This is for the Shopify to Netsuite sales order flow. We have custom fields in shopify order, see the bottom of this post. I want to be able to transform and map these fields into a netsuite custom field that is likely to be "shopify_subscription_percentage".
I need to have logic to check another field "note_attributes" in the order to determine if the order is an "initial_subscription" or "recurring". If initial then use the inital percentage, if recurring, use the recurring one.
Is this possible with handlebars if i add a new mapping field to the flow? (see below, i think not). If i need a hook, I assume that it is not possible, as hooks are not allowed in the IA, is that true?
// order has an array of:
"note_attributes": [
{
"name": "_subscription_order_type",
"value": "initial_subscription_only"
},
{
"name": "_payment_method",
"value": "shop_payment_method_2054"
}
// for each line_item in the order, there is an array:
"properties": [
{
"name": "_subscription_recurring_discount",
"value": "percentage:5"
},
{
"name": "_subscription_frequency",
"value": "1_week"
},
{
"name": "_subscription_line_item",
"value": true
},
{
"name": "frequency",
"value": "1 week"
},
{
"name": "_subscription_initial_discount",
"value": "percentage:10"
}
],
After working on the handlebars in Playground, i can read the values in each array but i cannot use note_attributes to determine the value we select from line_item properties.
# note_attributes array:
{{#each order.note_attributes as |attr|}}
{{#compare attr.value "==" "initial_subscription_only"}}
order type = initial subscription!
{{/compare}}
{{/each}}
# line_item properties array:
{{#each order.line_items as |line|}}
{{#each line.properties as |prop|}}
{{#compare prop.name "==" "_subscription_initial_discount"}}
initial discount = {{prop.value}}
{{/compare}}
{{/each}}
{{/each}}
# (output) note_attributes array:
order type = initial subscription!
# line_item properties array:
initial discount = percentage:10
My conclusion is that this can't be done with Handlebars, we would need a javascript hook in the IA. So what should we do?