Banner Logo

Be a part of the family: Connect, Receive Support,
Contribute, and Reap Abundant Rewards

Limiting checkout to 1 vendor

Theme and Plugin Support

Resolved
Viewing 1 reply thread
  • Author
    Posts
    • #133618
      kevin.batchelor
      Participant

      Good Day

      We are having trouble with our courier partner and dispatching items for Multi basket checkout.

      Is there a way to not allow users to add items to their cart if it Is coming from multiple vendors? We would like to allow single carts from single vendors

    • #133649

      Hi Kevin, thanks for getting in touch with us.

      In order to allow users to add from one vendor only please add this code in the function.php of the theme :

      ‘add_action(‘woocommerce_add_to_cart_validation’,’woocommerce_add_to_cart_validation’,10,3);
      function woocommerce_add_to_cart_validation($passed, $product_id, $quantity){
      foreach (WC()->cart->get_cart() as $cart_key => $cart_item ){
      $cart_vendor = get_wcmp_product_vendors($cart_item[‘product_id’]);
      $product_vendor = get_wcmp_product_vendors($product_id);
      if($cart_vendor && $product_vendor){
      if($cart_vendor->id != $product_vendor->id){
      $passed = false;
      wc_add_notice( __( ‘Another vendor product is already in your cart.’, ‘woocommerce’ ), ‘error’ );
      return $passed;
      }
      }
      }
      return $passed;
      }’

Viewing 1 reply thread

The topic ‘Limiting checkout to 1 vendor’ is closed to new replies.