Jump to content

Get transport / product totals, how with 2 decimals


Cnic

Recommended Posts

Hello, i am trying to get the transport / product totals calculated with 2 decimals and have no idea how to do it.

1. the invoice API accepts prices with 2 decimals

2. the AWB generator uses the total order price, calculated with 6 decimals

This results in differences between the invoice and the amount of money to return on AWB. So errors in billing.

i Tried to use 

$shippingCost = (int) Db::getInstance()->getValue('SELECT shipping_cost_tax_incl FROM `' . _DB_PREFIX_ . 'order_carrier` WHERE `id_order` = "' . (int) $cartId . '"');

but i have no idea how to get the value with decimals (i solved by using only integers in most cases / 99%)

How do i get the total products cost calculated with 2 decimals on each product?

 

Link to comment
Share on other sites

Try with this code:

$shippingCost = (int) Db::getInstance()->getValue('SELECT shipping_cost_tax_incl FROM `' . _DB_PREFIX_ . 'order_carrier` WHERE `id_order` = "' . (int) $cartId . '"');
$shippingCost = number_format($shippingCost, 2, '.', '');

Regards!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...