• Resolved boutzamat

    (@boutzamat)


    When i create an invoice (manually) it uses user language and not the sites language.
    This is very problematic since the site has multiple admins who has each of their own user-language set from their user profile.

    This specific store is only selling to english clients but some of the admins are danish and prefer to use WP backend in their own language. This is currently causing some problems.

    Is it possible to set a static language for the PDF? Or to have it use the site language always instead of the user language?

    Thanks in advance.

Viewing 1 replies (of 1 total)
  • Plugin Contributor Yordan Soares

    (@yordansoares)

    Hello @boutzamat,

    We follow the WooCommerce convention of adapting to the language of the context which means that if admins have set a different language for their profile (they’re the only ones able to do so), they’ll see the document in that language. For multilingual setups (WPML or Polylang, using our Professional extension) this is different and the language or the order is always leading.

    You can override this with the plugin_locale filter:

    add_filter( 'plugin_locale', 'filter_plugin_locale', 10, 2 );
    function filter_plugin_locale( $locale, $textdomain ) { 
    	if ( $textdomain === 'woocommerce-pdf-invoices-packing-slips' ) {
    		$locale = get_locale();
    	}
    	return $locale; 
    }

    Important to note:
    Our plugin loads translations at plugins_loaded, which means that you can’t put this filter in your theme functions.php because it executes too late. Using a plugin like Code Snippets or putting this in a mu-plugin will work fine though.

    Regular users will always see the invoice in the site language, not their profile language. Our Professional extension offers an option to keep the actual PDF on file and thus only ever serve one ‘version’ whichever language was used the first time the PDF was generated).

Viewing 1 replies (of 1 total)
  • The topic ‘Wrong language on the invoice’ is closed to new replies.