Drupal theming. Webform module notification letter template
The catalog we created using the CCK, Taxonomy, and Webform modules allows you to notify the customer and the site administrator (manager) via email about a placed order. However, the manager currently only receives the product name, quantity, and customer details in the email. It would be much more convenient if the email also included a direct link to the ordered product.
Currently, the email received when an order is placed looks like this:
Submitted on Tuesday, November 16, 2010 - 15:56 Submitted by user: Admin Responses: Product Name: Colorful Plate Quantity: 1 E-mail: levmyshkin2@mail.ru Address: Omsk City Preferences and Comments: Responses can be viewed here: http://drupal/node/14/submission/1
You can customize the email template in the webform settings:
There is a section in the settings for editing the Email template:
Default template: choose the default template, which can be edited in the text area below.
Custom template: choose a template from the Webform module’s templates
folder.
Let’s first look at editing the default template. You can add dynamic data using Token values, which include form fields, global site variables, usernames, GET and POST session variables, and more.
Under Included e-mail values, you can choose which form field values to include in the email.
To include a link to the ordered product, you need to add a field for the product ID that will automatically capture the product's ID. In the product ID field, set the default value as %get[id]
. In the product order form link, add the id
parameter so that the URL looks like this:
<a href="<?php print base_path(); ?>node/14?product=<?php print drupal_get_title(); ?>&id=<?php print arg(1); ?>">Order Product</a>
Next, disable editing for the ID field in the field settings—you can also do this for the product name field.
Now, when a product is ordered, the email will include a line like this:
Product link: http://%site/node/%value[id_product]
Where id_product
is the machine name of the product ID field, and %site
is a token representing the site domain name.
This way, the order confirmation email will include a direct link to the ordered product.