OrderItemSubscriber throws OrderVersionMismatchException when adding products to the cart

Created on 4 December 2024, 22 days ago

Problem/Motivation

OrderItemSubscriber::onItemInsert performs a save() call on the parent order to assign the order item not only when creating a new order item from the UI, but also when adding a single product to the cart.

That extra call to save() leads to the OrderVersionMismatchException when the item is added to the cart by CartManager::addOrderItem

Steps to reproduce

  1. Enable commerce_oder_item_ui module
  2. Add any existing product to the cart form the product detail page
  3. Check Druapl logs and con firm that Exception like this is thrown: Drupal\commerce_order\Exception\OrderVersionMismatchException: Attempted to save order XXX with version 1. Current version is 2

Proposed resolution

Refactor the way this module works to avoid this exception

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇪🇸Spain plopesc Valladolid

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024