You are here

public function CartEventSubscriber::cartItemRemove in Mailchimp E-Commerce 8

Respond to event fired after removing a cart item.

File

modules/mailchimp_ecommerce_commerce/src/EventSubscriber/CartEventSubscriber.php, line 127

Class

CartEventSubscriber
Event Subscriber for Commerce Carts.

Namespace

Drupal\mailchimp_ecommerce_commerce\EventSubscriber

Code

public function cartItemRemove(CartOrderItemRemoveEvent $event) {

  /** @var \Drupal\commerce_order\Entity\Order $order */
  $order = $event
    ->getCart();
  if (empty($order
    ->getItems())) {
    $this->cart_handler
      ->deleteCart($order
      ->id());
  }
  else {
    $this->cart_handler
      ->deleteCartLine($order
      ->id(), $event
      ->getOrderItem()
      ->id());
  }
}