Skip to content

Update Merge Tags During Order Submissions

khungate edited this page Jul 25, 2023 · 4 revisions

Welcome to the guide on Updating Merge Tags During Order Submissions in the MailChimp for WooCommerce Integration. This guide will help you understand how to alter the values being submitted during an order process by adding a custom filter.

Overview

Functionality

When an order is being submitted, you can alter the values being submitted by adding a custom filter that will use any values you specify. Please test in a development or staging environment before releasing to production to be sure of the results.

Code Example

Customizing Merge Tags

Here's an example of how to customize merge tags:

/**
 * @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);

In this example, a new merge tag 'WHATEVER' is added with a custom value. You can replace 'WHATEVER' and 'value you want' with your specific merge tag and value.