You are here

public function CartSubscriber::onCartEntityAdd in Commerce Shipping 8.2

Force repack/rates recalculation when an order item is added to the cart.

Parameters

\Drupal\commerce_cart\Event\CartEntityAddEvent $event: The cart event.

File

src/EventSubscriber/CartSubscriber.php, line 71

Class

CartSubscriber

Namespace

Drupal\commerce_shipping\EventSubscriber

Code

public function onCartEntityAdd(CartEntityAddEvent $event) {
  $cart = $event
    ->getCart();
  if ($this->shippingOrderManager
    ->hasShipments($cart)) {
    $cart
      ->setData(ShippingOrderManagerInterface::FORCE_REFRESH, TRUE);
  }
}