You are here

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

@inheritdoc

Overrides CartHandlerInterface::addCartLine

File

src/CartHandler.php, line 159

Class

CartHandler
Cart handler.

Namespace

Drupal\mailchimp_ecommerce

Code

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

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