Answer the question
In order to leave comments, you need to log in
How to set up plugin for Woocommerce on Wordpress?
There is such a problem with setting up a plugin for Woocommerce that displays different currencies. Installed WooCommerce Currency Switcher, turned it on and got a couple of problems.
So. It turns out that the main currency there is the US dollar.
This is how the basket for the dollar looks like
. And in the end, everything is correctly calculated, the delivery is also 1.5 bucks
. And now we just switch to EURO. The page has been updated and now the cart is correct.
But now the delivery has suddenly grown many times, although it costs $ 1.5
The same thing, if, for example, we switch to Ukr. hryvnia or ruble
AND delivery
I understand that this is a plugin bug. Here I found a crutch, which should help with something, but it did not help anything.
add_action('woocommerce_before_calculate_totals', 'fix_currency_conversion');
function fix_currency_conversion($cart_object){
global $WOOCS;
$cur_currency = $WOOCS->current_currency;
$currencies = $WOOCS->get_currencies();
$conversion_rate = $currencies[$WOOCS->current_currency]['rate'];
if($cur_currency == 'USD'){
foreach ( $cart_object->cart_contents as $cart_item_key => $cart_item ) {
$cart_item['data']->price = $cart_item['data']->price / $conversion_rate;
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question