Jump to content

[solved] Subtraction in php!


Recommended Posts

hey, i'm trying to subtract two variables in product.tpl like this:


{convertPrice price=$product->getPriceWithoutReduct()-$product->getPrice()}



what is so confusing to me is that the following code shows both variables come up with their values, for example: £10 £9, and all i want is for £10-£9 to appear, so it comes out as £1

{convertPrice price=$product->getPriceWithoutReduct()}{convertPrice price=$product->getPrice()}




and if i try this:

{convertPrice price=$product->getPriceWithoutReduct()-2}


or

{convertPrice price=$product->getPrice()-2}



they both work and show correct values - 2!

it only breaks when i try to subtract the vars with each other!

is there any way i can subtract those two variables?

thanks

Link to comment
Share on other sites

  • 4 years later...

Hi,

 

I would like to know if you have found the solution to substract 2 var. I have the same problem, when I substract 1 var with a number I get the good answer but when I substract 2 var, it just display the last one.

I've tried all these, nothing works : 

{math equation="x-y" x=convertPrice price=$product->getPrice(false, $smarty.const.NULL, 2) y=convertPrice price=$ecotax_tax_inc}

 

{convertPrice price=$product->getPrice(false, $smarty.const.NULL, 2)-convertPrice price=$ecotax_tax_inc}

thanks

Link to comment
Share on other sites

×
×
  • Create New...