function mailchimp_ecommerce_delete_cart_line in Mailchimp E-Commerce 7
Deletes a 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.
1 call to mailchimp_ecommerce_delete_cart_line()
- mailchimp_ecommerce_commerce_commerce_cart_product_remove in modules/
mailchimp_ecommerce_commerce/ mailchimp_ecommerce_commerce.module - Implements hook_commerce_cart_product_remove().
File
- ./
mailchimp_ecommerce.module, line 655 - Mailchimp eCommerce core functionality.
Code
function mailchimp_ecommerce_delete_cart_line($cart_id, $line_id) {
try {
$store_id = mailchimp_ecommerce_get_store_id();
if (empty($store_id)) {
throw new Exception('Cannot delete a cart line without a store ID.');
}
if (mailchimp_ecommerce_use_queue()) {
mailchimp_ecommerce_create_queue_item([
'op' => 'deleteCartLine',
'cart_id' => $cart_id,
'store_id' => $store_id,
'line_id' => $line_id,
]);
}
else {
/* @var \Mailchimp\MailchimpEcommerce $mc_ecommerce */
$mc_ecommerce = mailchimp_get_api_object('MailchimpEcommerce');
$mc_ecommerce
->deleteCartLine($store_id, $cart_id, $line_id);
}
} catch (Exception $e) {
mailchimp_ecommerce_log_error_message('Unable to delete a cart line: ' . $e
->getMessage());
mailchimp_ecommerce_show_error($e
->getMessage());
}
}