• Resolved InvestiSocial

    (@investisocial)


    Hello,
    i need to block multi vendor orders because I use stripe split payment and I need to have one order for one payment for each vendor.
    I just blocked it when enduser try to add a product of another vendor adding this code to child function.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

    It regularly works but how can i block it into the checkout page too?
    Can you help me please?
    Thank you.
    Regards
    Carlo

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author WC Lovers

    (@wclovers)

    Hi,

    Why are you adding custom code for the purpose.

    There has setting option for this.

    Just enable “Disable Multivendor Checkout” option from WCFM Admin Setting – Order setting – https://ibb.co/f0LBs1p

    Thank You

    Thread Starter InvestiSocial

    (@investisocial)

    Thank you for your reply.
    I’ve disabled multivendor orders, but it doesn’t work.
    I regularly can do an order with products from different vendors.
    Can you help me, please?
    Thank you.
    Regards
    Carlo

    Plugin Author WC Lovers

    (@wclovers)

    Do you have any other WooCommerce related plugins which control add to cart function?

    Thread Starter InvestiSocial

    (@investisocial)

    No, only this code in child funtion.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

    This code works on adding to cart button.

    Thank you..

    Plugin Author WC Lovers

    (@wclovers)

    Please remove that and use that setting option only.

    Thread Starter InvestiSocial

    (@investisocial)

    Done and it regularly works, but I have this problem: Your feature only works if you try to add a product to the cart from different stores.
    I have an app that works with another logical cart. The only shared page that links the website and the app is the checkout page, because app uses the web checkout page.
    So I have to block all the orders with different vendor’s products into checkout page.
    Can you help me?
    Thank you.
    Regards
    Carlo

    Hi InvestiSocial,
    I also have this same problem, did you resolve it?

    grouping per vendor like this is should be nice from WCFM : https://imgur.com/a/aPoEJ9t

    could you share with me please if you solve it? have you success add product vendor but notify to customer that they order more than 1 vendor in checkout?

    Thanks.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘WCFM checkout validation’ is closed to new replies.