Zen Cart Logo
Forums / General Questions / grab shipping total amount separately

grab shipping total amount separately

Views: 618

Results 1 to 3 of 3
1 Aug 2013, 8:06 PM
#1
sbbemn avatar

sbbemn

Zen Follower

Join Date:
Jan 2010
Posts:
182
Plugin Contributions:
0

grab shipping total amount separately

Hello, been at this and can't seem to extract just the shipping amount from order total... here is what I poked at...

(Shipping Type) - $x.xx

<?php echo substr(str_replace($united, $usps, $order->info['shipping_method']), 0, 38) . $break . $order->totals[$i]['text']; ?>

It is grabbing the shipping total, but if there are other totals involved (Tax, insurance etc), then it grabs that $ instead. How do I specify ONLY ot-shipping-Amount?
It also displays $0.00 and other times nothing at all, quite sporadic.... very odd.

1 Aug 2013, 8:39 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: grab shipping total amount separately

not all ot_xxxx records are for shipping, hence your sporadic stuff. If you want ot_shipping specifically, select only the ot_ records that are for 'ot_shipping'

and if you use 'value' instead of 'text' you'll get just the amount instead of any related descriptions

1 Aug 2013, 10:23 PM
#3
sbbemn avatar

sbbemn

Zen Follower

Join Date:
Jan 2010
Posts:
182
Plugin Contributions:
0

Re: grab shipping total amount separately

thanks for making me think! This did the trick...

00 were in the mix, so I chopped them off.

<?php 
   $shiptotal = $db->Execute("select value from orders_total where class='ot_shipping' and (value > 0 or text='PAID') and orders_id='" . (int)$oID . "'");
   ?>
   <?php echo substr(str_replace($united, $usps, $order->info['shipping_method']), 0, 38) . $breakm . number_format((float)($shiptotal->fields['value']), 2, '.', ''); ?>