Forum

Thread tagged as: Question, MailChimp, Shop

Add to mailing list after checkout

I'm trying to add a customer to a Mailchimp mailing list after they have completed checkout. Is there a way to do this through the Perch shop? I will need to pull out their email and which product (course) they have purchased in order to drop them into the correct group in Mailchimp.

Many thanks.

Rob Saunders

Rob Saunders 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

There's no direct integration for particular mailing providers within Shop, but I would have thought you should be able to achieve that.

How are you currently handling the MailChimp subscriptions?

Currently I am not handling subscriptions at all, this will be a fresh start from scratch so I can set it up however is best.

There are two products, one course in London and one in Bristol.

The plan I had was to have everyone added to the same mailing list, but passing over the SKU into mailchimp and using that to set a segment. That way the client has the option to mail everyone who is taking a course, or mail just the people taking the course in London 2016 for example.

Drew McLellan

Drew McLellan 2638 points
Perch Support

I was thinking you could just do it with MailChimp's JavaScript API from the order confirmation page, but it looks like MailChimp doesn't have a JavaScript API.

Looks like you'll need to do this server side. How's your PHP?

Hmmm. Not great...but I have a friend who can help :)

What is the best way of outputting the customer email and product sku on the payment successful page? Then I can work on passing that detail over to mailchimp.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Try:

$result = perch_shop_order_items(perch_shop_successful_order_id(), [
            'skip-template' => true
            ]);

Thank you that gives me the order details but not the customer email address. Any way to grab that from the order form as well?

Drew McLellan

Drew McLellan 2638 points
Perch Support

That would be

perch_member_get('email')

Oh brill! Thank you.