Hi,
I want to add this functionality to the form. I want the price per unit to decrease when quantity is increased. I am using products (drop-down) and quantity (drop-down) fields. I have a very simple php if-else condition for this but i am dont know how to integrate this with the form. I have read about using hooks but i failed to use them. Please help me with this. Here is the php statement
function get_price(baseprice, quantity){
if(quantity ==1)
{
total_price = baseprice*quantity;
}
else if(quantity>1 && quantity <=10)
{
total_price = (baseprice-(baseprice*5/100))*quantity;
}
else if(quantity>10 && quantity <=20)
{
total_price = (baseprice-(baseprice*10/100))*quantity;
}
else if(quantity>20 && quantity <=50)
{
total_price = (baseprice-(baseprice*15/100))*quantity;
}
else if(quantity>51 && quantity <=100)
{
total_price = (baseprice-(baseprice*20/100))*quantity;
}
else if(quantity>=101)
{
total_price = (baseprice-(baseprice*25/100))*quantity;
}
return total_price;
}
Can you please tell me how to use this with a hook and where to place the code.
Thanks.