Skip to content
Browse files

After successful add to cart, if there are no other redirects, redire…

…ct to referer.
  • Loading branch information...
1 parent 9d2b9be commit 12a248563715eccb1ca916cf9b35d841aceae4ca @mikejolley mikejolley committed
Showing with 8 additions and 1 deletion.
  1. +1 −0 readme.txt
  2. +7 −1 woocommerce-functions.php
View
1 readme.txt
@@ -153,6 +153,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
= 1.7 =
* Feature - Added sales by category report
* Tweak - If a PayPal prefix is changed, IPN requests break for all existing orders - fixed. new woocommerce_get_order_id_by_order_key() function added. Thanks Brent.
+* Tweak - On add to cart success, redirect back.
* Fix - Added more error messages for coupons.
= 1.6.5.1 - 25/08/2012 =
View
8 woocommerce-functions.php
@@ -370,10 +370,16 @@ function woocommerce_add_to_cart_action( $url = false ) {
}
// Redirect to cart option
- elseif (get_option('woocommerce_cart_redirect_after_add')=='yes' && $woocommerce->error_count() == 0) {
+ elseif ( get_option('woocommerce_cart_redirect_after_add') == 'yes' && $woocommerce->error_count() == 0 ) {
wp_safe_redirect( $woocommerce->cart->get_cart_url() );
exit;
}
+
+ // Redirect to page without querystring args
+ elseif ( wp_get_referer() ) {
+ wp_safe_redirect( remove_query_arg( array( 'add-to-cart', 'quantity', 'product_id' ), wp_get_referer() ) );
+ exit;
+ }
}

1 comment on commit 12a2485

@Pala4833

Hi Mike. Is there a similar fix for WooComm 2.2.6?

Please sign in to comment.
Something went wrong with that request. Please try again.