Main content begins here

Customize the Ubercart Email Based on Product

Wednesday, September 23, 2009

Let's learn to customize the Ubercart 2 purchase confirmation email based on product. Modifying the message is fairly straightforward, though not the most user-friendly in a Drupally sense.

What I needed was a way to customize text on the email based on what products had been purchased. I imagine this could be something added later to the node itself so that each product could have it's own text blurb added to the email when purchased, or if related to a purchased product, however I needed a quicker solution.

Find the Ubercart Email Template

In your file structure find modules/ubercart/uc_order/templates/customer.itpl.php for editing. At the top of the template add something like:
<?php foreach ($order->products as $product2) {
    if ($product2->nid == 52) { $flag1 = 1; }
    if ($product2->nid == 53) { $flag2 = 1; }

You will of course need the "nid" of whatever your product nodes are. An example of this usage would be if you had a sporting goods store that sold products as well as training events like baseball camps. You could use something like this to check to see if the user had purchased a baseball glove and then insert a blurb into the email about upcoming baseball training camps.

In my case I was selling events and wanted a way to remind the user of the directions to the event. Since the events could be held in different buildings and/or rooms we needed to provide text based on the event.

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <p> <h2> <br> <img>
  • Lines and paragraphs break automatically.

More information about formatting options

This question is for testing whether you are a human visitor and to prevent automated spam submissions.

John Barrick rocks.

K. B., Owner Brook Group, LTD
Copyright ©2001-2018 Way Cool Web Design LLC. All Rights Reserved.