Commit 41cd363f authored by Robin van Sloten's avatar Robin van Sloten Committed by Jonathan Sacksick
Browse files

Issue #3083384 by Neograph734, Renrhaf, jungle, jsacksick, bojanz: Checkout...

Issue #3083384 by Neograph734, Renrhaf, jungle, jsacksick, bojanz: Checkout flows should be resolved again after the cart/order has changed.
parent cea8422d
Loading
Loading
Loading
Loading
+16 −1
Changes for modules/cart/src/CartManager.php: 16 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ class CartManager implements CartManagerInterface {
    $cart->setAdjustments([]);

    $this->eventDispatcher->dispatch(new CartEmptyEvent($cart, $order_items), CartEvents::CART_EMPTY);
    $this->resetCheckoutFlow($cart);
    $this->resetCheckoutStep($cart);
    if ($save_cart) {
      $cart->save();
@@ -126,7 +127,7 @@ class CartManager implements CartManagerInterface {
    }
    $event = new CartOrderItemAddEvent($cart, $quantity, $saved_order_item);
    $this->eventDispatcher->dispatch($event, CartEvents::CART_ORDER_ITEM_ADD);

    $this->resetCheckoutFlow($cart);
    $this->resetCheckoutStep($cart);
    if ($save_cart) {
      $cart->save();
@@ -144,6 +145,7 @@ class CartManager implements CartManagerInterface {
    $order_item->save();
    $event = new CartOrderItemUpdateEvent($cart, $order_item, $original_order_item);
    $this->eventDispatcher->dispatch($event, CartEvents::CART_ORDER_ITEM_UPDATE);
    $this->resetCheckoutFlow($cart);
    $this->resetCheckoutStep($cart);
    if ($save_cart) {
      $cart->save();
@@ -165,12 +167,25 @@ class CartManager implements CartManagerInterface {
      return;
    }

    $this->resetCheckoutFlow($cart);
    $this->resetCheckoutStep($cart);
    if ($save_cart) {
      $cart->save();
    }
  }

  /**
   * Resets the checkout flow.
   *
   * @param \Drupal\commerce_order\Entity\OrderInterface $cart
   *   The cart order.
   */
  protected function resetCheckoutFlow(OrderInterface $cart) {
    if ($cart->hasField('checkout_flow')) {
      $cart->set('checkout_flow', '');
    }
  }

  /**
   * Resets the checkout step.
   *