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 关注
- 120 浏览
添加回答
举报