Hello,
Can you please share a link to your checkout page?
Also, when you go to the “MC4WP > Others” menu, do you see any errors?
Hi, there is something like this
[2019-11-16 09:58:21] ERROR: WooCommerce Checkout > Mailchimp API Error: Bad Request. Invalid Resource. kari************@gm***.con looks fake or invalid, please enter a real email address.
Request: POST https://us20.api.mailchimp.com/3.0/lists/2a3c06b967/members - {"status":"subscribed","email_address":"kari************@gm***.con","interests":{},"merge_fields":{"ADDRESS":"Oslobodite\u013eov 264","BIRTHDATE":"2000-02-15","CATEGORY":"L\u00edstok – CLASSIC","CITY":"Kr\u00e1snohorsk\u00e9 Podhradie","FNAME":"Karin","LNAME":"Voz\u00e1rov\u00e1","PHONE":"0904819080","SEX":"\u017dena"},"email_type":"html","ip_signup":"185.214.192.24","tags":[]}
Response: 400 Bad Request - {"type":"http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/","title":"Invalid Resource","status":400,"detail":"kari************@gm***.con looks fake or invalid, please enter a real email address.","instance":"0dfc6262-bc60-48ce-a0d3-d11809cd2503"}
But the e-mail is stored in MCH. Also name of product. What is missing, is additional fields in checkout.
Link on checkout – please, click this link: https://therace.sk/registracia-kategorie/elite/ and click there “Kúp si lístok” red button. This is a custom link to add a variation to cart and redirect to checkout.
-
This reply was modified 6 years, 6 months ago by
megosoft.
Hello,
Can you please let us know what you mean by “MCH”?
Also, is this email “kari************@gm***.con” yours? Can you test from a different email address and see if the details are sent to MailChimp.com even when selecting PayPal?
Hi, MCH == MailChimp 🙂
this kari***… is not my e-mail, but client’s. Here’s the screenshot of the MCH audience list
https://prnt.sc/pyiajr
E-mail is e-mail. You understand. Everything is OK. Krstné meno == first name, Priezvisko == last name, Pohlavie == gender, Kategória == product (variant)
So where is nothing else, but e-mail, it’s OK, this is subscribers from newsletter form, they will be filtered to send newsletter mails. That’s OK.
Where is everything (including Pohlavie – gender), those guys paid by direct bank pay. Everything is OK. Where gender is missing, those guys paid by PayPal. We need those information, but they are not in audience lists. I don’t know why?
I can understand, if no gender was there, but not if only product is paid via PayPal… ? For paypal there is “Paypal express” plugin used.
Hello @megosoft,
This is because the data is no longer in $_POST by the time the customer is redirect back from the PayPal website to your website to finalise the order. No worries though, because the data is saved by WooCommerce we can look it up from where they stored it – on the order itself.
add_filter( 'mc4wp_integration_woocommerce_data', function( $data, $order_id ) {
$product_name = '';
foreach( WC()->cart->get_cart() as $cart_item ){
$product_var_name = array();
$product_id = $cart_item['variation_id'];
$product_name = (get_the_title($product_id));
//$product_var_name = str_replace(“Lístok na preteky”, “Lístok”, $product_name);
}
$order = wc_get_order( $order_id );
// Grab Mailchimp field values from the current request
$data['SEX'] = $order->get_meta('billing_gender', true );
$data['BIRTHDATE'] = $order->get_meta('billing_birthdate', true );
$data['CITY'] = $order->get_billing_city();
$data['ADDRESS'] = $order->get_billing_address_1();
$data['CATEGORY'] = $product_name;
$data['PHONE'] = $order->get_billing_phone();
// Return the fields so the plugin knows to send them to Mailchimp
return $data;
}, 10, 2);
Hope that helps. If not, let us know please.
PS. I notice you’re trying to send data to Mailchimp about the products bought. I would recommend using the order to look for bought products instead of using the cart object, as the cart may have already been emptied at the time this snippet runs.
An even better solution would be to use our e-commerce integration feature in Mailchimp for WordPress Premium as it allows you to see exactly what was bought by your subscribers and when.
Please, what means ,10, 2 in the last line of code?
Your code with direct bank pay works OK, thank you. I must wait for new order by PayPal 🙂 hope, everything will be OK
Plugin Contributor
Lap
(@lapzor)
Awesome, Thanks for letting me know.
FYI:
The 10 is the $priority parameter (10 is default) which defines when your function will run in regards to the other functions which are attached to the nav_menu_css_class filter. 2 is the $accepted_args parameter which tells wordpress how many parameters the function you want to add will take.
Hope that helps. If you have any questions, please let me know!
Ok, Just one question. In $order_id there is an id of current order?
Plugin Contributor
Lap
(@lapzor)
Yes I would suppose so, the internal ID.
Hi, I have a new order by PayPal, address, phone and city are stored in mailchimp (default woo fields), but additional fields – gender and birthdate are not stored 🙁
In case of direct bank pay everything is OK
Hi, update.
The problem is not in your plugin. The additional fields are missing in database, while user pays via PayPal express. Your plugin is awesome 😉 Thanks for help
Awesome, glad to hear it @megosoft. Thanks for letting us know!
If you have a quick minute to spare to leave us a plugin review, it’d make us very happy!