Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Woo Discount Rules: Compatible for Multi Currency for WooCommerce by villaTheme
if(!function_exists('woo_discount_rules_before_apply_discount_method')){
function woo_discount_rules_before_apply_discount_method($price, $product, $cart){
$class_exists = false;
if(class_exists('WOOMULTI_CURRENCY_F_Data')){
$setting = new WOOMULTI_CURRENCY_F_Data();
$class_exists = true;
} elseif(class_exists('WOOMULTI_CURRENCY_Data')){
$setting = new WOOMULTI_CURRENCY_Data();
$class_exists = true;
}
if($class_exists === true){
$selected_currencies = $setting->get_list_currencies();
$current_currency = $setting->get_current_currency();
if ( ! $current_currency ) {
return $price;
}
if ( $price ) {
$price = $price / $selected_currencies[ $current_currency ]['rate'];
}
}
return $price;
}
}
add_filter('woo_discount_rules_before_apply_discount', 'woo_discount_rules_before_apply_discount_method', 10, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.