Allow messages to show with caching plugins on add to cart.
This commit is contained in:
parent
f7852906c9
commit
edb07efaef
|
@ -169,6 +169,8 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
|
|||
* Tweak - Made no shipping available messages filterable via woocommerce_cart_no_shipping_available_html and woocommerce_no_shipping_available_html.
|
||||
* Tweak - disabled keyboard shortcuts in prettyPhoto.
|
||||
* Tweak - woocommerce_date_format() function.
|
||||
* Tweak - After adding to cart, add 'added_to_cart' to querystring - lets messages show with cache enabled.
|
||||
* Tweak - Similar to above, on failure don't redirect. The POST should exclude from cache.
|
||||
* Fix - Fix orderby title - separated from menu_order.
|
||||
* Other minor fixes and localisation updates.
|
||||
|
||||
|
|
|
@ -298,6 +298,7 @@ function woocommerce_add_to_cart_action( $url = false ) {
|
|||
|
||||
$product_id = apply_filters( 'woocommerce_add_to_cart_product_id', absint( $_REQUEST['add-to-cart'] ) );
|
||||
$was_added_to_cart = false;
|
||||
$added_to_cart = array();
|
||||
$adding_to_cart = get_product( $product_id );
|
||||
$add_to_cart_handler = apply_filters( 'woocommerce_add_to_cart_handler', $adding_to_cart->product_type, $adding_to_cart );
|
||||
|
||||
|
@ -312,8 +313,7 @@ function woocommerce_add_to_cart_action( $url = false ) {
|
|||
// Only allow integer variation ID - if its not set, redirect to the product page
|
||||
if ( empty( $variation_id ) ) {
|
||||
$woocommerce->add_error( __( 'Please choose product options…', 'woocommerce' ) );
|
||||
wp_redirect( get_permalink( $product_id ) );
|
||||
exit;
|
||||
return;
|
||||
}
|
||||
|
||||
$attributes = $adding_to_cart->get_attributes();
|
||||
|
@ -366,12 +366,12 @@ function woocommerce_add_to_cart_action( $url = false ) {
|
|||
if ( $woocommerce->cart->add_to_cart( $product_id, $quantity, $variation_id, $variations ) ) {
|
||||
woocommerce_add_to_cart_message( $product_id );
|
||||
$was_added_to_cart = true;
|
||||
$added_to_cart[] = $product_id;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$woocommerce->add_error( __( 'Please choose product options…', 'woocommerce' ) );
|
||||
wp_redirect( get_permalink( $product_id ) );
|
||||
exit;
|
||||
return;
|
||||
}
|
||||
|
||||
// Grouped Products
|
||||
|
@ -380,7 +380,6 @@ function woocommerce_add_to_cart_action( $url = false ) {
|
|||
if ( ! empty( $_REQUEST['quantity'] ) && is_array( $_REQUEST['quantity'] ) ) {
|
||||
|
||||
$quantity_set = false;
|
||||
$added_to_cart = array();
|
||||
|
||||
foreach ( $_REQUEST['quantity'] as $item => $quantity ) {
|
||||
if ( $quantity <= 0 )
|
||||
|
@ -405,16 +404,14 @@ function woocommerce_add_to_cart_action( $url = false ) {
|
|||
|
||||
if ( ! $was_added_to_cart && ! $quantity_set ) {
|
||||
$woocommerce->add_error( __( 'Please choose the quantity of items you wish to add to your cart…', 'woocommerce' ) );
|
||||
wp_redirect( get_permalink( $product_id ) );
|
||||
exit;
|
||||
return;
|
||||
}
|
||||
|
||||
} elseif ( $product_id ) {
|
||||
|
||||
/* Link on product archives */
|
||||
$woocommerce->add_error( __( 'Please choose a product to add to your cart…', 'woocommerce' ) );
|
||||
wp_redirect( get_permalink( $product_id ) );
|
||||
exit;
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
@ -431,6 +428,7 @@ function woocommerce_add_to_cart_action( $url = false ) {
|
|||
if ( $woocommerce->cart->add_to_cart( $product_id, $quantity ) ) {
|
||||
woocommerce_add_to_cart_message( $product_id );
|
||||
$was_added_to_cart = true;
|
||||
$added_to_cart[] = $product_id;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -455,7 +453,7 @@ function woocommerce_add_to_cart_action( $url = false ) {
|
|||
|
||||
// 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() ) );
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue