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 topic contains 3 replies, has 3 voices.

Last updated by kristinaF-2 1 year, 5 months ago.

Author Posts
May 16, 2018 at 6:13 am #2149995

josipC-2

A Payment Gateway I am using expects only Croatian currency so I am trying to update cart total and its currency by using a filter on placing order if the currency is Euro. I have successfully changed cart total but I can't change string currency . How can I do it inside following action?

// Set currency
function change_existing_currency() {
return 'HRK';
}

function change_total_on_checking($order) {

// Get order total
$total = $order->get_total();

// Change cart total on creating order
if(get_woocommerce_currency() === 'EUR') {

// Change currency somewhere here - currently this doesn't work
add_filter('woocommerce_currency', 'change_existing_currency', 999, 2);

// Set new cart total
$new_total = $total * get_currency_rate();
$order->set_total($new_total);

}

}
add_action( 'woocommerce_checkout_create_order', 'change_total_on_checking', 999, 1 );

So far I have tried this filters without luck:

add_action('wcml_set_client_currency', 'change_existing_currency', 999999, 1);
add_filter('woocommerce_currency_symbol', 'change_existing_currency_symbol', 9999999); // return '&kn';
add_filter('woocommerce_currency', 'change_existing_currency', 9999999);
add_filter('wcml_client_currency', 'change_existing_currency');
add_filter('wcml_get_client_currency', 'change_existing_currency');

May 16, 2018 at 7:35 am #2150743

josipC-2

SOLVED

May 31, 2018 at 2:18 am #2253996

alexanderK-15

Could you please share how you solved it and if possible how at all you programmatically change the currency if not matching the selected payment method?

September 26, 2019 at 8:36 am #4644503

kristinaF-2

Dough.. Would you care to share your solution instead of just saying "Solved"?...