Due to the fact that we use custom checkouts on our WooCommerce store, Mailchimp official plugin for Woocommerce, is not picking up some of the details on the orders.
The one that we need to pass from each order to Mailchimp is the 2 letter country code, but for some reason i cant make it work.
On one of my tests, i "make it work" as it passed the 2 letter country code, but not the one for the order, but the store one, so I know most of my code is working, but i cant figure out how to make it work as intended:
One is for subscribed people:
function custom_mailchimp_sync_user_mergetags($merge_fields, $user) {
/// add anything you would like to this array - and return it
$merge_fields['COUNTRYCOD'] = $order->get_billing_country();
mailchimp_log('trace', 'custom_fields', $merge_fields);
return $merge_fields;
}
add_filter('mailchimp_sync_user_mergetags', 'custom_mailchimp_sync_user_mergetags', 10, 2);
And the other one is for non subscribed people:
function custom_mailchimp_sync_user_mergetags_no_sub($merge_fields, $user) {
/// add anything you would like to this array - and return it
$merge_fields['COUNTRYCOD'] = $order->get_billing_country();
mailchimp_log('trace', 'custom_fields', $merge_fields);
return $merge_fields;
}
add_filter('mailchimp_get_ecommerce_merge_tags', 'custom_mailchimp_sync_user_mergetags_no_sub', 10, 2);
I would appreciate any help