Skip to main content

orderAddDiscount Mutation

Description

Adds a discount or credit note to an order.

mutation orderAddDiscount(
$orderRef: ID!
$type: String!
$value: Float
$amount: Float
$creditNoteRef: ID
) {
orderAddDiscount(
orderRef: $orderRef
type: $type
value: $value
amount: $amount
creditNoteRef: $creditNoteRef
) {
_id
id
incId
origin
created
modified
shipping {
status
fulfilled
date
method
freeShippingThreshold
tracking
shopCollection
weight
packingSlip
}
billing {
status
fulfilled
paymentDate
refundDate
}
orderId
notes {
date
content
}
instructions
totals {
subtotal
subtotalBeforeTaxes
tax
grand
leftToPay
itemQuantity
discount
shipping
creditNote
balance
}
items {
_id
quantity
unavailable
added
}
messages {
_id
created
subject
message
fromBuyer
flagged
content
read
orderId
orderIncId
uri
via
}
buyer {
_id
firstName
lastName
email
name
path
telephone
organisation
taxNumber
}
logs {
action
description
date
ip
}
seller {
type
name
email
ref
}
updated
status
discogsStatus
buyerWasContacted
unreadMessagesCount
mergeableOrders {
_id
id
created
total
description
}
path
}
}

Variables

{
"orderRef": "809b7424e65fc10b8a9ca959",
"type": "type",
"value": 30.7,
"amount": 29.99,
"creditNoteRef": "845ed3f6ed6b81b40c099c90"
}

Response

{
"orderAddDiscount": {
"_id": "01c4bff32393795d3098925a",
"id": "example",
"incId": 42,
"origin": "example",
"created": 1769426950482,
"modified": 1746259165172,
"shipping": {
"status": "Pending",
"fulfilled": true,
"date": 1765466070104,
"method": "example",
"freeShippingThreshold": 1.23,
"tracking": "example",
"shopCollection": true,
"weight": 1.23,
"packingSlip": "example"
},
"billing": {
"status": "example",
"fulfilled": true,
"paymentDate": 1757795860196,
"refundDate": 1758408733315
},
"orderId": "example",
"notes": [
{
"date": 1749445133904,
"content": "example"
}
],
"instructions": "example",
"totals": {
"subtotal": 1.23,
"subtotalBeforeTaxes": 1.23,
"tax": 1.23,
"grand": 1.23,
"leftToPay": 1.23,
"itemQuantity": 1.23,
"discount": 0.1,
"shipping": 1.23,
"creditNote": 1.23,
"balance": 1.23
},
"items": [
{
"_id": "277ab4e2696ff948037d0f04",
"quantity": 1,
"unavailable": true,
"added": 1743897145201
}
],
"messages": [
{
"_id": "4fcb178024404682e1a39f39",
"created": 1759035823205,
"subject": "example",
"message": "example",
"fromBuyer": true,
"flagged": true,
"content": "example",
"read": true,
"orderId": "example",
"orderIncId": 42,
"uri": "https://www.my-common-ground-store.com/release/1763553751/release-artist-release-name",
"via": "example"
}
],
"buyer": {
"_id": "b99f2400c8275b6edab9f0c0",
"firstName": "example",
"lastName": "example",
"email": "email@example.com",
"name": "example",
"path": "/release/1763553751/release-artist-release-name",
"telephone": "example",
"organisation": "example",
"taxNumber": "example"
},
"logs": [
{
"action": "example",
"description": "example",
"date": 1757254659721,
"ip": "example"
}
],
"seller": {
"type": "example",
"name": "example",
"email": "email@example.com",
"ref": "1ab6f40c84c1a8b0cc29e285"
},
"updated": 1745216866326,
"status": "example",
"discogsStatus": "example",
"buyerWasContacted": true,
"unreadMessagesCount": 42,
"mergeableOrders": [
{
"_id": "ee1b6d6a44f61a2d20955666",
"id": "example",
"created": 1726720796880,
"total": 29.99,
"description": "example"
}
],
"path": "/release/1763553751/release-artist-release-name"
}
}

Arguments

NameTypeDescription
orderRefID!Reference ID of the order.
typeString!Type of discount (e.g. "discount", "creditNote").
valueFloatDiscount value (percentage or amount, depending on type).
amountFloatAmount to apply, used for credit notes.
creditNoteRefIDReference ID of the credit note to apply, when adding a credit note discount.

Returns

Order!