【发布时间】:2019-05-31 13:31:18
【问题描述】:
我使用在购物车页面上显示消息“您当前的订单总数是%s 来下订单”的代码,并锁定按钮,直到客户收集到一定数量的正确数量的产品。
代码如下:
/* Set a minimum order amount for checkout */
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 = 1000;
if ( WC()->cart->total < $minimum ) {
if( is_cart() ) {
wc_print_notice(
sprintf( 'Your current order total is %s — you must have an order with a minimum of %s to place your order ' ,
wc_price( WC()->cart->total ),
wc_price( $minimum )
), 'error'
);
} else {
wc_add_notice(
sprintf( 'Your current order total is %s — you must have an order with a minimum of %s to place your order' ,
wc_price( WC()->cart->total ),
wc_price( $minimum )
), 'error'
);
}
}
}
如何根据这段代码制作进度条?向客户清楚地显示了订单的最低数量以及他添加了多少产品。
例如基于此:Dynamic Progress Bar with Labels
我在 WooCommerce 中找不到类似的东西。我希望这段代码对许多开发者有用。
【问题讨论】:
标签: wordpress woocommerce