How are you flagging that they bought the sodas? How does that purchase then discount the pizza?
Well, what in the Cart table, I do have a filed which calculated the number of pizza that should be discounted. it is as follows:
Min ( Floor ( Drink::Totalcans/6 ) ;Floor ( PizzaOrders::countpizzaorders /2))
The calculation gives the right number, now I need to choose the n first cheapest pizza (with consideration of quantity)
You could sort the portal by price, then throw a loop to go through the portal rows and find the last pizza and discount it.
Actually that is my main issue right now. It is sorted by price., but how to make a loop? Should I make a self adjoint relationship?
I concluded that the best way to do this is through a table instead of a portal. What I did: made a button with the following script:
Go to pizza table and find the related(to that shopping cart) pizza order
sort them by price
check one by one to find the n desired number of pizza
Please feel free to reply if you need help in a similar problem.