Variations maintain selections after adding to cart. Closes #926.

This commit is contained in:
Mike Jolley 2012-06-10 13:53:26 +01:00
parent c6d6fd7901
commit 06398f4a5b
4 changed files with 7 additions and 3 deletions

View File

@ -654,7 +654,7 @@ class WC_Cart {
$woocommerce->add_error( __('You cannot add that product to the cart since the product is out of stock.', 'woocommerce') ); $woocommerce->add_error( __('You cannot add that product to the cart since the product is out of stock.', 'woocommerce') );
return false; return false;
} }
// Downloadable/virtual qty check // Downloadable/virtual qty check
if ( $product_data->is_sold_individually() ) { if ( $product_data->is_sold_individually() ) {
$in_cart_quantity = ( $cart_item_key ) ? $this->cart_contents[$cart_item_key]['quantity'] + $quantity : $quantity; $in_cart_quantity = ( $cart_item_key ) ? $this->cart_contents[$cart_item_key]['quantity'] + $quantity : $quantity;

View File

@ -154,6 +154,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
* Feature - Menu count for orders requiring admin action * Feature - Menu count for orders requiring admin action
* Feature - 'supports' function for gateways. * Feature - 'supports' function for gateways.
* Feature - Ajax powered coupon form on checkout. * Feature - Ajax powered coupon form on checkout.
* Tweak - Variations maintain selections after adding to cart.
* Tweak - Improvements to the order tracking code, including better error messages * Tweak - Improvements to the order tracking code, including better error messages
* Tweak - EU states for tax * Tweak - EU states for tax
* Tweak - woocommerce_shipping_chosen_method hook * Tweak - woocommerce_shipping_chosen_method hook

View File

@ -21,7 +21,10 @@ global $woocommerce, $product, $post;
<option value=""><?php echo __('Choose an option', 'woocommerce') ?>&hellip;</option> <option value=""><?php echo __('Choose an option', 'woocommerce') ?>&hellip;</option>
<?php if(is_array($options)) : ?> <?php if(is_array($options)) : ?>
<?php <?php
$selected_value = (isset($selected_attributes[sanitize_title($name)])) ? $selected_attributes[sanitize_title($name)] : ''; if ( empty( $_POST ) )
$selected_value = ( isset( $selected_attributes[ sanitize_title( $name ) ] ) ) ? $selected_attributes[ sanitize_title( $name ) ] : '';
else
$selected_value = isset( $_POST[ 'attribute_' . sanitize_title( $name ) ] ) ? $_POST[ 'attribute_' . sanitize_title( $name ) ] : '';
// Get terms if this is a taxonomy - ordered // Get terms if this is a taxonomy - ordered
if (taxonomy_exists(sanitize_title($name))) : if (taxonomy_exists(sanitize_title($name))) :

View File

@ -388,7 +388,7 @@ 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 we added the product to the cart we can now do a redirect, otherwise just continue loading the page to show errors
if ($added_to_cart) { if ($added_to_cart) {
$url = apply_filters('add_to_cart_redirect', $url); $url = apply_filters( 'add_to_cart_redirect', $url );
// If has custom URL redirect there // If has custom URL redirect there
if ( $url ) { if ( $url ) {