@lukoie,
You should retrieve those checkout those fields off the WooCommerce order instead of through the $_POST variable.
Like this: $birthday = get_post_meta( $order_id, 'birthday', true );
Adjust the line above to use the field names you are using to save the checkout fields.
[ Signature deleted ]
Hello,
I have the same problem i don’t see the field ‘birthday’ in order to get birthday date (with date picker)
Here my code:
// Make birthday a date picker mm/dd field
function ss_wc_add_checkout_field_datepicker() {
if ( is_checkout() ) {
$js = 'jQuery( "#birthday" ).css("width","125px").datepicker({ changeMonth: true, changeYear: true, yearRange:"-100:+0", dateFormat: "mm/dd" });';
// Check if WC 2.1+
if ( defined( 'WC_VERSION' ) && WC_VERSION ) {
wc_enqueue_js( $js );
} else {
global $woocommerce;
$woocommerce->add_inline_js( $js );
}
}
}
add_filter( 'wp_footer' , 'ss_wc_add_checkout_field_datepicker' );
// Save the birthday field with the order
function ss_wc_save_birthday_field( $order_id ) {
$birthday = isset( $_POST['birthday'] ) ? $_POST['birthday'] : null;
update_post_meta( $order_id, 'birthday', $birthday );
}
add_action( 'woocommerce_checkout_update_order_meta', 'ss_wc_save_birthday_field' );
// tie into the WooCommerce MailChimp 'ss_wc_mailchimp_subscribe_merge_tags' action filter to add the MailChimp merge tag for Birthday
function ss_wc_send_birthday_field_to_mailchimp( $merge_tags, $order_id, $email ) {
// retrieve the birthday from the order meta/custom fields
$birthday = get_post_meta( $order_id, 'birthday', true );
// Add 'BIRTHDAY' merge variable to MailChimp call (change 'BIRTHDAY' to whatever your merge variable is called in MailChimp)
$merge_tags['BIRTHDAY'] = $birthday;
return $merge_tags;
}
add_filter( 'ss_wc_mailchimp_subscribe_merge_tags' , 'ss_wc_send_birthday_field_to_mailchimp', 10 , 3 );
Please help.