Title: cart
Last modified: June 11, 2020

---

# cart

 *  Resolved [shayed](https://wordpress.org/support/users/shayed/)
 * (@shayed)
 * [6 years ago](https://wordpress.org/support/topic/cart-17/)
 * hi bro is it possible when a buyer add a product to his cart that click will 
   direct him to seller shop page aswell?
    note i am using a code where customer
   can buy from one seller at a time
 *     ```
       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( __( " one seller at a time!", "wcfm-ecogear" ), 'error' );
       	}
   
       	return $is_allow;
       }, 50, 3 );
       ```
   

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [WC Lovers](https://wordpress.org/support/users/wclovers/)
 * (@wclovers)
 * [5 years, 12 months ago](https://wordpress.org/support/topic/cart-17/#post-12988734)
 * > when a buyer add a product to his cart that click will direct him to seller
   > shop page aswell?
 * – Where it’s redirecting now?
 * > note i am using a code where customer can buy from one seller at a time
 * – No code required for this. There has setting for this at WCFM Admin Setting–
   Order Setting – [https://ibb.co/f0LBs1p](https://ibb.co/f0LBs1p)
 *  Thread Starter [shayed](https://wordpress.org/support/users/shayed/)
 * (@shayed)
 * [5 years, 12 months ago](https://wordpress.org/support/topic/cart-17/#post-12988962)
 * I mean when a customer adds a product from woocommerce it should redirect to 
   seller store page. Lets say customers search by biryani in woocommerce page n
   biryanies from different sellers come out n buyers click add to cart then briyani
   from x seller added to cart n seller redirect to x seller home page.
 *  Plugin Author [WC Lovers](https://wordpress.org/support/users/wclovers/)
 * (@wclovers)
 * [5 years, 12 months ago](https://wordpress.org/support/topic/cart-17/#post-12991306)
 * Understand. Add this snippet to your site –
 *     ```
       add_filter( 'woocommerce_add_to_cart_redirect', function( $url, $product ) {
       	if( $product && is_object( $product ) && method_exists( $product, 'get_id' ) && function_exists( 'wcfm_get_vendor_id_by_post' ) ) {
       		$vendor_id = wcfm_get_vendor_id_by_post( $product->get_id() );
       		if( $vendor_id && function_exists( 'wcfmmp_get_store_url' ) ) {
       			$url = wcfmmp_get_store_url( $vendor_id );
       		}
       	}
       	return $url;
       }, 500, 2 );
       ```
   
 * Add custom code(s) to your child theme’s functions.php
    In case you do not have
   child theme then add those using this plugin – https://wordpress.org/plugins/
   code-snippets/
 *  Thread Starter [shayed](https://wordpress.org/support/users/shayed/)
 * (@shayed)
 * [5 years, 12 months ago](https://wordpress.org/support/topic/cart-17/#post-12991834)
 * Hi thank you. Sorry to say it only works from single product page. From search
   result page it just adds to cart. Any idea whats wrong? i used oceanwp theme.
 *  Plugin Author [WC Lovers](https://wordpress.org/support/users/wclovers/)
 * (@wclovers)
 * [5 years, 12 months ago](https://wordpress.org/support/topic/cart-17/#post-12991935)
 * Enable this setting option from WooCommerce – Setting – Products – [https://ibb.co/dkr49wG](https://ibb.co/dkr49wG)
 *  Thread Starter [shayed](https://wordpress.org/support/users/shayed/)
 * (@shayed)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/cart-17/#post-13002059)
 * Thanks bro i also think of that. Bro just want to know when do your products 
   go on sales? like to buy few for my single site.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘cart’ is closed to new replies.

 * ![](https://ps.w.org/wc-multivendor-marketplace/assets/icon-256x256.gif?rev=2611991)
 * [WCFM Marketplace - Multivendor Marketplace for WooCommerce](https://wordpress.org/plugins/wc-multivendor-marketplace/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wc-multivendor-marketplace/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wc-multivendor-marketplace/)
 * [Active Topics](https://wordpress.org/support/plugin/wc-multivendor-marketplace/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wc-multivendor-marketplace/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wc-multivendor-marketplace/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [shayed](https://wordpress.org/support/users/shayed/)
 * Last activity: [5 years, 11 months ago](https://wordpress.org/support/topic/cart-17/#post-13002059)
 * Status: resolved