Sending Woocommerce Cart Items As Merge Tags
-
I am attempting to modify the provided code that sends the merge tags from Woocommerce to Mailchimp.
/** * @param array $merge_tags * @param MailChimp_WooCommerce_Order $order * @return array */ function mailchimp_custom_order_merge_tags($merge_tags, $order) { /// add whatever you want to the merge tags $merge_tags['WHATEVER'] = 'value you want'; return $merge_tags; } add_filter('mailchimp_get_ecommerce_merge_tags', 'mailchimp_custom_order_merge_tags', 10, 2);
I can get this default version to work but whenever I make modifications such as to send the product name to a merge tag, it does not send.
I have tested a lot of variations, but this is the version that I feel should be working:/** * @param array $merge_tags * @param MailChimp_WooCommerce_Order $order * @return array */ function mailchimp_custom_order_merge_tags($merge_tags, $order) { // Retrieve the order items $items = $order->get_items(); // Check if there are any items if (!empty($items)) { // Get the first item $first_item = reset($items); // Retrieve the product title $product_title = $first_item->get_name(); // Add the product title as a merge tag $merge_tags['COURSENAME'] = $product_title; } return $merge_tags; } add_filter('mailchimp_get_ecommerce_merge_tags', 'mailchimp_custom_order_merge_tags', 10, 2);
Can I please get a second eyeball on this to figure out what it is missing?
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Sending Woocommerce Cart Items As Merge Tags’ is closed to new replies.