Looping using Toolbox plugin

Good day bubblers,

This is the first time using the toolbox plugin. and for my use case, I don’t know if it is the best approach. I have a page similar to a checkout page where users add products with their respective quantity and a totalCost will be calculated for that user.

My problem is I want taxes/charges to be applied to the total. The taxes applied could be of a taxType (percentage or fixed amount) and they should be added incrementally e.g

user cart= { productName: “Product 1”, retailPrice: 1000, quantity: 2, totalCost: 2000 },
{ productName: “Product 2”, retailPrice: 500, quantity: 3, totalCost: 1500 },

Taxes/charges to be applied = { taxName: “VAT”, taxValue: 10, taxType: percent },
{ taxName: “Environmental Fee”, taxValue: 50, taxType: fixed amount },

For this example, The user cartTotal before taxes/charges is 3500

On adding the taxes/charges:
1.) VAT (taxType=percentage) : (10% of 3500) + 3500 =3535

2.) Environment fee (taxType: fixed amount): (3535+50) = 3585

The number of products or taxes is not fixed.

The cartTotal after taxes/charges is 3585.

Discount could still be applied which should also be a percentage value or a fixed value.

I have achieved this functionality using backend workflow but the cartTotal after taxes or discount doesn’t get displayed in an instance and can take up to 30 secs. I decided to try using the toolbox plugin and from the image,

i wrote a javascript function that performs this functionality but for some reason, I’m not getting a value back, please any help will be highly appreciated. Thank you


You should also check trigger event and get the event with a workflow.

image

image