0
当用户在购物车上时,我想在最终订单中输入我的订单,并希望在完成时验证最小金额。需要乘以7.woocommerce的产品最小量乘以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));
}
}
嗨!这很好,但我想在用户点击“下订单”按钮时做这项工作......当用户下订单时...... – Hateres1990
@ Hateres1990:我已更新我的答案,请看看。 –
我看到它的作品,但我需要这个版本。朋友,谢谢:) – Hateres1990