I created a cart and then ran the cancel transition. When I went to the site and added a new product, I noticed a quantity of 2. The cart provider returned the cancelled cart acting as if it was valid.

CommentFileSizeAuthor
#3 cancelled_orders_that-2833780-3.patch10.59 KBmglaman

Comments

mglaman created an issue. See original summary.

bojanz’s picture

CartProvider needs to check for both the cart boolean and the "draft" state to be sure.

We also need to expand commerce_cart_commerce_order_presave(), it currently does the right thing when the order is placed, but doesn't account for cancelled orders (which also need the cart removed).

mglaman’s picture

Status: Active » Needs review
StatusFileSize
new10.59 KB

https://github.com/drupalcommerce/commerce/pull/608

The ::finalizeCart method does exactly what I need it to do. Just feels weird calling it on cancel due to naming.

  • bojanz committed 8f1e829 on 8.x-2.x authored by mglaman
    Issue #2833780 by mglaman, bojanz: Cancelled orders that are carts keep...
bojanz’s picture

Status: Needs review » Fixed

Committed the final version of this.

Includes mglaman's test improvements (CartManagerTestTrait), my addition of the missing CartProvider::clearCaches() (every service with a static cache needs a method to clear it), as well as the extended cart validation and test coverage.

We tried to add a cancelCart() method as a parallel to finalizeCart() but it didn't make much sense because in most cases the cart isn't cancelled by the cart owner, but by another user.

Status: Fixed » Closed (fixed)

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