Adding birthday field to Mailchimp
-
Hi!
I’m trying to add a custom birthday field to my checkout page from Woocommerce, and at the same time I’m trying to add this data into Mailchimp so I can make a birthday automation.
I did manage to show an extra field in my checkout page where I can add my birthday. However, when placing an order I find the label ‘Geboortedatum’ (dutch for Birthday) in my order information in Woocommerce, however, only the label and not the birthday itself. Besides that I don’t see any information back in Mailchimp audience contact (I did synchronize information about the order, so I see my order and order amount etc in Mailchimp, just nothing about the birthday).
This is the code I used, I have no idea what is going wrong.. Hope someone can help me!// Hook in add date of birth in checkout field add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' ); // Our hooked in function – $fields is passed via the filter! function custom_override_checkout_fields( $fields ) { $fields['billing']['billing_date_of_birth'] = array( 'type' => 'date', 'label' => __('Geboortedatum'.'<br>'.'<small>Laat je verassen op je verjaardag!</small>', 'woocommerce'), 'placeholder' => _x('Geboortedatum', 'placeholder', 'woocommerce'), 'required' => false, 'class' => array('form-row-wide'), 'clear' => true ); return $fields; } /** * Display field value on the order edit page */ add_action( 'woocommerce_admin_order_data_after_billing_address', 'my_custom_checkout_field_display_admin_order_meta', 10, 1 ); function my_custom_checkout_field_display_admin_order_meta($order){ echo '<p><strong>'.__('Geboortedatum').':</strong> ' . get_post_meta( $order->get_id(), 'date_of_birth', true ) . '</p>'; } function mailchimp_custom_order_merge_tags($merge_tags, $order) { $birthday = get_post_meta( $order->getId(), 'date_of_birth', true ); /// add whatever you want to the merge tags $merge_tags['MMERGE3'] = $birthday; return $merge_tags; } add_filter('mailchimp_get_ecommerce_merge_tags', 'mailchimp_custom_order_merge_tags', 10, 2);
- The topic ‘Adding birthday field to Mailchimp’ is closed to new replies.