You are here

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

@inheritdoc

Overrides CartHandlerInterface::updateCartLine

File

src/CartHandler.php, line 177

Class

CartHandler
Cart handler.

Namespace

Drupal\mailchimp_ecommerce

Code

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

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