Button release - trigger actions after a counter is updated, only if counter is still within range

Hi All,
I’m stuck on this one. I am willing to completely change how I do this but this is where I am at right now:

  • I have a simple counter which keeps track of how many ounces are added to the cart (for shipping)
  • each item in the catalog has a different weight, normalized to ounces so it can always be added to the counter as is
  • on the catalog screen, hit the “Add” button, what I want to happen is: 1) does this item cause the cart to exceed the max weight? 2) if yes: alert the user and don’t add the product to the cart, if no: add the product to the cart as usual … I can’t seem to execute the IF statement AFTER the counter is added to…any suggestions?
  • note: I thought about triggering off the counter itself however I need the product info to add to cart which is all attached to the item in the asset grid, all pulled from an interface asset of course.

Hi @nicole and welcome to the Community! :tada:

First, if you don’t use it already, I recommend you to check the Browse and Select Retail Sample from the Marketplace.

As you will see, it uses a Shopping List Interface Asset.

Looking at the X-Ray Panel of Shopping list, here is what it offers

The process here, would be to edit this Interface Asset and customize it for your needs, by adding properties Item Unit Weight, Item Total Weight for each item, and a property Total Weight calculating the sum of all items (quantities x unit weight) at the root of the Interface Asset.

Once it’s done, you will be able to use 2 Conditional Triggers when user is adding elements like:

WHEN button (+) is pressed
   AND "Total Weight" is < 20
THEN Item Quantity +1 for the item

and

WHEN button (+) is pressed
   AND "Total Weight" is >= 20
THEN Message about cart being overweight

As you see, the process here is to create an equivalent for “weight” of what you already have for “price”.
If you want to check the principles before starting modifying the Interface Asset, you can test implementing a cart with a maximum price (instead of a maximum weight)

Please note it requires a bit of Javascript knowledge to edit an existing Interface Asset.
I recommend you to have a look at this series of articles from our Help Center, starting here: https://support.intuiface.com/hc/en-us/articles/360007431131-Interface-Asset-General-Concepts

Don’t hesitate also to have a look at our Intuiface Academy for some guidance, especially the lesson “Custom Interface Asset” from the course Connecting to the world.

Kind regards,

Alex.

2 Likes