Is it possible to create different notifications for different products on CartThrob? I have products I'm selling in a products channel and services which are also offered that's within another channel. I would like the successful transaction of the products to shoot a different email notification than the service purchase, but I can't differentiate the two different orders because there's only "successful transaction" as the trigger. Any help on this would be greatly appreciated! Thanks!
1 Answer
(I'm with Vector; we own CartThrob)
There are two ways to do this, depending on how much customization you need:
- You can use conditionals inside the order notification template. Something like
{if channel_id == '2'}{/if}
(of the purchased item) in the code, and then have different content based on that. - For a lot more customization you can turn off the default notifications, and use the post-purchase hook with a custom extension to send your own emails. This way you can run through the purchased items and do whatever you need.
Also, is it possible to order both items at once on your site? If so you'll want to think through what happens then.
-
Thanks! Currently, I have the following setup on my notification template:
{if group_id=="1" OR "ORDER_ID" != ""} {exp:cartthrob:submitted_order_info} ALL THE CONFIRMATION INFO {/exp:cartthrob:submitted_order_info} {/if}
But would I put the conditional within the exp:carthrob:submitted_order_info like this?{if group_id=="1" OR "ORDER_ID" != ""} {exp:cartthrob:submitted_order_info} {if channel_id == "1"} ALL THE CONFIRMATION INFO {/if} {if channel_id == "2"} ALL THE CONFIRMATION INFO {/if} {/exp:cartthrob:submitted_order_info} {/if}
– user3092Commented Feb 11, 2016 at 20:53 -
@user3092 I think you should use
exp:channel:entries
withentry_id="{order_id}"
instead ofsubmitted_order_info
. Then you can put the conditionals wherever.– MattCommented Feb 12, 2016 at 20:57 -
I tried this, but adding the conditional {if channel_id == "1"} under exp:channel:entries doesn't seem to work. Nothing outputs when I wrap things with the conditional. Any idea?– user3092Commented Feb 22, 2016 at 23:24
-
The
e:c:e
loop there is going to be for the order itself. You'll want to use a combination ofexp:cartthrob:order_items
inside of there along with passing theentry_id
to possibly furthere:c:e
loops/embeds after, and set your conditionals there, on the ordered item, not the order itself.– MattCommented Feb 24, 2016 at 15:28