I’m running into a problem with trying to develop some functionality. The basic layout is as such:
User has a “shopping cart” of sorts, where they can add items from different stores. The shopping cart is represented as a list of “CartItems”. Each cartitem has a quantity and links to a product, which has its own price. Each CartItem is also tied to a store, and a user can add items to their cart from different stores.
Here’s where it gets difficult: I’d like to calculate the tax for the cart. I’m using the TaxJar API via a connector, which has you provide “to” and “from” addresses. This means that I actually can’t just make one API call to calculate tax, I have to make one API call per STORE that the user has items in their cart from, since the store’s addresses are different.
Essentially I want a dynamic list that, on the fly (rather than on button press), does the following:
- Groups the cart by store, calculates the sum of the product of each CartItems’ quantity and product’s price, then returns a list of these sums, along with their associated store
- Makes an API call for each item in the list based on its store address and sum, and returns the total value with tax
- Sums the final taxed values together for a total with tax included
Unfortunately, even using groups and the “ListItemExpression” value of the toolbox plugin, I can’t seem to figure out how to do this. Does anyone have any insight?