ShopEngine Multilingual Hooks for Developers

ShopEngine comes with WPML and Polylang multilingual by default. However, if you want to use other multi-language plugins there are a bunch of hooks available for developers. The developers can customize the multilingual functionalities of ShopEngine using these hooks.

Hook to set the user’s current language code: #

Here is the hook to set users’ current language. You can use this hook to define the language that the website is currently using.

Here is the hook to set the user’s current language code:

add_filter('shopengine_language_code', function () {
        return 'bn';
    });

Hook to set all available languages: #

The following hook is for multi-language support. You can add the languages that your website supports using this hook.

In this array format, you will add the language code (language_code), name of the translated language (translated_name), and the country flag URL (country_flag_url). You must set the status to “true” under the lang_items array to enable multilingual support.

Here is the hook to set all available languages:

add_filter('shopengine_multi_language', function () {
        $languages = [
            'en' => [
                'language_code'    => 'en',
                'translated_name'  => 'United States English',
                'country_flag_url' => 'http://example.com/en.png'
            ],
            'bn' => [
                'language_code'    => 'bn',
                'translated_name'  => 'Bangla',
                'country_flag_url' => 'http://example.com/bn.png'
            ]
        ];
        return ['lang_items' => $languages, 'status' => true];
    });

Hook to get all the ShopEngine module settings: #

This action hook is used to get all the ShopEngine module settings on save. When users make any changes to any ShopEngine module, this action will be fired as soon as they save the changes. And the settings will be executed under the “$args” function.

Here is the action hook to get all the ShopEngine module settings on save.

  add_action('shopengine/core/settings/on_save', function ($args) {
        // execute your code
    });
What are your feelings
Updated on November 1, 2022