Reputation: 69
not sure if this is the best option but I would like not to leave the page that the add to cart button is on. In order for more items to be added, I would like to add to cart and stay on the same page. I run into problems with variable products when I add to cart.
I have added some code to the functions php to send the person back to the referring site not sure if this is the best way to do this.
//redirect to the same page
/**
* Set a custom add to cart URL to redirect to
* @return string
*/
function custom_add_to_cart_redirect() {
return (wp_get_referer() );
}
add_filter( 'woocommerce_add_to_cart_redirect', 'custom_add_to_cart_redirect' );
expected to stay on the same page when adding to cart button is clicked with simple and variable products. I also would like to have the notice shown on the same page.
Upvotes: 0
Views: 1453
Reputation: 84
Try this
$referer = $_SERVER['HTTP_REFERER'];
header("Location: $referer");
Upvotes: 1