mailchimp-api
mailchimp-api copied to clipboard
mailchimp objects
Hello,
I'm able to send data to mail chimp for text fields, but how can I format data for those which mailchimp calls "object"? Like address, or product in case of order?
Thanks a lot
@giorg you'll need to read the mailchimp api docs for this. Try: http://developer.mailchimp.com/documentation/mailchimp/guides/get-started-with-mailchimp-api-3/#json
thanks for your answer, yes I've read that, I mean I tried the usual way in php:
$result = $MailChimp->patch("lists/501580b9e9/members/$subscriber_hash", [ 'merge_fields' => [ 'FNAME' => $order->getCustomerFirstname(), 'LNAME' => $order->getCustomerLastname(), 'BSTREET' => $baddress[0], 'BCITY' => $order->getBillingAddress()->getCity(), 'BPOSTCODE' => $order->getBillingAddress()->getPostcode(), 'BADDRESS' => array( 'address1' => $baddress[0], 'city' => $order->getBillingAddress()->getCity(), 'province' => $order->getBillingAddress()->getRegion(), 'postal_code' => $order->getBillingAddress()->getPostcode(), 'country_code' => $order->getBillingAddress()->getCountry() ) ] ]);
but the BADDRESS gives me "merge field invalid", if I remove it everything works. So I wonder how to format the BADDRESS field.
thanks a lot
The address data structure looks like this:
[
'addr1' => '',
'addr2' => '',
'city' => '',
'state' => '',
'zip' => '',
'country' => ''
]
Just in case anyone is still looking around for this answer here is what the code should look like:
$subscriber_hash = $MailChimp->subscriberHash($email);
$result = $MailChimp->patch("lists/$list_id/members/$subscriber_hash", [
'merge_fields' => [
'FNAME' => $firstname,
'LNAME' => $lastname,
'ADDRESS' => array
(
'addr1' => $addline1,
'addr2' => $addline2,
'city' => $city,
'state' => $state,
'zip' => $zip,
'country' => $country
)
],
'interests' => [$interest_id => true],
]);
print_r($result);