5 Replies Latest reply on Jul 25, 2017 1:22 PM by fm-user01

Getting n min number of a portal

Hello everyone,

I am working for this customer, pizza place. They do have a promotion going on, if you buy 6 can of drinks, the second pizza(cheapest) would be half price. Like if you are ordering 3 mushroom pizza(19\$) and 2 Pepperoni (22\$) and 6 cans of drink, then you will get 50% off 19\$. My file is working fine for this discount.

However if you get 12 cans, then 2 pizza are discounted, and here is where my file fails to do. I need some help to fine a solution for this.

Pizza Table includes "Name", "price per unit", "Quantity", "Total price"

Shopping cart: includes a portal of pizzas

Thanks

• 1. Re: Getting n min number of a portal

How are you flagging that they bought the sodas?  How does that purchase then discount the pizza?

• 2. Re: Getting n min number of a portal

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)

• 3. Re: Getting n min number of a portal

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.

• 4. Re: Getting n min number of a portal

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?

• 5. Re: Getting n min number of a portal

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.