After successful add to cart, if there are no other redirects, redirect to referer.

This commit is contained in:
Mike Jolley 2012-08-31 10:05:28 +01:00
parent 9d2b9be190
commit 12a2485637
2 changed files with 8 additions and 1 deletions

View File

@ -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 File

@ -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;
}
}