function mailchimp_ecommerce_update_cart in Mailchimp E-Commerce 7
Updates an existing cart in the current Mailchimp store.
Parameters
string $cart_id: The cart ID.
array $customer: Associative array of customer information.
- id (string): A unique identifier for the customer.
array $cart: Associative array of cart information.
- currency_code (string): The three-letter ISO 4217 currency code.
- order_total (float): The total for the order.
- lines (array): An array of the order's line items.
See also
http://developer.mailchimp.com/documentation/mailchimp/reference/ecommer...
4 calls to mailchimp_ecommerce_update_cart()
- mailchimp_ecommerce_commerce_commerce_customer_profile_insert in modules/
mailchimp_ecommerce_commerce/ mailchimp_ecommerce_commerce.module - Implements hook_commerce_customer_profile_insert().
- mailchimp_ecommerce_ubercart_batch_add_orders in modules/
mailchimp_ecommerce_ubercart/ mailchimp_ecommerce_ubercart.module - Batch callback used to add orders to Mailchimp.
- mailchimp_ecommerce_ubercart_uc_order in modules/
mailchimp_ecommerce_ubercart/ mailchimp_ecommerce_ubercart.module - Implements hook_uc_order().
- _mailchimp_ecommerce_commerce_send_cart in modules/
mailchimp_ecommerce_commerce/ mailchimp_ecommerce_commerce.module - Private function to send cart data to Mailchimp.
File
- ./
mailchimp_ecommerce.module, line 482 - Mailchimp eCommerce core functionality.
Code
function mailchimp_ecommerce_update_cart($cart_id, array $customer, array $cart) {
try {
$store_id = mailchimp_ecommerce_get_store_id();
if (empty($store_id)) {
throw new Exception('Cannot update a cart without a store ID.');
}
// Do nothing with no email.
if (!$customer['email_address']) {
return;
}
if (mailchimp_ecommerce_use_queue()) {
mailchimp_ecommerce_create_queue_item([
'op' => 'updateCart',
'cart_id' => $cart_id,
'store_id' => $store_id,
'customer' => $customer,
'cart' => $cart,
]);
}
else {
/* @var \Mailchimp\MailchimpEcommerce $mc_ecommerce */
$mc_ecommerce = mailchimp_get_api_object('MailchimpEcommerce');
$list_id = mailchimp_ecommerce_get_list_id();
// Pull member information to get member status.
$memberinfo = mailchimp_get_memberinfo($list_id, $customer['email_address'], TRUE);
$customer['opt_in_status'] = isset($memberinfo->status) && $memberinfo->status == 'subscribed' ? TRUE : FALSE;
$parameters = [
'customer' => (object) $customer,
];
$parameters += $cart;
$mc_ecommerce
->updateCart($store_id, $cart_id, $parameters);
}
} catch (Exception $e) {
mailchimp_ecommerce_log_error_message('Unable to update a cart: ' . $e
->getMessage());
mailchimp_ecommerce_show_error($e
->getMessage());
}
}