We’re currently using a custom mutation to create orders in our headless Shopify storefront. Since we’re not using Shopify’s native payment gateway and instead integrating Razorpay, our flow is slightly different.
Current Flow:
- The user selects a product, and we add it to the cart using the Cart API.
- The user completes the payment using Razorpay.
- After the payment is confirmed, we create the order via the following GraphQL mutation:
export const createOrderMutation = `
mutation createOrder($order: OrderCreateOrderInput!, $options: OrderCreateOptionsInput) {
orderCreate(order: $order, options: $options) {
order {
id
name
email
createdAt
displayFulfillmentStatus
displayFinancialStatus
customAttributes {
key
value
}
totalPriceSet {
shopMoney {
amount
currencyCode
}
}
lineItems(first: 10) {
nodes {
id
name
quantity
variant {
id
title
product {
id
title
handle
}
}
}
}
shippingAddress {
firstName
lastName
address1
address2
city
province
country
zip
phone
}
billingAddress {
firstName
lastName
address1
address2
city
province
country
zip
phone
}
}
userErrors {
field
message
}
}
}
`
Issue:
We want to attach marketing metadata to the order — such as UTM source, campaign, medium, etc. However, we haven’t found a way to pass these through the orderCreate
mutation.
Question:
Is there a way to include marketing attributes (e.g., UTM parameters) in the orderCreate
mutation, perhaps using customAttributes
or another field? If not, is there an alternative method to associate such metadata with an order created programmatically outside of Shopify’s checkout flow?