Tags that display cart total and coupon code

I am setting up custom tracking in my store. The tracking script accepts parameters to capture values like the total amount of a sale, etc like so:


So, for each parameter I just add the smarty tag to populate it.

I am adding the tracking code to the /store/skins/basic/customer/views/orders/details.tpl template. I have been able to get everything to work, except I cannot locate what smarty tag to use fort the value of the order total and the coupon code. I have been able to get subtotal, but not order total.

Can someone please tell me what two smarty tags would display those values (ie {$order_info.cart_total}

Thank you for your help.

I discovered the debug console in the adin settings and enabled that. I believe the coupon code can be gotten from the $applied_promotions array. Not sure how to cycle thru to get all its elements. If anyone knows how to do this, please post some sample code where it goes thru $applied_promotions and pulls the bonus or coupon code names and combines them into a text string.

For anyone trying to do the same, the following are working for me:




{$user_info.user_id} {$user_info.firstname} {$user_info.lastname} {$user_info.email}



Is till can’t get the coupon code names though. I tried {$applied_promotions.name}, but I’m guessing its missing an element t tell it which array.

Here’s what I have in the debugger:

In the left side debugger panel:


In the right side debugger panel:

Array (74)
order_id => "2043"
user_id => "1"
total => "21.79"
subtotal => "68.43"
discount => "0.00"
subtotal_discount => "54.36"
payment_surcharge => "0.00"
shipping_ids => "1"
shipping_cost => "7.72"
timestamp => "1271818246"
status => "O"
notes => ""
details => ""
promotions => Array (1)
19 => Array (3)
bonuses => Array (1)
order_discount => Array (4)
bonus => "order_discount"
discount_bonus => "to_percentage"
discount_value => "15"
promotion_id => "19"
name => "Test Coupon"
short_description => "Test Coupon by Jesse\r\n"

I need to figure out how to capture the “name” (“Test Coupon”).

I tried this, but no avail:


I also tried the same with values of 1,2, and 3 in case I had the array’s number reference wrong. Can anyone steer me in the right direction? I’m 99% sure I’m just referencing the array wrong.

I’ve been able to get the coupon code using th efollowing notation:


Unfortunately, it seems the number in the array is matched to the id of the promotion created in the store backend. We will have at least 60 of these since we track individuual media peices thru the coupon codes.This makes it impossible to just check the codes one by one (it would be sloe and we would have to update the code in our templates every time a new promotion is added. There must be some way to cycle thru the “applied_promotions” array and collect the value for every “name” element. This would result in just the applied coupon names being gathered together. I could then pass that into 1 variable that could be used within my tracking script to insert the capture the coupons.hink a “for each” loop may do this, but I’ve never done one in smarty.

Don’t think I’d do this at the template level. Much more control to do it at the controller level.

For instance, create addons/my_changes/controllers/customer/checkout.post.php with something like:

if( !defined('AREA') ) die('Access deined');

if( $_SERVER['REQUEST_METHOD'] == 'POST' && $mode == 'place_order' ) {
$my_url = "http://your_domain.com/my_tracking.php";
// order is already in the DB at this point
$o_info = fn_get_order_info($_REQUEST['order_id']);
// Grab what you want from the orderInfo assigning it to $my_params;
$my_params['order_id'] = $_REQUEST['order_id'];
foreach($o_info['promotions'] as $promo_id => $promo_info) {
$my_params['promo_'.$promo_id] = $promo_info['name'];
$my_url .= "?".http_build_query($my_params);
return array(CONTROLLER_STATUS_OK, $my_url);
} else {

Thanks Tbirnseth. Your 2 for 2 with my threads today :smiley:

Again a great answer.

I’ll wrap my head around your suggestion tonight and see if I can move the tracking I put into the template to the controller level you mentioned. I haven’t made any changes that way yet, but I’ll give it a shot. If I bite of more than I can chew and can’t tie it all together at the controller level, would you consider coding the controller snippet for me and PM an estimate of what the charge would be?

To give you an idea ofth ejob scope, here’s what I have in there so far and would need added to the code you gave above:

As you can see its just an image call with the smarty appended to the URL parameters. I’d need to have the coupon codes you gathered into $my_params appended at the position where I put {COUPON CODES GO HERE}. If the smarty tags I referenced can be used within the controller code you gave (I’m not proficient in smarty so I don’t yet know the scope of the smarty tags and where they will/won’t work), it should be possible to just take my snippet and embed it into the 5th line from the bottom of your code example, where $my_params is added to $my_url.

Thanks again for your help and explanation.

Note that what I provided is NOT smarty code. This controller is run before the template is executed. Your $my_url needs to be able to redirect back to the dispatch=orders.summary&order_id=123 when it is done capturing the info.

Why use an html page rather than a php page that can easly parse the parameters passed, update whatever database (or call other tracking code) and then simply return to where the dispatch=checkout.place_order would normally return to (dispatch=orders.summary&order_id=123.

Feel free to PM me if you want/need help.