Минимальный заказ на Woocommerce (несколько валют)

этот код работает для всего, я хочу указать его для определенной валюты
например, 14$ минимальный заказ в USD, но когда конвертер валют в AED осталось 14 так и должно быть 51.52 AED

function wc_minimum_order_amount() {
// Set this variable to specify a minimum order value
$minimum = 14;

if ( WC()->cart->total < $minimum ) {
if( is_cart() ) {
wc_print_notice(
sprintf( 'You must have an order with a minimum of 52.5 AED Or 14 $ to place your order' ,
wc_price( $minimum ),
wc_price( WC()->cart->total )
), 'error'
);
} else {
wc_add_notice(
sprintf( 'You must have an order with a minimum of %s to place your order, your current order total is %s.' ,
wc_price( $minimum ),
wc_price( WC()->cart->total )
), 'error'
);
}
}
}

0

Решение

Вы можете определить переменную minium следующим образом:

  add_action( 'woocommerce_checkout_process', 'wc_minimum_order_amount' );
add_action( 'woocommerce_before_cart' , 'wc_minimum_order_amount' );
function wc_minimum_order_amount() {
// Set this variable to specify a minimum order value

$currency = get_woocommerce_currency();

if ($currency == 'USD'){
$minimum = 14;
}else{
$minimum =51.52;
}


if ( WC()->cart->total < $minimum ) {
if( is_cart() ) {
wc_print_notice(
sprintf( 'You must have an order with a minimum of 52.5 AED Or 14 $ to place your order' ,
wc_price( $minimum ),
wc_price( WC()->cart->total )
), 'error'
);
} else {
wc_add_notice(
sprintf( 'You must have an order with a minimum of %s to place your order, your current order total is %s.' ,
wc_price( $minimum ),
wc_price( WC()->cart->total )
), 'error'
);
}
}
}

проверил и работает

0

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector