WCFM checkout validation
-
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 messageIt regularly works but how can i block it into the checkout page too?
Can you help me please?
Thank you.
Regards
CarloThe page I need help with: [log in to see the link]
- The topic ‘WCFM checkout validation’ is closed to new replies.