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.

This thread is resolved. Here is a description of the problem and solution.

Problem:
When using Klarna Checkout and WooCommerce Multilingual, the prices in the secondary language are not processed correctly.

Solution:
This issue has already been escalated to our developers and will be resolved in a future release. There is a quick workaround fix that may help for the time being.

Open the file wp-content/plugins/woocommerce-multilingual/inc/class-wcml-orders.php

Search for the code

add_action('updated_post_meta', array($this,'update_order_currency'), 100,4);

Replace it with

//add_action('updated_post_meta', array($this,'update_order_currency'), 100,4);

This topic contains 3 replies, has 3 voices.

Last updated by Martin Schadegg Brønniche 2 weeks, 1 day ago.

Assigned support staff: Lauren.

Author Posts
October 3, 2019 at 12:33 pm

joostv-21

I am using the Klarna Checkout plugin and WPML / Woocommerce Multilingual (and multi-currency) to support my multi-language / multi-currency (WPML) webshop to receive multi-country payments (Klarna).
The default currency in my shop is EUR. Orders in EUR are processed just fine.
Orders in another currency (e.g. SEK) are not processed correctly. The order gets processed by the Klarna Checkout (and is registered correctly in their merchant portal), but when the order is actually registered in Woocommerce, the currency of all amounts suddenly changes to EUR. Like in order total is SEK 125, Woocommerce order total is EUR 125.

I have submitted this issue to Klarna as well, but as I noted a similar issue on this forum : https://wpml.org/forums/topic/showing-wrong-amount-for-other-currencies-in-multi-currency/ I was asking myself: Can it be that things still are not entirely compatible? When I look into Woocommerce Multilingual/Currencies I note "Klarna not supported" (and "Paypal Checkout not supported" so probably the same goes for Paypal....)

October 3, 2019 at 12:38 pm
October 3, 2019 at 12:41 pm #4687701

Lauren
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

Thank you for contacting WPML support. I'll be happy to help you with this. I found that this issue has already been escalated to our developers. There is a quick workaround fix that may help for the time being.

Open the file wp-content/plugins/woocommerce-multilingual/inc/class-wcml-orders.php

Search for the code

add_action('updated_post_meta', array($this,'update_order_currency'), 100,4);

Replace it with

//add_action('updated_post_meta', array($this,'update_order_currency'), 100,4);

Please let me know if the workaround resolves the issue for you. A permanent solution will be included in one of our future releases.

October 3, 2019 at 1:38 pm #4688095

joostv-21

My issue is resolved now.
I was struggling with this for about a day already because I suspected the Klarna Plugin. Will share the solution with Klarna as well.
I expect I have to re-apply the patch every time when I update WPML (until the patch is included)??

Thank you!

October 7, 2019 at 2:04 pm #4708197

Martin Schadegg Brønniche

This is not only at problem for Klarna, but all plugins which is updating meta data in the hook

woocommerce_checkout_update_order_meta

I have implementet a solution in a plugin I develop:

/**
	 * Solves problem with WPML changing the currency after meta data update due to update_order_currency in woocommerce-multilanugage/inc/class-wcml-orders.php:384
	 *
	 * @param $return
	 * @param $object_id
	 * @param $meta_key
	 * @param $meta_value
	 * @param $prev_value
	 *
	 * @return mixed
	 */
    function shortCircuitWPMLCurrencyUpdate($return, $object_id, $meta_key, $meta_value, $prev_value) {
    	if($meta_key === '_order_currency') {
		    if(!empty($prev_value)) {
		    	return false;
		    }

		    $old_value = get_metadata('post', $object_id, $meta_key);
		    if(count($old_value) > 0) {
			    if(!empty($old_value[0])) {
				    return false;
			    }
		    }
	    }

    	return $return;
    }

and then

add_filter('update_post_metadata', 'shortCircuitWPMLCurrencyUpdate', 99, 5);

before caling

update_post_meta(...);

and

remove_filter('update_post_metadata', 'shortCircuitWPMLCurrencyUpdate', 99);

after.