function mailchimp_ecommerce_update_cart_line in Mailchimp E-Commerce 7
Updates an existing line in a cart in the current Mailchimp store.
Parameters
string $cart_id: The cart ID.
string $line_id: A unique identifier for the order line item.
array $product: Associative array of product information.
- product_id (string) The unique identifier for the product.
- product_variant_id (string) The unique identifier for the variant.
- quantity (int) The quantity of a cart line item.
- price (float) The price of a cart line item.
1 call to mailchimp_ecommerce_update_cart_line()
- mailchimp_ecommerce_commerce_commerce_line_item_update in modules/
mailchimp_ecommerce_commerce/ mailchimp_ecommerce_commerce.module - Implements hook_commerce_line_item_update().
File
- ./
mailchimp_ecommerce.module, line 619 - Mailchimp eCommerce core functionality.
Code
function mailchimp_ecommerce_update_cart_line($cart_id, $line_id, $product) {
try {
$store_id = mailchimp_ecommerce_get_store_id();
if (empty($store_id)) {
throw new Exception('Cannot update a cart line without a store ID.');
}
if (mailchimp_ecommerce_use_queue()) {
mailchimp_ecommerce_create_queue_item([
'op' => 'updateCartLine',
'cart_id' => $cart_id,
'store_id' => $store_id,
'line_id' => $line_id,
'product' => $product,
]);
}
else {
/* @var \Mailchimp\MailchimpEcommerce $mc_ecommerce */
$mc_ecommerce = mailchimp_get_api_object('MailchimpEcommerce');
$mc_ecommerce
->updateCartLine($store_id, $cart_id, $line_id, $product);
}
} catch (Exception $e) {
mailchimp_ecommerce_log_error_message('Unable to update a cart line: ' . $e
->getMessage());
mailchimp_ecommerce_show_error($e
->getMessage());
}
}