【发布时间】:2017-05-09 07:45:07
【问题描述】:
当用户在购物车上并希望在完成时验证最小金额时,我想在最终下订单。需要乘以 7。
例如.. 我店里有 20 种产品。最小产品数量是任何产品的 7 的乘积。
Ex:
Product with ID:3 & Quantity: 5
Product with ID:13 & Quantity: 2
=> Total:7 = > Success
Product with ID:2 & Quantity: 3
Product with ID:6 & Quantity: 8
=> Total: 11 => Fail
Product with ID:1 & Quantity: 2
Product with ID:5 & Quantity: 8
Product with ID:11 & Quantity: 4
=> Total: 14 => Success
我该怎么做?这是我尝试过的
function wc_minimum_order_amount() {
global $woocommerce;
$minimum = 7;
if ( $woocommerce->cart->get_cart_total() % $minimum != 0) {
$woocommerce->add_error( sprintf( 'You must have an order with a minimum of %s to place your order.' , $minimum ) );
}
}
【问题讨论】:
标签: php wordpress woocommerce cart hook-woocommerce