setting the quantity won’t do it. You have to remove the item entirely by setting it’s quantity to 0. So…
First, change the shipping address:
mutation orderUpdate($input: OrderInput!) {orderUpdate(input: $input) {order { email customer {id} } userErrors {field message}}}
{"input": {"id": "gid://shopify/Order/12345","shippingAddress":{"address1":"1234 Main Street","city":"Anytown","company":"","provinceCode":"CA","zip":"12345","countryCode":"US","firstName":"John","lastName":"Smith","phone":"+15555551234"}}}
Then, open the order for editing:
mutation {orderEditBegin(id: "gid://shopify/Order/1234") {calculatedOrder{id totalOutstandingSet{shopMoney{amount currencyCode}} shippingLines {id price {presentmentMoney {amount currencyCode} shopMoney {amount currencyCode} } title } lineItems(first:140){nodes{id quantity variant{id idProduct:metafield(key:""kp_idproduct"",namespace:""products""){value}} title sku discountedUnitPriceSet{presentmentMoney{amount}}editableQuantity variantTitle originalUnitPriceSet{presentmentMoney{amount}}calculatedDiscountAllocations{ discountApplication{allocationMethod, id, appliedTo}}}}} userErrors {field message}}}
Set all the line item quantities to 0:
mutation orderEditSetQuantity{orderEditSetQuantity(id: "
Re-add all the variants:
```markup
mutation addVariantToOrder{orderEditAddVariant(id: "gid://shopify/CalculatedOrder/
AllowDuplicates is important. It means, temporarily, you'll have a duplicate variant id in that order until you save it.
Remove the current shipping lines. If shipping is taxed, the current shipping needs to be removed and then re-added
For each shippingLine in shippingLines:
mutation {orderEditRemoveShippingLine(id: “<calculatedOrder.id>”, shippingLineId: “<shippingLine.id>”) {calculatedOrder {id shippingLines {id stagedStatus}} userErrors {field message code}}}
Add the new shipping line:
mutation {orderEditAddShippingLine(id: “<calculatedOrder.id>”, shippingLine: { title: “”, price: { amount: , currencyCode: USD }}) {calculatedOrder { id shippingLines {id stagedStatus title price {shopMoney {currencyCode amount}}}} userErrors {field message code}}}
Save the order:
mutation commitEdit{orderEditCommit(id:“<calculatedOrder.id>”,notifyCustomer:true,staffNote:“”){order{id totalOutstandingSet{shopMoney{amount currencyCode}} totalReceivedSet{shopMoney{amount currencyCode}} netPaymentSet{shopMoney{amount currencyCode}} lineItems(first:240){nodes{id quantity fulfillableQuantity title variant{id}}}} userErrors{field message}}}
Let me know if this all works for you.