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

    (@wclovers)

    However, when the customer sees the cart, a “continue shopping” button appears for him. I would like this button to direct the customer to the store page

    – Do you have only one store?

    Hope no.

    Suppose cart has products from 2 vendors, then which store page will be linked?

    Thank You

    Thread Starter lsesol

    (@lsesol)

    Hello,

    The buyer will only have products in his cart from a single seller.

    Plugin Author WC Lovers

    (@wclovers)

    That’s great. Then add this snippet to your site –

    add_filter( 'woocommerce_continue_shopping_redirect', function( $redirect_url ) {
    	$vendor_id = 0;
    	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( function_exists( 'wcfm_is_vendor' ) && wcfm_is_vendor( $cart_product_author ) ) {
    			$vendor_id = $cart_product_author;
    			break;
    		}
    	}	
    	if( $vendor_id ) {
    		$redirect_url = wcfmmp_get_store_url( $vendor_id );
    	}
    	return $redirect_url;
    }, 100 );

    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://www.ads-software.com/plugins/code-snippets/

    Thank You

    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 );
    
    • This reply was modified 4 years, 9 months ago by shayed.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Continue Shopping cart button link not direct to the source store URL’ is closed to new replies.