1 回答

TA貢獻1804條經驗 獲得超3個贊
更新:使用以下重新訪問和壓縮的代碼,該代碼使用未折扣的總數:
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
$minimum = 50;
$total = WC()->cart->total;
$discount_total = WC()->cart->get_discount_total(); // updated thanks to 7uc1f3r
$maximized_total = $total + $discount_total;
if ( $maximized_total < $minimum ) {
$notice = sprintf( __('Your current order total is %s — you must have an order with a minimum of %s to place your order '),
wc_price( $maximized_total ),
wc_price( $minimum )
);
if( is_cart() ) {
wc_print_notice( $notice , 'error' );
} else {
wc_add_notice( $notice , 'error' );
}
}
}
代碼進入您的活動子主題(或活動主題)的 functions.php 文件。測試和工作。
- 1 回答
- 0 關注
- 154 瀏覽
添加回答
舉報