• Hello. I’m trying to add an aditional field to the Mailchimp, but without any success.
    I’ve got the “WooCommerce Checkout Manager” and I’ve set up some filds in it, lets say “test”.
    When i go to the CheckOut page, and “buy” anything, the field is writing to the database, but i can’t send it to the MailChimp.
    Here’s the screenshot from my functions.php file:
    https://i65.tinypic.com/34ill46.png
    The phone, ID1 and ID2 fields(my custom fields) works just fine.
    Untill I enable the 508 line ($merge_tags['BIRTHDAY'] = $_POST['birth'];)
    After I enable it, none of the fields sends to the Mailchimp.
    I need that Birthday field and some other fields, like “city”, “address”.
    But I can’t make it work the same way as those 3 fields works. That’s weird.
    What should I do to make it work?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter lukoie

    (@lukoie)

    noone?

    Plugin Author Saint Systems

    (@saintsystems)

    @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 ]

    • This reply was modified 6 years, 11 months ago by Jan Dembowski.

    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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Adding additional field to MailChimp’ is closed to new replies.