How can we help?

Order confirmation message

Overview

An order confirmation message is a transactional message sent with an API call after a purchase is made. The API method for an order confirmation message is the Automation Templates method.

Order data sent using the Automation Templates API method is set in the external variables object. These variables are unique to that send and not stored in Cordial. You can, however, print the data in the message with Smarty, including the purchaser, product name, shipping address, and more.

Note: Data set in the "contact" object (email, name, etc.) is stored in Cordial as contact attributes after a send.

Create the automated message

Before an API call is made, you need to create the automated message and enable the API sending method.

1. Log into Cordial and navigate to Message Automation > Create New Automation.

2. Provide the necessary information and click Continue.

3. Fill out the message headers and click Save.

4. Click Edit under Message Content and enter the HTML for the message.

5. For this type of transactional message, we'll print the order data with Smarty that references external variables passed in the API call. Here's an example of a simple HTML message.

<h2>Thanks for your purchase!</h2>
Order ID: {$extVars.orderID}<br>
Date: {$extVars.purchaseDate|date_format}
<br><br>
{foreach $extVars.items as $item}
productID: {$item.productID}<br>
Name: {$item.name}<br>
Price: ${$item.price}<br><br>
{/foreach}

6. After entering the message content and header information, click the Publish button at the top of the page.

7. In the left panel under Sending Method, click API and then Enable the API sending method.

8. Now that the message is published and the API sending method is enabled, you can make the API call to send the message.

Send the message via API

In order for the message to send, you need to use the Automation Templates API method:

Note: Make sure to store the message key when sending with the API. You can get the message key from the API Sending pane.

Here's an example API call that would provide the order data for the automated message we just created.

{  
"identifyBy": "email", "to":{ "contact":{ "email":"fredgarvin@example.com" }, "extVars":{ "OrderID":"1234", "PurchaseDate":"2022-09-15 12:47:34", "orderTotal":"30.00", "Items":[ { "name":"shirt", "price":"10.00", "productID":"123" }, { "name":"pants", "price":"20.00", "productID":"456" } ] } } }

Notice how the field values (name, price, and productID) correspond to the Smarty variables.

If there are no errors, the final message will look like this:

Thanks for your purchase!

Order ID: 1234
Date: Sep 15, 2022 

productID: 123
Name: shirt
Price: $10.00

productID: 456
Name: pants
Price: $20.00

 

In the next article, you can learn how to set up a browse abandon message.

Comments

0 comments

Please sign in to leave a comment.