Skip to content Skip to sidebar

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- - 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00
- - - - - - -

Supporter timezone: America/Lima (GMT-05:00)

Tagged: 

This topic contains 8 replies, has 1 voice.

Last updated by Andreas W. 3 days, 21 hours ago.

Assisted by: Andreas W..

Author Posts
September 18, 2025 at 3:22 am #17411562

rhettY

Background of the issue:
I am trying to resolve an error display for [esi wpml_language_selector_widget] in the secondary language within the Bricks editor. Please check this video for more details: hidden link.

Symptoms:
In the frontend, everything seems to be okay. However, in the Bricks editor, the secondary language displays an error.

Questions:
Why is there an error display in the Bricks editor for the secondary language?
How can I fix the error display for [esi wpml_language_selector_widget]?

September 18, 2025 at 3:57 am #17411566

rhettY

New issue after turning into ESI block. Switching currency, it would not reflect correctly in cart, no matter refreshing. The currency would always stay USD, though the currency has changed and displayed the switching currency in the page.

Please check the video:

hidden link

September 18, 2025 at 7:44 am #17411930

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

It is likely that the "esi" fails on the Bricks Editor.

I would suggest trying to wrap the shortcode in a conditional:

if ( ! is_admin() && ! defined( 'BRICKS_IS_EDITOR' ) ) {
    echo do_shortcode('[esi wpml_language_selector_widget]');
} else {
    echo do_shortcode('[wpml_language_selector_widget]');
}

This way, the normal WPML shortcode should be used on Bricks Editor, while the frontend keeps using the ESI version.

Best regards
Andreas

September 18, 2025 at 7:46 am #17411932

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

About the cart:

I would not suggest using ESI on the cart in this case.

if ( ! is_cart() ) {
    echo do_shortcode( '[esi wpml_currency_switcher_widget]' );
} else {
    // Optionally render nothing, or fallback to a static version
    // echo do_shortcode( '[wpml_currency_switcher_widget]' );
}
September 18, 2025 at 7:48 am #17411935

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

WPML would not be directly responsible for fixing ESI-related issues—especially those tied to rendering [esi wpml_language_selector_widget] or [esi wpml_currency_switcher_widget]—because ESI (Edge Side Includes) is a feature of the LiteSpeed Cache plugin and server, not WPML itself.

WPML’s Role
- WPML ensures its shortcodes (language switcher, currency switcher, etc.) are translatable and renderable.

- It does not control how LiteSpeed parses or caches ESI blocks.

- WPML can offer guidance or compatibility notes, but does not patch ESI behavior.

LiteSpeed’s Role
- LiteSpeed Cache plugin parses [esi ...] shortcodes and decides how to render them.

If the shortcode fails to render (e.g. shows raw text or errors in Bricks editor), it’s often due to:

- ESI not being enabled correctly

- Theme or builder not supporting ESI context

- Session or user-specific data not resolving inside the ESI block

September 18, 2025 at 8:03 am #17412009

rhettY

Hi Andreas,

The custom code should be put in functions.php, right?

I have a question about the currency cookie. I saw this doc: https://wpml.org/documentation/support/browser-cookies-stored-wpml/

So there are only below 4 cookies WPML uses, right?
wp-wpml_current_language
wp-wpml_current_admin_language_{hash}
_icl_visitor_lang_js
wpml_browser_redirect_test

And I saw this post: https://wpml.org/forums/topic/woocommerce-multilingual-multicurrency-detected-an-active-cache-plugin-3/. It mentioned below cookies, but I didn't see them in browser:
wcml_client_currency
wcml_client_currency_language
wcml_client_country

I set the currencies setting to show currencies based on "site language". This would remove above currency cookies, right?

Best Regards,

Rhett

September 18, 2025 at 8:18 am #17412118

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

The first provided code would be a conditional for your Bricks templates.

1. Use the “Code” Element
Drag the Code element into your layout.

Paste your PHP code inside it.

By default, the code is treated as a snippet—not executed.

2. Enable Code Execution
To actually run PHP:

Go to Bricks → Settings → Custom Code

Enable “Code Execution” for your user role (e.g. Administrator)

---

For the cart page, I would suggest using a hook in functions.php:

add_action( 'woocommerce_before_main_content', 'custom_wpml_currency_switcher_esi', 20 );

function custom_wpml_currency_switcher_esi() {
    if ( ! is_cart() && ! is_checkout() ) {
        echo do_shortcode( '[esi wpml_currency_switcher_widget]' );
    } else {
        // Optional fallback or nothing
        // echo do_shortcode( '[wpml_currency_switcher_widget]' );
    }
}

I am here hooking into "woocommerce_before_main_content" - depending on where you want the currency switcher to appear, you could also use:

- wp_header
- wp_footer
- woocommerce_after_cart_table
- woocommerce_before_cart_table
etc.

---

About WCML Cookies:

Those are usually only used if you use currency by location. Otherwise, WPML's language cookie would be sufficient to display currencies based onthe site language.

September 18, 2025 at 8:36 am #17412235

rhettY

Thanks Andreas. You solved my issue

September 18, 2025 at 8:50 am #17412319

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

I am glad to hear that 🙂

Have a nice day!