PluginUs.Net - Business Tools for WooCommerce and WordPress

[realize your idea - make your dreams come true]

Support Forum

You need to log-in to create request (topic) to the support

Need to apply disscount depending on currency

The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday. If you have problems with registration ask help on contact us page please
If you not got email within 24~36 business hours, firstly check your spam box, and if no any email from the support there - back to the forum and read answer here. DO NOT ANSWER ON EMAILS [noreply@pluginus.net] FROM THE FORUM!! Emails are just for your info, all answers should be published only here.
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday.

Hello, I need to make a 20% discount depending on if the currency is USD or not.
The code is the following:

if(get_woocommerce_currency() =='USD'){
add_filter('raw_woocommerce_price', 'descuento_usd');
function descuento_usd($price){
$price = $price - ($price * 0.2);
return $price;
}
}

The problem that I'm actually having is that when I publish the code, then my woocommerce is always at another currency. I mean, I change the currency to USD and it's showing perfectly, however at the checkout page or mini-cart it is always showing on another currency (the main one)

How can I solve this, or edit the $price after change the currency to USD?

Update: I solved this using

$WOOCS->current_currency == 'USD'

Instead

get_woocommerce_currency() =='USD'

 

However I'd like to know why is this :) Thank a lot

Hello

Try to use:

add_filter('raw_woocommerce_price', 'descuento_usd');
function descuento_usd($price){

if(get_woocommerce_currency() =='USD'){
$price = $price - ($price * 0.2);

}
return $price;
}