PattyBlount
Community Member
6 months ago

# Storyline360 variables, calculating values with maximums

Hello,

I'm working on a project that must calculate a Shopping Cart total for 2 different products, A and B. Customers receive a volume discount per unit and that discount varies, depending on quantity. They may buy no more than 5 products total and may mix/match (i.e., 4 of A with 1 of B, etc.)

I'm stumped how to set up the variables to calculate the Cart Total.

Here are the volume discounts:

 Product Quantity Cost A 1 45 2 30 each 3 30 each 4 30 each 5 25 each B 1 55 2 40 each 3 40 each 4 40 each 5 35 each

I know I need a variable for Cart Total, Quantity A, and Quantity B.

After that, I'm not sure how to include the conditions or the 5 product maximum.

I have no project file to share yet. Can anyone help me figure out how to express the variable calculations?

• Calculations are performed via a series of triggers: one operation per trigger.

The attached file demos how this could work for your calculation.

It has two button sets: one set of 5 buttons to choose how many of Product A, and another set of 5 buttons to choose how many of Product B.

My number variables are called A_Cost and B_Cost. The buttons have triggers that first set the associated variable to the appropriate per-item cost. Then another trigger multiplies that by the quantity. (The buttons for choosing just one item don't need that second trigger.) Here's what all those triggers look like:

The button to calculate the Cart Total has similar triggers. The first trigger sets the Cart_Total variable to the value of the A_Cost variable. The second trigger adds the B_Cost value.

FYI: When you're editing triggers, every item with a dashed underline is editable. So, when adjusting a number variable, click "Set" to access the math operators.

Also note: I simply inserted a picture of your chart, and put buttons over that. That's fine for a quick demo, but not for accessibility purposes. You may have to set up your buttons differently. But I hope this gives you a good start on how to do it.

• PattyBlount
Community Member

Thank you so much! I was completely unsure how to even begin this. You've helped so much :)