I am trying to create an order with the code below. Only the customer’s first and last name are populated, but the shipping and billing addresses are not. Even when I try to pass them directly, as shown in the commented-out portion of the code, they still do not appear in the created order. Why is this happening?
const query = {
query: `
mutation OrderCreate($order: OrderCreateOrderInput!, $options: OrderCreateOptionsInput) {
orderCreate(order: $order, options: $options) {
order {
id
}
userErrors {
field
message
}
}
}
`,
variables: {
order: {
name: orderName,
email: payload.email,
currency: payload.currency,
tags: "Child",
presentmentCurrency: payload.line_items[0].price_set.presentment_money.currency_code,
currency: payload.line_items[0].price_set.shop_money.currency_code,
customer: {
toAssociate: {
id: payload.customer.admin_graphql_api_id
}
},
// shippingAddress: {
// firstName: payload.shipping_address.first_name,
// lastName: payload.shipping_address.last_name,
// address1: payload.shipping_address.address1,
// phone: payload.shipping_address.phone,
// city: payload.shipping_address.city,
// zip: payload.shipping_address.zip,
// countryCode: payload.shipping_address.country_code,
// provinceCode: payload.shipping_address.province_code
// },
// billingAddress: {
// firstName: payload.billing_address.first_name,
// lastName: payload.billing_address.last_name,
// address1: payload.billing_address.address1,
// phone: payload.billing_address.phone,
// city: payload.billing_address.city,
// zip: payload.billing_address.zip,
// countryCode: payload.billing_address.country_code,
// provinceCode: payload.billing_address.province_code
// },
lineItems: lineItems
}
}
};