After update from 7.x-1.0-alpha6 to 7.x-1.0-beta1 can add the same product to cart only once.
How to reproduce:
- Load page with multiple products (with quantity input near every "Add to cart" button).
- Press "Add to cart" button.
- AJAX request processed: product successfully added to cart, cart block was updated.
- Press "Add to cart" button for the same product.
- AJAX request processed: cart block updated but quantity of added product is the same (not updated).
- After page reload product quantity in cart block is the same as after first "Add to cart" button press.
This behavior related to code change added on last version:
diff --git a/commerce_ajax_cart.module b/commerce_ajax_cart.module
index 45f5e8a..1ce0b53 100644
--- a/commerce_ajax_cart.module
+++ b/commerce_ajax_cart.module
@@ -130,11 +130,6 @@ function commerce_ajax_cart_callback($form, &$form_state){
global $user;
unset($form['quantity']['#value']);
- // Clear form and form state cache
- $form_state = form_state_defaults();
- $form_build_id = $_POST['form_build_id'];
- form_set_cache($form_build_id, $form, $form_state);
-
$commands = array();
$commands[] = array('command' => 'commerce_ajax_cart_update') ;
$commands[] = ajax_command_prepend('#block-system-main', theme('status_messages'));
After return back code:
// Clear form and form state cache
$form_state = form_state_defaults();
$form_build_id = $_POST['form_build_id'];
form_set_cache($form_build_id, $form, $form_state);
Module works correct and I can add to cart the same product multiple times.
Comments
Comment #1
erik seifert commentedThe problem is a collision with ajax call product attributes. I need an other solution.
@see #2159043: Add to cart form disappears after adding to cart then selecting product attributes
Comment #2
erik seifert commentedFound a solution.
Checkout beta2 or latest dev
Comment #3
antonnaviOn 7.x-1.0-beta2 this issue was fixed. Works fine, for me.
Comment #4
antonnavi