GraphQL Remove a discount from a variant

Hi All,

I am struggling to find the discountApplicationId to be able to run the following in graphQL:

mutation removeDiscount {
orderEditRemoveLineItemDiscount(id: “gid://shopify/CalculatedOrder/5678”, discountApplicationId: “gid://shopify/CalculatedDiscountApplication/134243”) {
userErrors {
field
message
}
}
}

Can someone please point me in the right direction, where can I find the existing line_item applied discount discountApplicationId ?

Kind Regards,

Brenden Draper

Hey @bdraper ,

I assume you are following out tutorial on how to Edit an existing order with GraphQL Admin API, and if that is the case, I can see that it does not clearly show where the discountApplicationId when removing a discount from a line item would be found.

I will add a note for our team to look at updating the tutorial to include an example of how that value would be retrieved, but while editing orders I would recommend either :

Here’s an example of an addDiscount mutation from that tutorial that would return the discountApplicationId values both ways to give you an idea of what I mean:

mutation addDiscount {
	orderEditAddLineItemDiscount(
		id: "gid://shopify/CalculatedOrder/123456"
		lineItemId: "gid://shopify/CalculatedLineItem/987654321"
		discount: { percentValue: 25, description: "Discount" }
	) {
		calculatedOrder {
			id
			addedLineItems(first: 5) {
				edges {
					node {
						id
						title
						quantity
						calculatedDiscountAllocations {
							discountApplication {
								id
								description
							}
						}
					}
				}
			}
			addedDiscountApplications(first: 5) {
				edges {
					node {
						id
						description
					}
				}
			}
		}
		userErrors {
			field
			message
		}
	}
}

Hi James,

Thanks so much for the feedback. I will try out the above mentioned and let you know.

Kind Regards,

Brenden Draper

Hi James,

I noticed that the above mentioned works to remove discount from the calculated order, but is it possible to remove existing discounts of existing items on the order ?

Kind Regards,

Brenden Draper

Hey Brendan,

All of the mutations in that tutorial are meant to add or remove line item discounts for new line items.

The admin API does not currently support removing discounts from an existing order’s line items, but I will add a feature request on your behalf.

Great thanks James,

Kind Regards,

Brenden Draper

Hi everyone my apologies for taking so long to reply but Ive been a one man
show trying to get this rolled out for useb Now I’m trying to build this
app so the partners or admin would be able to expand all check out options
for customers I am new at developing and I would greatly appreciate any
input from the community to get it done the correct way

Hi James, how about having this error?
“message”: “Only items added during the current edit may be discounted.”