• Resolved srlimon

    (@srlimon)


    Is there a hook or filter to direct the customer to the upsell product page once this was “added” ? I have a Greeting Card which customer can add a custom msg, so they need to be taken to the card/product page.

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

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Giacomo

    (@jakjako)

    Hi,
    currently there’s no hook for that, I’m sorry.

    Thread Starter srlimon

    (@srlimon)

    ohh ??
    This plugin covered almost all my needs. I’ll still research on how I could implement it to my needs and purchase the paid version.

    Please consider this a feature on future development, as one might need for variable products, even on your demo website, to take customer to product page and “custom to add”
    Brownie points if this can be configurable by each upsell.

    Plugin Author Giacomo

    (@jakjako)

    To be honest, this is not an hard thing to do! We may add a filter these days ??
    Give us 2-3 days!

    Plugin Author Giacomo

    (@jakjako)

    Let me recap:
    when the user clicks “add upsell” (or the text you’ve put there), instead of adding the item to cart, we redirect it to the product page?

    Thread Starter srlimon

    (@srlimon)

    Yes, redirect to product page with custom text (either defined by specific upsell, or product or product category)
    This is useful for variable products when customer need to choose options (T-shirt size for example) prior to add to cart.

    See live example
    https://www.staging9.thefunguywa.com.au/

    On all pages I removed the “add to cart” buttom/function and replaced to “customeze” & linking to product page with this on my functions.php

    add_action( 'woocommerce_is_purchasable', 'hide_add_to_cart_function', 10, 2 );
    
    function hide_add_to_cart_function( $return_value, $product )
    	{
    	// Remove only if Cards category and is not on single product page (removes from shop, home, categories, etc)
    	if ( has_term( 'Cards', 'product_cat' ) AND !is_product() ) {
    			return false; //will replace badd to cart to "rad more" linking to single product page
    	}
    
    return $return_value;
    }
    
    //replace text on "Add to cart button" to "Customize"
    add_filter( 'woocommerce_product_add_to_cart_text', 'custom_replace_read_more' );
      
    function custom_replace_read_more( $text ) {
       global $product;       
    //    if ( $product && ! $product->is_in_stock() ) {  
      if ( has_term( 'Cards', 'product_cat' ) ) {         
          return 'Customize';
       } 
       return $text;
    }
    Plugin Author Giacomo

    (@jakjako)

    The problem is that doing that you are losing the discount effect of the upsell and so the main power of our plugin.
    We can do what you are asking for: redirect to product page when clicking the upsell up button. But we can’t keep the discount amount set.

    Thread Starter srlimon

    (@srlimon)

    How would I do it, even if is suing a filter or hook?

    Plugin Author Giacomo

    (@jakjako)

    Update to the last version and try this code:

    add_action(‘wjufw_add_to_cart_parameters’, function( $prod ){

    $url = get_permalink( $prod->get_id() );
    echo “href='”. $url .”‘ class=’button product_type_simple'”;
    });

    Thread Starter srlimon

    (@srlimon)

    Legend. Worked like a charm!
    With my rudimentary php skills I managed to adapt your code to 1 unique product with:

    add_action('wjufw_add_to_cart_parameters', function( $prod ){
    	if ($prod->get_id() == '12629') {
    		$url = get_permalink( $prod->get_id() );
    		echo "href='". $url ."' class='button product_type_simple'";
    	}
    });

    Any idea how to trigger this Action on all products of a product category?
    I tried the below without sucess:

    add_action('wjufw_add_to_cart_parameters', function( $prod ){
    	$prod_cats = wc_get_product_category_list( $prod->get_id() );
    	
    	foreach (wc_get_product_category_list( $prod->get_id() ) as $prod_cat) {
    // 		if ( has_term( 'Cards', $prod_cat ) ) { 
    		if (str_contains('Cards' , $prod_cat )) {
    // 		if (strpos('Cards' , $prod_cat) !== FALSE) { 
    			$url = get_permalink( $prod->get_id() );
    			echo "href='". $url ."' class='button product_type_simple'";
    		}
    	}
    });

    This plugin now does what I need, any chance you’re available to look on the ajax loading error if I give you admin rights? at staging9.thefunguywa.com.au

    Plugin Author Giacomo

    (@jakjako)

    Try something like:

    add_action('wjufw_add_to_cart_parameters', function( $prod ){
    
    	$categories_slug = ['card','other-slug'];
    	$prod_id = $prod->get_id();
    	
    	if( has_term( $categories_slug, 'product_cat', $prod_id )) 
    	{	
    		$url = get_permalink( $prod->get_id() );
    		echo "href='". $url ."' class='button product_type_simple'";
    	}
    });

    Which ajax loading error? Usually js can be debugged even without login.

    Thread Starter srlimon

    (@srlimon)

    Rockstar!

    The ajax error was fixed when I uninstalled my other side cart plugin (just deactivating it didn’t help) all working perfectly now.
    Upgrading to pro version, your support has been awesome.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Take customer to product page on ADD’ is closed to new replies.