You are here

public function CartHandler::deleteCart in Mailchimp E-Commerce 8

@inheritdoc

Overrides CartHandlerInterface::deleteCart

File

src/CartHandler.php, line 137

Class

CartHandler
Cart handler.

Namespace

Drupal\mailchimp_ecommerce

Code

public function deleteCart($cart_id) {
  try {
    $store_id = $this->helper
      ->getStoreId();
    if (empty($store_id)) {
      throw new \Exception('Cannot delete a cart without a store ID.');
    }
    $this->mcEcommerce
      ->deleteCart($store_id, $cart_id);
  } catch (\Exception $e) {
    if ($e
      ->getCode() == 404) {

      // Cart doesn't exist; no need to log an error.
    }
    else {

      //mailchimp_ecommerce_log_error_message('Unable to delete a cart: ' . $e->getMessage());
      $this->messenger
        ->addError($e
        ->getMessage());
    }
  }
}