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