2016-10-20 21 views
0

お客様はカート内の各商品カテゴリごとに€100以上の注文を行わなかった場合、エラーメッセージ(カートとチェックアウトページ)を受け取ってチェックアウトをブロックします。Woocommerce - カテゴリごとに最低注文額を設定してください

私の店では、私は6つのブランドを持っています。これらは6つのカテゴリーに分かれています。したがって、顧客がカート内にブランドAの製品を保有している場合、その注文を完了させるためには、カート内に少なくとも100ユーロ相当のブランドを持っていなければなりません。カートに複数のブランドが含まれている場合、顧客はカート内で各ブランドの€100以上を注文する必要があります。

最小€100はすべてのブランド(商品カテゴリ)の総称であるため、特定のカテゴリに固有の最小値を設定する必要はありません。すべてのブランドは同じ最小です。 EUROSは私の通貨です。 NOMOQ

私は一般的な最小の順序を設定し、それがで無効にすることができるようにするには、このコードを持っている:

そして最後に、ではなく、少なくとも、私は、このルールは、顧客がこのコードのクーポンが適用されたときに無効にすることにしたいですクーポン:私は私のニーズに合うように、このコードを変更することができます

/** 
* Give the site a minimum order amount that can be avoided by using a coupon code 
* 
* @return void 
*/ 
public function minimum_order_amount() { 

    // Set this variable to specify a minimum order value 
    $minimum = 100; 

    // No minimum purchase if a specific coupon code is used 
    if (WC()->cart->has_discount('nomoq')) { 
     return; 
    } 

    if (WC()->cart->total < $minimum) { 
     $message = sprintf(
      'You must order at least a total of %s (excluding shipping and VAT) of one brand or a combination of brands. <a title="Find out more!" href="%s" target="_blank">Find out more!</a>', 
      wc_price($minimum), 
      site_url('/ordering/#moq') 
     ); 

     if (is_cart()) { 
      wc_print_notice($message, 'error'); 
     } else { 
      wc_add_notice($message, 'error'); 
     } 
    } 
} 

?ありがとう!

答えて

0

あなたはまた、このリンクをチェックすることができ、

add_action('woocommerce_check_cart_items', 'spyr_set_max_campioni'); 
function spyr_set_max_campioni() { 
// Only run in the Cart or Checkout pages 
if(is_cart() || is_checkout()) { 
global $woocommerce, $product; 
$cart_num_products = 0; 
foreach ($woocommerce->cart->cart_contents as $product) { 
// See if any product is from the campioni category or not 
if (has_term('campioni', 'product_cat', $product['product_id'])) { 
$cart_num_products++; 
} 
} 
wc_add_notice(sprintf('You can buy a maximum of 3 samples.' 
Currently there are in the cart:% s. ', 
$cart_num_products 
'error'); 
} 
} 
} 

をチェックアウトする前に、特定のカテゴリから製品の最大数を設定し、// それは便利です

https://docs.woocommerce.com/document/minmax-quantities/

https://wordpress.org/plugins/minimum-purchase-for-woocommerce/screenshots

https://wordpress.org/plugins/woocommerce-incremental-product-quantities/screenshots/

関連する問題