From b38ef8efcd32694f9a7962c7435e5fd238341584 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Fri, 14 Jun 2013 12:48:41 +0100 Subject: [PATCH] No add to cart redirect, and use POST for add-to-cart Closes #3200 --- templates/single-product/add-to-cart/grouped.php | 5 +++-- templates/single-product/add-to-cart/simple.php | 8 ++++---- templates/single-product/add-to-cart/variable.php | 7 +++++-- woocommerce-functions.php | 13 +++---------- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/templates/single-product/add-to-cart/grouped.php b/templates/single-product/add-to-cart/grouped.php index c92c7e3d565..c516b06329e 100644 --- a/templates/single-product/add-to-cart/grouped.php +++ b/templates/single-product/add-to-cart/grouped.php @@ -30,7 +30,7 @@ foreach ( $product->get_children() as $child_id ) { -
+ @@ -70,6 +70,8 @@ foreach ( $product->get_children() as $child_id ) {
+ + @@ -79,7 +81,6 @@ foreach ( $product->get_children() as $child_id ) { -
\ No newline at end of file diff --git a/templates/single-product/add-to-cart/simple.php b/templates/single-product/add-to-cart/simple.php index eb1252af331..88599149fe3 100644 --- a/templates/single-product/add-to-cart/simple.php +++ b/templates/single-product/add-to-cart/simple.php @@ -27,8 +27,7 @@ if ( ! $product->is_purchasable() ) return; -
- + is_purchasable() ) return; ) ); ?> + + - - +
diff --git a/templates/single-product/add-to-cart/variable.php b/templates/single-product/add-to-cart/variable.php index f75aa074c50..e8675b7c264 100644 --- a/templates/single-product/add-to-cart/variable.php +++ b/templates/single-product/add-to-cart/variable.php @@ -14,7 +14,7 @@ global $woocommerce, $product, $post; -
+ $options ) : $loop++; ?> @@ -83,7 +83,10 @@ global $woocommerce, $product, $post; -
+
+ + +
diff --git a/woocommerce-functions.php b/woocommerce-functions.php index c865c426276..272d11d731f 100644 --- a/woocommerce-functions.php +++ b/woocommerce-functions.php @@ -282,7 +282,6 @@ function woocommerce_update_cart_action() { * @return void */ function woocommerce_add_to_cart_action( $url = false ) { - if ( empty( $_REQUEST['add-to-cart'] ) || ! is_numeric( $_REQUEST['add-to-cart'] ) ) return; @@ -426,8 +425,8 @@ function woocommerce_add_to_cart_action( $url = false ) { } - // If we added the product to the cart we can now do a redirect, otherwise just continue loading the page to show errors - if ( $was_added_to_cart ) { + // If we added the product to the cart we can now optionally do a redirect. + if ( $was_added_to_cart && wc_error_count() == 0 ) { $url = apply_filters( 'add_to_cart_redirect', $url ); @@ -438,17 +437,11 @@ function woocommerce_add_to_cart_action( $url = false ) { } // Redirect to cart option - elseif ( get_option('woocommerce_cart_redirect_after_add') == 'yes' && wc_error_count() == 0 ) { + elseif ( get_option('woocommerce_cart_redirect_after_add') == 'yes' ) { wp_safe_redirect( $woocommerce->cart->get_cart_url() ); exit; } - // Redirect to page without querystring args - elseif ( wp_get_referer() ) { - wp_safe_redirect( add_query_arg( 'added-to-cart', implode( ',', $added_to_cart ), remove_query_arg( array( 'add-to-cart', 'quantity', 'product_id' ), wp_get_referer() ) ) ); - exit; - } - } }