Marcin
Marcin

Reputation: 5579

orderTotal and orderId inside tpl_checkout_success_default - zen-cart

any ideas how to get orderTotal and orderId inside the tpl_checkout_success_default for the conversions tracking purposes ?

So far it looks like order id can be accessed by using this variable $zv_orders_id but how to get order total ?

will this code work:

$orders_query = "SELECT * FROM zen_orders WHERE orders_id = " . $zv_orders_id ." LIMIT 1"; $orders = $db->Execute($orders_query); $order_total = $orders->fields['order_total'];

many thanks, cheers

Upvotes: 0

Views: 1213

Answers (2)

Hayden Thring
Hayden Thring

Reputation: 1810

look in /includes/modules/pages/checkout_success/header_php.php

in there you will see the queries already being run by zencart to do with your order, and id say its already pulling out the info you want.

so you just need to set said data you need to a variable that you can then use in your tpl_checkout_success_default.php file.

eg, something like $customer_has_gv_balance, you will see where it is set in the hearder file and then used in the template file

heres something i found in order.php that would almost do it as is:

$order_total_query = "select text, value
                             from " . TABLE_ORDERS_TOTAL . "
                             where orders_id = '" . (int)$order_id . "'
                             and class = 'ot_total'";

$order_total = $db->Execute($order_total_query);

Upvotes: 1

Joe
Joe

Reputation: 1

For a simple tracking code like one used for a shopping comparison site, I've used the following for the order ID and order amount. Use these in the tpl_checkout_success.php page

Order ID:

echo $zv_orders_id;

Use this select statement:

$to_send_sql = 'select REPLACE (text,"$","") text from orders_total where orders_id = '.$zv_orders_id.' and class = "ot_subtotal"';

$to_send= $db->Execute($to_send_sql);

Order amount:

echo $to_send->fields['text'];

Hope this helps someone!

Upvotes: 0

Related Questions