Forum


Calc Builder Support

Calc Builder support
Forums
Public write access is disabled. Please login

Multiple matrices 28.02.2015 21:47

Hello, I want to make a price calculator for my homepage. Price depends on three variables (length, width and material). Because I have four types of material, I made four matrices. Potential buyers can choose material by an option field. Variable of option field is $material. Depending on the material I want to select a price in one of the four matrices. I use the following code, but does not work: $price=$material[$length][$width]. It does not work because the variable of the four matrices is not 'material' but 'wood', 'steel' etcetera (the type of material the customers can choose). Is it possible to make this work this way? Or is there another (simple) option? Thanks!

Update 1-3-2015: I tried to use the switch PHP code and it seems to work out for me.

Edited by jvanmid - 01.03.2015 11:46

Re: Multiple matrices 02.03.2015 08:13

Hello,
great it worked, thanks for sharing. In case it may help others, for this situation you can use the if/else structure, the switch structure, or the $$ operator. Its used to refer a variable whose name is also a variable like it happens for this case, so you could use:

$mymatrix=$$material;

and then query $mymatrix


$price=$mymatrix[$length][$width]

Regards
Moonsoft Team
www.moonsoft.es
Are you satisfied with our products/services/support?
Please help us to keep improving, add a review at  joomla extensions site and  magento connect

Our clients' feedback