I referred to the following article but could not solve the problem.
I tried Webhoo, App Extension, and etc. Finally I tried “Code” like below.
const order_id = inputDatat'orderid'];
const res = await fetch(
'https://YOUR-STORE-SUBDOMAIN.myshopify.com/admin/api/2023-10/orders/' + order_id + '.json?fields=line_items',
{
headers: { 'X-Shopify-Access-Token' : 'HERE IS YOUR API TOKEN' }
}
);
const json = await res.json();
let line_items = m];
for( const item of json.order.line_items ) {
let prop = '';
for( const p of item.properties ) {
prop += p.name + ': ' + p.value + "\n";
}
line_items.push({
product_id: item.product_id,
name: item.name,
prop: prop,
variant: item.variant_title
});
}
output = { line_items: line_items };
This code takes a Shopify order ID as input data, retrieves the data via the API, parses the line_items and converts it to the format it wants. It then sets it as output data.
The line_items key is used to handle the data as an array in Zapier. You can then use it in loops and so on.
Shopify API tokens can be obtained from the Shopify administration screen, in the settings and in the app development.
I'd be happy to help!