Forums / General Questions / How can I get subtotal value at the checkout success page?

How can I get subtotal value at the checkout success page?

Locked

Views: 1,973

Results 1 to 2 of 2
This thread is locked. New replies are disabled.
9 Sep 2008, 10:41 PM
#1
dmcontact avatar

dmcontact

New Zenner

Join Date:
Sep 2008
Posts:
4
Plugin Contributions:
0

How can I get subtotal value at the checkout success page?

I did some looking around and have found and examined the $orders object at the checkout success page. What I am doing is including a tracking pixel into the checkout success page so that the pixel will send a bit of information to an external program I wish to use. The pixel will report the amount of the sale and the sale ID to the external system. I used the Define Pages Editor and selected "define_checkout_success.php" page.

In here, I would include piece of HTML like this:

<img src="http://mysite.com/tracking_sales/my_code/<?= $orders->fields['total_amount']; ?>/<?= $orders->fields['orders_id']; ?>/">

This is almost perfect, except that the total_amount field includes the products as well as shipping costs. I looked through the $orders->fields array and it doesn't even have the shipping amount as a separate field so that I could subtract shipping total from order total to get my subtotal. I need to be able to report the order total without shipping included. Does anyone know if this is available at this page somehow? Or if there's at least a way to get the shipping total to do math to get my subtotal?

Thanks in advance.

12 Sep 2008, 4:56 PM
#2
dmcontact avatar

dmcontact

New Zenner

Join Date:
Sep 2008
Posts:
4
Plugin Contributions:
0

Re: How can I get subtotal value at the checkout success page?

Well, I couldn't come up with any better solution for this, so I am just going to query the subtotal from the database within the checkout success template like so:

// $st_result = $db->Execute("SELECT ROUND(value, 2) subtotal FROM orders_total WHERE class='ot_subtotal' AND orders_id = '{$orders->fields['orders_id']}'");
$st_result->fields['subtotal']; // <- this is the subtotal pre-shipping