Hi there,
As many of us I am migrating from the Rest API to Graphql Admin. I have two questions:
- When does the Rest API become fully unavailable?
- I am struggling with the discount part on orderCreate. In our use case we can’t use the checkout sheet, so we have our own custom checkout page. The flow is as follows:
- User uses the Cart API to add products, add discount, manage their address etc.
- User clicks on pay
- Cart Object is sent to my rails backend
- Cart Object is used to create the Order object for the orderCreate API
This all works, and I am able to create the order. However, it seems like automated discounts or discount codes are not being applied. Which is super frustrating.
This my gql request:
mutation OrderCreate($order: OrderCreateOrderInput!, $options: OrderCreateOptionsInput) {
orderCreate(order: $order, options: $options) {
userErrors {
field
message
}
order {
id
discountApplications(first:10) {
nodes {
value {
... on MoneyV2 {
currencyCode
amount
}
... on PricingPercentageValue {
percentage
}
}
... on DiscountCodeApplication {
code
}
}
}
currentSubtotalPriceSet {
presentmentMoney {
amount
currencyCode
}
shopMoney{
amount
currencyCode
}
}
totalTaxSet {
shopMoney {
amount
currencyCode
}
}
totalPriceSet {
shopMoney {
amount
currencyCode
}
}
currentTotalPriceSet {
shopMoney {
amount
currencyCode
}
}
lineItems(first: 5) {
nodes {
variant {
id
}
id
title
quantity
taxLines {
title
rate
priceSet {
shopMoney {
amount
currencyCode
}
}
}
}
}
}
}
}
Input:
{
"options": {
"inventoryBehaviour": "DECREMENT_OBEYING_POLICY"
},
"order": {
"email":"test@test.com",
"currency": "CNY",
"lineItems": [
{
"variantId": "gid://shopify/ProductVariant/46004283965731",
"quantity": 1
}
],
"discountCode": {
"itemFixedDiscountCode": {
"code": "product1234p"
}
},
"shippingAddress": {
"address1": "123 Test Street",
"address2": null,
"zip": "200040",
"city": "Shanghai",
"countryCode": "CN",
"provinceCode": "SH",
"phone": null,
"lastName": "Smith",
"firstName": "Mary"
},
"billingAddress": {
"address1": "123 Test Street",
"address2": null,
"zip": "M5T1G4",
"city": "Shanghai",
"countryCode": "CN",
"provinceCode": "SH",
"phone": null,
"lastName": "Smith",
"firstName": "Mary"
},
"note": "Waiting for pickup"
}
}
So basically my question comes down to, how does the automatic discount get applied and how do coupon codes apply?
In the REST API it was super easy, in GQL it sucks.