Updating Order Line Item

Updating Order Line Item

SayMoo
Shopify Partner
4 0 2

Hi, wonder if anyone can help.

I can update Order Custom Attributes, but I'm stuck on line items.

In the orders screen I have

 

SayMoo_0-1743719194756.png

 

I can update 1, but not 2.

In 1 I am using 
Send Admin API request
orderUpdate

{
	"input": {
  "id": "gid://shopify/Order/116544546654200",
		"customAttributes": [
			{
				"key": "Essences",
				"value": "Apple, Walnut, Peach"
			}
		]
	}
}

This works on 1.

I have tried adding after the ID, the following
 "lineItemId": "gid://shopify/LineItem/348823433194936",

But I get the following error

Mutation had errors: "Variable $input of type OrderInput! was provided invalid value for lineItemId (Field is not defined on OrderInput)"

 

What is it I am missing?

Is there any good tutorials on the basic of using Flow for this type adjustment.

 

kind regards

 

 

Replies 2 (2)

Maxleontech
Tourist
7 0 1

You can’t update line item properties in an existing order using the Admin API. Shopify only allows order-level updates.

 

Workarounds

 

FirstlyUse Draft Orders – Edit before checkout.

Then,Refund & Recreate – Only way to fully change line items.

Also Use Metafields – Store extra info instead of editing the line item.

 

Let me know if you need help with a workaround 

SayMoo
Shopify Partner
4 0 2

That is a bit of a bummer.

1. FirstlyUse Draft Orders – Edit before checkout.
This is for Shopify subscription orders, so if they want to edit their line items for next time, by the admin able to edit the order line items I thought it'd be able to edit it for next subscription run. I really don't fancy recreating the order as a draft, etc

 

2. Also Use Metafields

This would probs take a bit rebuild, it was built in Shopify 1 a few years ago and doesn't use the standard basket. It is a custom build a box, so people can add different attributes (upto 7) to a single order and then checkout.
These are added to a Orders Line Items Custom Attributes.

eg:

 if (Shopify.queue.length) {
                    var request = Shopify.queue.shift();
                    var data = {};
                    if (request.properties) {
                        data = {
                            id: request.variantId,
                            quantity: request.quantity,
                            selling_plan: choosenFrequency,
                            properties: {
                                Essences: essenceString,
                                Price: '£' + boxPrice.toFixed(2),
                                'Base': choosenBase
                            }
                        };

So would need to rebuild
It originally came from:

https://www.slicedbread.agency/blogs/shopify/how-to-develop-a-build-a-box-product-in-shopify
But now customer is investigating Subscriptions and this type of custom basket is not the most compatible if you want to edit subscriptions