1

Justin at ObjectiveHTML has been helping me out here but I think it might be time to see if anyone else has had some experience with this.

My client is selling two items. Item A requires an email be sent to the customer when the purchase is authorized with copies of the email sent to a set of additional recipients, let’s call them Set A. I’ve been using the standard CartThrob Notifications and EE mail and it is working.

Now, Item B is to be sold but, when purchase is authorized, an email is to be sent to the customer and to a different set of additional recipients, Set B. (Note: both Items can not be purchased in the same order.)

There didn't seem to be anyway to do this in CartThrob so I installed Postmaster. Postmaster has a "cartthrob_on_authorize" hook that will send out an email when a purchase is authorized. I was able to make that work equally well on Item A. (I figured out how to "turn off" the CartThrob Notifications, I'll put that in a note at the bottom.)

Postmaster also has a "Extra Conditionals" feature to do things like not send the email if the customer hasn't entered a full name. Justin thought that it would work to put this in to keep an email from being sent out when the product purchased was not, say, Item A. (Note: each item in the CT orders channel has an order_items CT field which is a matrix that includes an entry_id field which uniquely identifies a product. Item A's entry_id is 213.)

{if hook:entry_id != “213”}FALSE{/if}

Unfortunately, no email got sent out when I tried this. I tried various iterations of it including:

{if hook:item_options:entry_id != "213"}FALSE{/if} 

and

{if hook:item_options:item:entry_id != "213"}FALSE{/if} 

neither of which worked.

I'd certainly appreciate hearing from anyone who has successfully used the "Extra Conditionals" feature with the "cartthrob_on_authorize" hook.

I'm using the latest Postmaster version and 2.3.5 version of CT.

Thanks,

Jeanne

P.S. I tried setting "Log Email" to "No" in CT Notifications but that did not stop the emails. Justin gave me the hint to set up a "dummy" email which just means just leaving the email section as blank as possible.

1
  • To get CT's notifications to stop completely, you'll need to leave one notification, and just make the event something that will never get triggered. For example, 'Refund alert' if you don't process refunds. Removing all CT notifications doesn't work, for whatever reason. Commented Aug 7, 2013 at 22:51

2 Answers 2

1

If there's only ever one item being purchased in a single checkout, maybe try {hook:items}{if '{entry_id}' != '213'}FALSE{/if}{/hook:items}.

For debugging, it's useful to get to a point where an email is definitely being sent (ie, remove all the extra conditionals), then print out the variable names in the body of the email so you can see what they should be called. Also handy if you don't mind getting your hands dirty is throwing a quick var_dump into the postmaster/hooks/cartthrob_on_authorize.php file to see what variable names are available.

0

I'm not sure this will help your particular case but I'm doing a very similar thing at the moment and this may help you.

You can use the custom_data array in {exp:cartthrob:submitted_order_info} to do some conditional logic. Add a specific value to your checkout form and test that value later in the checkout process.

For instance, I have a checkout form that can be used to pay a previous invoice. For the checkout form in this case I have added a hidden field.

<input type="hidden" name="custom_data[type]" value="invoice">

I can then check for that value in a notification template and the order-info screen that the customer sees after a transaction. In my case the notification template shows some different information.

{exp:cartthrob:submitted_order_info}
    {if custom_data:type=="invoice"}
        Show this message and other stuff
    {if:else}
        Show a different message, receipt and purchase details
    {/if}
{/exp:cartthrob:submitted_order_info}

I don't know Postmaster but I wonder if you could check the custom_data value and have Postmaster do its stuff based on that?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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