• Resolved mikey_mms

    (@mikey_mms)


    Hi there,

    I’m using Mailchimp for WP Premium and the woocommerce Integration.
    There is a field date (birth date) at the checkout, which I’m integrating using :

    add_filter( ‘mc4wp_integration_woocommerce_data’, function( $data ) {
    $data[‘BIRTHDATE’] = sanitize_text_field( $_POST[‘birthdate’] );
    return $data;
    });

    The date format is in datepicker field is dd/mm/yyyy (also the format of the mailchimp mergetag), but Mailchimp for WP doesn’t seem to recognize it and populate with yyyy/mm/dd instead (the report log item shows: DATE OF BIRTH: 1970-01-01 ). No errors are displayed though in the Debug Log though.

    Thank you very much in advance for you help!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Lap

    (@lapzor)

    Hi,

    Since a link to your form is missing from the post I can’t say for sure, but I assume you are using the HTML5 date picker? It will show the date in whatever date format is set in your local browser, and it will always send the date as yyyy/mm/dd.

    I suggest you use PHP to convert the date in the filter code. Something like this (untested):

    add_filter( ‘mc4wp_integration_woocommerce_data’, function( $data ) {
    $originalDate = sanitize_text_field( $_POST[‘birthdate’] );
    $newDate = date(“d-m-Y”, strtotime($originalDate));
    $data[‘BIRTHDATE’] = $newDate;
    return $data;
    });

    Since you are Premium user please contact Premium support if you need more help so we can give you Priority support.
    https://wordpress.org/support/topic/sticky-premium-users-please-read-this/

    Hope that helps!

    Thread Starter mikey_mms

    (@mikey_mms)

    Hi there,

    It worked using your code and the Y/m/d format (format always sent) instead of the d-m-Y format.

    Thank you very much for your help !

    Plugin Contributor Lap

    (@lapzor)

    Thanks for letting us know!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Date Format not recognized’ is closed to new replies.