Calculations in a hook
Posted: 2013-06-04 08:47
HI,
I need some help with calculating in a hook please
tables
products
order
orderdetail
in orderdetail I have a field called product, when I select a product from the list I have an auto lookup field that populates the price field from the products table, this displays correctly.
I then have another field called quantity which I manually add the value a wish to purchase of the product
Then is the total field which is calculated by quantity x price = total, I do this through the orderdetail hook
$data['total'] = $data['quantity'] * $data['Price'];
problem
the auto lookup sets the price in the database to the ID of the products table and not the actual value which is displayed.
example - correct
product A = $1000
quantity = 2
total = $2000
example - database
product A = 1
quantity = 2
total = 2
How can I get the actual values to be passed to the table instead of the field ID of the other table?
thanks in advance.
Joe
I need some help with calculating in a hook please
tables
products
order
orderdetail
in orderdetail I have a field called product, when I select a product from the list I have an auto lookup field that populates the price field from the products table, this displays correctly.
I then have another field called quantity which I manually add the value a wish to purchase of the product
Then is the total field which is calculated by quantity x price = total, I do this through the orderdetail hook
$data['total'] = $data['quantity'] * $data['Price'];
problem
the auto lookup sets the price in the database to the ID of the products table and not the actual value which is displayed.
example - correct
product A = $1000
quantity = 2
total = $2000
example - database
product A = 1
quantity = 2
total = 2
How can I get the actual values to be passed to the table instead of the field ID of the other table?
thanks in advance.
Joe