Hi All,
I know this out of the scope of support but was hoping someone out there might help.
I am using a pipe to create an invoice in Shopify. Shopify has an array called line_items and you add your qty and the product. This works for one product but what if I have 3, or 4, etc. I can’t send a qty of 0.
Since the pipe request looks like this:
{“draft_order”:{“line_items”:[{“variant_id”:“{item}”,“quantity”:“{qty}”}],“note”:“{on}”,“customer”:{“id”:“{customer}”},“use_customer_default_address”:true}}
You can see the line_items array. I know that I can just add another element to that array but I don’t always have that. Sometimes customers have other items and I’d like a conditional I guess.
Something like:
If service fee is not blank, add another line_item element making the JSON request look like:
{“draft_order”:{“line_items”:[{“variant_id”:“{item}”,“quantity”:“{qty}”},{“variant_id”:“{item2}”,“quantity”:“{qty2}”}],“note”:“{on}”,“customer”:{“id”:“{customer}”},“use_customer_default_address”:true}}
Notice that the above has a second element within the line_items array. This seems complicated as I type this out but very popular considering most invoices have line items and we never know how many there will be. It is a variable and we just tacking one on to the arrays we send.
Any ideas?