Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WC Marketplace › Disable a feature
- This topic has 1 reply, 2 voices, and was last updated 2 years, 11 months ago by
Sarmistha Chakraborty.
Viewing 1 reply thread
- AuthorPosts
- April 10, 2020 at 11:22 pm #117776
matfeinikolaev
ParticipantHello! My question is: You have a feature, allowing customers to buy products from different vendors in a single order. How can I disable this feature? I need a customer to do two different orders if he is buying from two vendors. Thank you
- April 11, 2020 at 8:32 pm #118067
Sarmistha Chakraborty
KeymasterHello,
You just have to add this code to your child theme’s functions.php –
add_action( 'woocommerce_add_to_cart_validation', function( $is_allow, $product_id, $quantity ) { $product = get_post( $product_id ); $product_author = $product->post_author; //Iterating through each cart item foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { $cart_product_id = $cart_item['product_id']; $cart_product = get_post( $cart_product_id ); $cart_product_author = $cart_product->post_author; if( $cart_product_author != $product_author ) { $is_allow = false; break; } } if( !$is_allow ){ // We display an error message wc_clear_notices(); wc_add_notice( __( "Well, you already have some item in your cart. First checkout with those and then purchase other items!", "wcfm-ecogear" ), 'error' ); } return $is_allow; }, 50, 3 );
Thanks.
- AuthorPosts
Viewing 1 reply thread
- You must be logged in to reply to this topic.