Compare Handlebar - Looping Through Items List

This pertains to the Magento 2 - NetSuite integration, Order Import Flow.

I'm having trouble with a handlebar, in which I'm checking for the presence of 3 different items to determine whether or not to check "Box A" on a sales order upon import. Box A is a Transaction Body Field in NetSuite.

The behavior I'm looking for: If SKU for Item A, Item B, or Item C is present in the Items list on the order, check Box A on the sales order.

My handlebar is as follows, for setting the Boolean field Box A:

{{#each items}}{{#compare sku "==" "Item A"}}T{{else}}{{#compare sku "==" "Item B"}}T{{else}}{{#compare sku "==" "Item C"}}T{{else}}F{{/compare}}{{/compare}}{{/compare}}{{/each}}

Desired behavior is to have the box checked if any of these items are present on the order. The actual behavior is that the loop will continue to check or uncheck a box as it loops through the items. So the formula will only evaluate based on the last item in the list.

For example, an order with only Item A would evaluate to True.

An order with Item A, and Item D would evaluate to false:

Item A - Evaluates to true, loop continues

Item D - Evaluates to false, loop ends and Box A = false upon sales order save.

To get around this issue, I will need the loop to stop if it runs into any of these items. Does anyone know what handlebar helper can be used to accomplish this? Any insight would be appreciated.

0

Comments

0 comments

Please sign in to leave a comment.

 

Didn't find what you were looking for?

New post