WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
Add to Cart and Redirect to Previous Page (2 posts)

  1. ianmcabee
    Member
    Posted 1 year ago #

    Hello,

    I want to create a filter where the user is redirected to the previous page they were on (product catalog) after adding a product to their cart in an individual product page.

    Any help is greatly appreciated!

    Thanks,
    Ian

    http://wordpress.org/extend/plugins/woocommerce/

  2. ianmcabee
    Member
    Posted 1 year ago #

    // Redirect user to previous page after adding to basket
    function custom_add_to_cart_redirect() {
    	$url = htmlspecialchars($_SERVER['HTTP_REFERER']);
        return $url;
    }
    add_filter('add_to_cart_redirect', 'custom_add_to_cart_redirect');

    Seems to work for removing the add to cart url but I am still on the same page. Any way I can go back two pages?

    Thanks,
    Ian

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic