Skip Navigation

Open

Reported for: WooCommerce Multilingual & Multicurrency 5.3.2

Topic Tags: Bug

Overview of the issue

Currently, the order note added automatically after a first purchase may appear in the language where the order was done, instead of the default admin language. This issue is specific to situations where the user completes the purchase in a secondary language.

Workaround

Please, make sure of having a full backup of your site before proceeding.

  • Open your theme’s functions.php file.
  • Add the following snippet:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    // The action is added only once, we are removing it just after it's called.
    // The same happens for the hook to restore the language once the note is added.
    $temporarilySwitchToDefaultLang = function() use ( &$temporarilySwitchToDefaultLang ) {
        add_action( 'woocommerce_order_status_processing', $temporarilySwitchToDefaultLang );
        do_action( 'wpml_switch_language', apply_filters( 'wpml_default_language', null ) );
     
        $restoreLang = function() use ( &$restoreLang ) {
            remove_action( 'woocommerce_order_note_added', $restoreLang );
            do_action( 'wpml_switch_language', null );
        };
     
        add_action( 'woocommerce_order_note_added', $restoreLang );
    };
     
    add_action( 'woocommerce_order_status_processing', $temporarilySwitchToDefaultLang );

Leave a Reply

Please stay on topic and be respectful to others. If you need help with issues not related to this post, use our Support Forum to start a chat or submit a ticket.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>