public static function updateShipping($rates, $package) { $products=$package['contents']; $product=reset($products); $total=$package['contents_cost']; $total_brixen = $total*1.25; /**** BRIXEN - INFO: To get total incl. tax (25%) when comparing with Free Shipping minimum amount (this amount is incl. tax, so total has to be incl. tax also) *****/ $shipping=ThemexShop::getShipping(ThemexUser::getShop($product['data']->post->post_author)); $country=''; if(isset($package['destination']) && isset($package['destination']['country'])) { $country=$package['destination']['country']; } if(!empty($rates)) { foreach($rates as $key => $rate) { if(isset($shipping[$key]) && !empty($shipping[$key])) { $method=$shipping[$key]; $enabled=themex_value('enabled', $method); $available=themex_value('availability', $method); //$amount=themex_value('min_amount', $method); // BRIXEN / ENIITO // Convert the amount from base currency to the active currency // @author Aelia $amount = aelia_convert_to_currency(themex_value('min_amount', $method)); $countries=themex_array('countries', $method, array()); //if($enabled=='no' || (!empty($amount) && $total<$amount) || ($available=='specific' && !in_array($country, $countries))) { if($enabled=='no' || (!empty($amount) && $total_brixen<$amount) || ($available=='specific' && !in_array($country, $countries))) { //****** BRIXEN */ /** echo ''; **/ unset($rates[$key]); } else if($key=='flat_rate') { $default=round(floatval(themex_value('default_cost', $method)), 2); $costs=themex_array('costs', $method); $cost=$default; $rates[$key]->cost=$cost; } else if($key=='international_delivery') { if(($available=='including' && !in_array($country, $countries)) || ($available=='excluding' && in_array($country, $countries))) { unset($rates[$key]); } else { $default=round(floatval(themex_value('cost', $method)), 2); $rates[$key]->cost=$default; } } else if($key=='local_delivery') { $default=round(floatval(themex_value('cost', $method)), 2); $rates[$key]->cost=$default; } } } } return $rates; } function aelia_convert_to_currency($price, $to_currency = null, $from_currency = null) { // If source currency is not specified, take the shop's base currency as a default if(empty($from_currency)) { $from_currency = get_option('woocommerce_currency'); } // If target currency is not specified, take the active currency as a default. // The Currency Switcher sets this currency automatically, based on the context. Other // plugins can also override it, based on their own custom criteria, by implementing // a filter for the "woocommerce_currency" hook. // // For example, a subscription plugin may decide that the active currency is the one // taken from a previous subscription, because it's processing a renewal, and such // renewal should keep the original prices, in the original currency. if(empty($to_currency)) { $to_currency = get_woocommerce_currency(); } // Call the currency conversion filter. Using a filter allows for loose coupling. If the // Aelia Currency Switcher is not installed, the filter call will return the original // amount, without any conversion being performed. Your plugin won't even need to know if // the multi-currency plugin is installed or active return apply_filters('wc_aelia_cs_convert', $price, $from_currency, $to_currency); }