mailchimp / mc-woocommerce

MailChimp for Woocommerce Integration. Syncs all data (subscriber, customers, orders, products) and enables marketing automation with email campaigns, automations, ads, postcards and more.
https://wordpress.org/plugins/mailchimp-for-woocommerce/
GNU General Public License v2.0
82 stars 66 forks source link

Phone sync issue #950

Closed rad0301 closed 1 year ago

rad0301 commented 2 years ago

Hi I am binging up the issue of phone sync once again. As per your previous threads I have switched on the debug and can see the phone number in the log and added the custom code in the functions.php file but somehow still dont see this in Mailchimp. Please find below the code I have added

function custom_user_merge_tags($merge_vars, $user) {
    // Get the WooCommerce customer object
$customer = new WC_Customer($user->ID);

$merge_vars[‘PHONE’] =  $customer->get_billing_phone();

// return the merge tag array to be submitted.
return $merge_vars;
}

add_filter(‘mailchimp_sync_user_mergetags’, ‘custom_user_merge_tags’, 100, 2);
?>

I also tried another code

function mailchimp_custom_order_merge_tags($merge_tags, $order) {
// the phone number can be used from either the shipping address, or the billing address.
//$shipping_phone_number = (string) $order->getShippingAddress()->getPhone();
$billing_phone_number = (string) $order->getBillingAddress()->getPhone();

// this is what I would do – only supply it if the phone number is there.
if (!empty($billing_phone_number)) {
$merge_tags[‘PHONE’] = $billing_phone_number;
}
// return the merge tags to be submitted.
return $merge_tags;
}

add_filter(‘mailchimp_get_ecommerce_merge_tags’, ‘mailchimp_custom_order_merge_tags’, 10, 2);

Somehow both dont work. Any help would be greatly appreciated.

ryanhungate commented 2 years ago

@rad0301 sorry for the delay here, but i need to ask you a fairly obvious question. Have you created a new field in Mailchimp that's named PHONE? What type of field is it?

khungate commented 1 year ago

Hi @rad0301 we're going to close out this ticket for now since it's been a few weeks since we've been in touch. Please let us know if you still need any help and we'll be glad to reopen and troubleshoot further.

rad0301 commented 1 year ago

HI, sorry somehow missed your response. Yes I have created a field in Mailchimp with the merge tag as PHONE, it is a phone type field with format sent to international.

rad0301 commented 1 year ago
Screenshot at Nov 30 10-32-10
rad0301 commented 1 year ago

Any update?

khungate commented 1 year ago

Hi @rad0301, we've updated this post over in the Wordpress forums: https://wordpress.org/support/topic/phone-number-not-syncing-2/. Is this the same question? If so, let's close the forum one out to continue the conversation. Let us know your thoughts on our reply:

We’ve done some testing on our end and by our testing everything works as expected. When you submit things, can you confirm that the billing and shipping phones are present on the order, and the “PHONE” merge tag created in Mailchimp?