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:

  1. Load page with multiple products (with quantity input near every "Add to cart" button).
  2. Press "Add to cart" button.
  3. AJAX request processed: product successfully added to cart, cart block was updated.
  4. Press "Add to cart" button for the same product.
  5. AJAX request processed: cart block updated but quantity of added product is the same (not updated).
  6. 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

erik seifert’s picture

The 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

erik seifert’s picture

Found a solution.

Checkout beta2 or latest dev

antonnavi’s picture

On 7.x-1.0-beta2 this issue was fixed. Works fine, for me.

antonnavi’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.