• Resolved Claudio

    (@cl4udio)


    Hi team!

    I need send my customers to another page (specific URL) after clicking in the “Add to cart” button of the plugin.

    How we can do that?

    Thanks in advance

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter Claudio

    (@cl4udio)

    I’ve inserted a function and is working good on the default “Add to cart” buttons from WooCommerce, but for the “Add to cart” button of your plugin, doesn’t working.

    Have any idea?

    Plugin Contributor Ewout

    (@pomegranate)

    Hello Claudio,
    What function did you use for the other add to cart buttons? Let me know and I’ll see if I can adapt this so that it works with the Bulk Order Form too!

    Ewout

    Thread Starter Claudio

    (@cl4udio)

    Thanks for your reply,

    Here the function:

    // Redirect after clicking "add to cart" button
    function my_custom_add_to_cart_redirect( $url ) {
    	$url = home_url( '#url-or-id' ); // URL to redirect
    	return $url;
    }
    add_filter( 'woocommerce_add_to_cart_redirect', 'my_custom_add_to_cart_redirect' );
    Plugin Contributor Ewout

    (@pomegranate)

    I see – because the bulk order form adds the items to the cart via AJAX, it never gets to this redirect. You can however use a small code snippet to do this via JS (replacing https://www.yoursite.com):

    
    add_action( 'wp_head', function () { ?>
    	<script>
    	jQuery( function ( $ ) {
    		$('body').on( 'wc_bof_added_to_cart', function ( clickElem, inputRow, Response ) {
    			window.location.href = "https://www.yoursite.com";
    		} );
    	} );
    	</script>
    <?php } );
    

    Hope that helps!

    Thread Starter Claudio

    (@cl4udio)

    Thanks,

    I put the snippet in the “functions.php” file, and it doesn’t work. It remains on the same page after adding it to the cart.

    I copied and pasted everything, I only replaced the URL.

    Plugin Contributor Ewout

    (@pomegranate)

    That’s strange… What’s the URL of your site (or more specifically, the bulk order form)? Are you using caching plugins?

    Thread Starter Claudio

    (@cl4udio)

    The Bulk Form is here: https://formulario.meglob.com/

    I’m not using cache plugins

    Plugin Contributor Ewout

    (@pomegranate)

    Hello Claudio,
    I checked the site and found the culprit: you’re using a very old version of the plugin: 2.2.1 which was released in January 2015. Version 3.0 was quite a big update and that’s what the script I wrote was for. I’m afraid we can’t provide support for that old version, but perhaps you can give the latest version a try?

    Good luck!
    Ewout

    Thread Starter Claudio

    (@cl4udio)

    Hi Ewout,
    Sorry for my late response.

    I’ve tested the PHP function and is worked well with the latest version of the plugin.

    Thanks for that!

    PD: I will go generating another thread about a new issue with the update.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Add to cart custom link’ is closed to new replies.