I have 3 products. All the products have the same price, I named it : price
Each product has a discount. I defined its variables as follows:
discount1, discount2, discount3
But there is a different tax for each product when the discount equals 100% (for example) as follows:
tax1, tax2, tax3
I wrote this code and it works well:
But I need a simple and short code that do the same functionality because when new products are added, the code will be large and difficult to follow.
Each product has a discount. I defined its variables as follows:
discount1, discount2, discount3
But there is a different tax for each product when the discount equals 100% (for example) as follows:
tax1, tax2, tax3
I wrote this code and it works well:
Code:
if discount1 = 100 and discount2 = 100 and discount3 = 100 then total_price = price - tax1 - tax2 - tax3 elseif discount2 = 100 and discount3 = 100 then total_price = price - tax2 - tax3 elseif discount1 = 100 and discount3 = 100 then total_price = price - tax1 - tax3 elseif discount1 = 100 and discount2 = 100 then total_price = price - tax1 - tax2 elseif discount1 = 100 then total_price = price - tax1 elseif discount2 = 100 then total_price = price - tax2 elseif discount3 = 100 then total_price = price - tax3 else total_price = price end if
Comment