Notice when ordering again
-
I have found a little bug which happens in the following situation:
– Bundle product with multiple optional childs
– Add to cart with optional A, B and C
– Add to cart with optional A, D and E
– Reorder through my account
– A notice “1 item from your previous order is currently unavailable and could not be added to your cart” is shown, however all items are added to the cartI have done some debugging and found what is causing this issue. Within /woocommerce/includes/class-wc-cart-session.php in the function ‘populate_cart_from_order’ they generate a cart ID:
$cart_id = WC()->cart->generate_cart_id( $product_id, $variation_id, $variations, $cart_item_data );
In my situation, the cart ID for optional A (in both order lines) is exactly the same, because the $cart_item_data is exactly the same. WooCommerce then counts the ‘new’ $cart array, filled using the $cart_id and compares this to the original $order_items.
The cart_item_data contains two fields:
woosb_order_again: yes
woosb_parent_id: 123Because they both have the same parent product it’s not unique in this case. It would be better to add the woosb_parent_key to the order items, which is also used within the cart while ordering.
The topic ‘Notice when ordering again’ is closed to new replies.