Jump to content

Stuck on 'CashOnDelivery' code


dogdayfear

Recommended Posts

Im trying to customize a COD module to fit my needs.

 

This is the piece of code

$order->total_shipping_tax_excl = (float)$this->context->cart->getPackageShippingCost((int)$id_carrier, false, null, $order->product_list)+$fee;

At the end of the line I need 

$fee/1.21

but it throws an error.

 

But if I use

$fee*AnyNumberHere

it woks but obviously it is not the result I need.

 

Why can I multiply but not divide?

 

Im using PS 1.6.0.14.

 

Thanks in advance.

Edited by dogdayfear (see edit history)
Link to comment
Share on other sites

I'm not sure why you can't divide. Perhaps you need to use brackets like ($fee / 1.21)? Or maybe you need to convert fee to a float like ((float)$fee / 1.21)? If neither of those work, you can use simple algebra to convert it into multiplication, i.e. ($fee * (1 / 1.21)) or ($fee * 0.8264462809917355).

Link to comment
Share on other sites

Hi rocky!, thanks so much for answering.

 

- If I use brackets -> Error.

- I tried converting to float -> Error.

 

After that I give it a try to algebra and that give a little light:

 

($fee *  (1 / 1.21)) -> Error.

($fee * 0.8264462809917355) -> ERROR TOO!

 

So I think its about decimals used.

 

In terms of decimals I can divide by 1.2 and can multiply by 0.8264462. If I use more decimals it throws the 500 server error.

 

Can you figure out what is happening?

 

Thanks again.

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...