Re: Set Order Line Item Properties with a Flow

Set Order Line Item Properties with a Flow

justin_cuyana
Visitor
2 0 0

Hi there!

 

We have products that have specific metadata like: "custom.isPreorder" : "true". We're looking to write that data to the order line item at some point before the transaction is submitted, so that it can be included in the Webhook to our ERP. Is there a way to do this via a Flow? We attempted to set an order tag with the the Order Transaction, but the webhook fires before the tag is set. Any ideas would be welcome!

Replies 2 (2)

PMike
Shopify Partner
134 12 22

Hi!

To write the specific metadata "custom.isPreorder" to the order line item before the transaction is submitted, you can utilize Shopify's Script Editor. This allows you to customize the checkout process and modify the order data.

Here's an approach you can consider:

1. Access the Script Editor in your Shopify admin.
2. Create a new script or edit an existing one.
3. In the script, use the `input.order.line_items` variable to access the line items in the order.
4. Iterate through the line items and check for the "custom.isPreorder" metadata.
5. If the metadata is present and matches your criteria, you can update the line item or add a new property to store the preorder information.
6. Once you've made the necessary modifications, the updated line item data will be included in the webhook payload sent to your ERP.

By using the Script Editor, you have more control over the order processing flow and can manipulate the order data before it's submitted.

Remember to test your script thoroughly to ensure it functions as expected and doesn't interfere with other aspects of your checkout process.

Fordeer Invoice Order Printer - The great tool for the best business!
https://link.fordeer.io/YZL4Ge
justin_cuyana
Visitor
2 0 0

Hi @PMike ! Thank you so much for your reply. I was hesitant to use the Script Editor approach since Shopify declared they were going to deprecate it (https://changelog.shopify.com/posts/shopify-scripts-deprecation); hence why I was trying to maximize Flow.

 

For the time being I was able to put into place a workaround. We're reading the product metadata when we Add To Cart, and will set a line item property that way. It's not perfect (because the SOT can change between add to cart and order submission) but it works for most instances.