Ceil() Shipping Charges

Hello,

First of all, I was a little in doubt as for where to post my question, so hopefully this would be the correct forum. If not, please, could you move the post into its proper home? Many thanks!

I have modified an existing shipping module for PostDanmark for shipments in Denmark. All is working nicely, but I would like to somehow produce an integer to the customer, i.e. shipping charge 30 DKK instead of 29.97 DKK. I have tried to ciel the $cost var in the shipping module itself which doesn't have the effect, even though that var is clearly passing on the correct decimal number to the output var. Of course, it's easy to output the ceiled value cosmetically by simply ceiling the php echo throughput in box_checkout_shipping.inc.php, however this is just cosmetic and stores the wrong value.

So, I have been doing a little bit of digging, and to be completely honest, I was wondering whether you would be so kind to as to point me in the right direction for the shipping cost var, so that I can ceil it in the proper place?

Many thanks and all the best,
Joe

Is the problem that tax is added? Because you are at the right spot.

'cost' => ceil($cost),

and incl tax (dirty example)

'cost' => ceil($cost*1.25)/1.25,

Cache could be your enemy. Change quantity of items or restart browser with a fresh session.

Hi,

Thank you very much for the response.

Actually I was using this so that would catch and ceil all shipping options for the module.

return isset($cost) ? ceil($cost) : false;

I think the problem is that the standard currency in the shop is SEK, so DKK shipping charges are calculated as a function of SEK -> currency conversion to DKK with VAT added on top. Is the shipping coding logic separated from the products coding logic?

PS. I tried clearing the cache and starting a fresh session.

Return a ceiled value from the method calculate_cost() is also a good idea.

You can round a store currency amount in a remote currency in 1.3 by using currency::round($local_currency_value, $remote_currency_code). Note: round, not ceil.

All internal values used for calculation are always in store currency. That goes for eveything, products, shipping fees, payment fees, order total. Unless someone would write a module that does different.

If your values you are working with are not in the store currency, then they must be converted to the store currency before returned.

$cost = currency::convert(ceil($cost), 'DKK');

Okay, thanks for explaining. Perhaps a simpler question would then be; is there a way to round every amount to the nearest whole number?

tim

Just remove the decimals in your currency setting and turn on round amounts in admin -> settings to get rid of hidden decimal values.

This thread has been closed due to long inactivity. Posting to it is not possible.
View code on GitHub