Skip to content

Commit 6602c62

Browse files
mglamanbojanz
authored andcommitted
Issue #2807567 by mglaman: Checkout fails when Editor module enabled (#513)
1 parent 9d5186e commit 6602c62

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

modules/cart/commerce_cart.module

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ function commerce_cart_commerce_order_presave(OrderInterface $order) {
112112
$from_states = $place_transition->getFromStates();
113113
$to_state = $place_transition->getToState()->getId();
114114
if (in_array($order->original->state->value, array_keys($from_states)) && $order->state->value == $to_state) {
115-
\Drupal::service('commerce_cart.cart_provider')->finalizeCart($order);
115+
\Drupal::service('commerce_cart.cart_provider')->finalizeCart($order, FALSE);
116116
}
117117
}
118118
}

modules/cart/src/CartProvider.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,11 @@ public function createCart($order_type, StoreInterface $store, AccountInterface
107107
/**
108108
* {@inheritdoc}
109109
*/
110-
public function finalizeCart(OrderInterface $cart) {
110+
public function finalizeCart(OrderInterface $cart, $save_cart = TRUE) {
111111
$cart->cart = FALSE;
112-
$cart->save();
112+
if ($save_cart) {
113+
$cart->save();
114+
}
113115
// Remove the cart order from the internal cache, if present.
114116
unset($this->cartData[$cart->getOwnerId()][$cart->id()]);
115117
}

modules/cart/src/CartProviderInterface.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ public function createCart($order_type, StoreInterface $store, AccountInterface
3838
*
3939
* @param \Drupal\commerce_order\Entity\OrderInterface $cart
4040
* The cart order.
41+
* @param bool $save_cart
42+
* Whether to immediately save the cart or not.
4143
*/
42-
public function finalizeCart(OrderInterface $cart);
44+
public function finalizeCart(OrderInterface $cart, $save_cart = TRUE);
4345

4446
/**
4547
* Gets the cart order for the given store and user.

modules/checkout/tests/src/Functional/CheckoutOrderTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ class CheckoutOrderTest extends CommerceBrowserTestBase {
4242
'entity', 'views', 'address', 'profile', 'commerce', 'inline_entity_form',
4343
'commerce_price', 'commerce_store', 'commerce_product', 'commerce_cart',
4444
'commerce_checkout', 'commerce_order', 'views_ui',
45+
// @see https://www.drupal.org/node/2807567
46+
'editor',
4547
];
4648

4749
/**

0 commit comments

Comments
 (0)