1

We currently can successful send the name and email fields to Campaign Monitor by this addon:

https://github.com/CartThrob/addon-mailing_list

By adding this field to our checkout form:

<input type="hidden" value="list id goes here" name="custom_data[campaign_monitor]">

Is there a way to send custom fields or an other fields to CM aswell?

IE. Fields like:

<select id="custom_data[order_gender]" name="custom_data[order_gender]">
  <option value="">please select</option>
  <option value="m">Male</option>
  <option value="f">Female</option>
</select>

OR

<input type="text" id="address" name="address" value="{address}" placeholder="Street Address" class="placeholder">

OR

<input type="text" id="custom_data[order_date_of_birth]" name="custom_data[order_date_of_birth]" value="{custom_data:order_date_of_birth}">

2 Answers 2

1

Looking at around line 114 of the source of the CT Mailing list extension, it looks like the addon adds the content of the ['campaign_monitor'] key of $this->EE->cartthrob->cart->order('custom_data') as part of the request to CampaignMonitor. The contents of this can be either a String or an Array, which suggests it's designed to permit multiple values to be sent to CM.

Quick aside: I find the CT docs are a little confusing as the suggest that when adding custom data to orders you can just use your custom field name name in your template rather than as custom_data['field_name'] the way you would for custom data on the save member form (though your custom field does need to exist in the back end for data to be saved). However looking at the source (Carttrob_core_ee.php, ~ line 548) I don't think you'd then still able to access these values via $this->EE->cartthrob->cart->order('custom_data'). I could be wrong though.

I haven't had a chance to test that I've got the syntax right, but it looks to me like all you may need to do is add the relevant fields to your order via the checkout form, namespacing your values under campaign_monitor[] (assuming you want to pass multiple values), so I think you either need

<input type="hidden" name="custom_data[campaign_monitor][custom_value_1]" value="{my_value_1}" /> 
<input type="hidden" name="custom_data[campaign_monitor][custom_value_2]" value="{my_value_1} /> 

or perhaps (but less likely):

<input type="hidden" name="campaign_monitor[custom_value_1]" value="{my_value_1}" /> 
<input type="hidden" name="campaign_monitor[custom_value_2]" value="{my_value_1} /> 

You can then set whatever data you need to send through to Campaign Monitor in your template.

If your data to send to CM always comes from the customer, you could probably also add the data via a simple custom extension using the cartthrob_save_customer_info_end hook, but I'd probably start by just outputting the values in the template (or reading them from other user inputed fields on the fly with JavaScript) as it's probably faster to try out.

1
  • » Thanks for the suggestions: Doesn't send anything: <input type="hidden" name="custom_data[campaign_monitor]" value="list-id-number-here"> <input type="hidden" name="custom_data[campaign_monitor][order_gender]" value="{custom_data:order_gender}"> Only sends name and email: <input type="hidden" name="custom_data[campaign_monitor]" value="list-id-number-here"> <input type="hidden" name="campaign_monitor[order_gender]" value="{custom_data:order_gender}"> Dec 10, 2012 at 22:50
1

One option is get Postmaster v1.2 when it comes out. I spent more 9 months analyzing problems from clients and how to better implement notifications with any email service.

Here is the original release https://www.objectivehtml.com/articles/read/postmaster-the-definitive-email-solution-for-expressionengine

v1.2 is coming in the next week or two, but happy to setup anyone up with the beta that has a license. v1.2 will feature CartThrob compatibility out of the box, for both checkouts and subscriptions. You can use EE tags to compose your email, html or plain text, whatever you need. There are even additional variables passed to the templates that CT doesn't even support. So to be clear, you can send emails with any service when a user checkouts. The hooks are there for failures and declines, but I didn't include that functionality by default. Among CT, Postmaster will work with any EE hook. Developers can include advanced support for their add-ons do really anything they want.

v1.2 will also open the extremely robust API's to the public with great documentation that I have also spent a lot of time improving.

Email support[at]objectivehtml.com if you have any project specific questions.

1
  • » Thanks for the suggestion. We only have a few days left to launch this project and having not used Postmaster yet and being new to EE I'm nervous to chuck another variable in there for me to muck up. No doubt PM is awesome like all your work. Dec 10, 2012 at 22:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.