Open dkrefta opened 1 year ago
Hi, you should check completedAt
value on the checkout. It's empty when the checkout is not completed.
I'm using this api. I can't complete the checkout after creating it. and I can't add the shippingLine either.
@nelson3design As far as I know, checkout is completed by customer/user from the checkoutUrl provided by response.
As for updating shippingLine, I believe this could help you?
Thanks, I can't add shippingLine or shippingRates. can you help me please
How are you trying to do this?
How are you trying to do this?
const updatedCheckout = await client.checkout.updateShippingLine(checkoutId, addShippinLine);
How are you trying to do this?
const updatedCheckout = await client.checkout.updateShippingLine(checkoutId, addShippinLine);
if you have an example of how to do it can you send it to me.thanks
Could this be what you need? Link
I would require more context in order to help you. Maybe send me the "addShippinLine" object so I can see
Could this be what you need? Link
I would require more context in order to help you. Maybe send me the "addShippinLine" object so I can see
const checkoutId = "gid://shopify/Checkout/e44ba7f7e9ee1d7b301f2629325ad11e?key=f8eb10b327d6df6d69571feba95b41f0";
const addShippingLineToCheckout = async (checkoutId, shippingRateHandle) => {
try {
const response = await shopify.graphql({
query: `
mutation ($checkoutId: ID!, $shippingRateHandle: String!) {
checkoutShippingLineUpdate(checkoutId: $checkoutId, shippingRateHandle: $shippingRateHandle) {
checkout {
# Campos do checkout
}
checkoutUserErrors {
# Campos do CheckoutUserError
}
}
}
`,
variables: {
checkoutId: checkoutId,
shippingRateHandle: shippingRateHandle,
},
});
console.log('Shipping line added to checkout:', response.checkoutShippingLineUpdate.checkout);
} catch (error) {
console.error('Error adding shipping line to checkout:', error);
}
};
const shippingRateHandle = '724847198506';
addShippingLineToCheckout(checkoutId, shippingRateHandle);
Could this be what you need? Link I would require more context in order to help you. Maybe send me the "addShippinLine" object so I can see
const checkoutId = "gid://shopify/Checkout/e44ba7f7e9ee1d7b301f2629325ad11e?key=f8eb10b327d6df6d69571feba95b41f0";
const addShippingLineToCheckout = async (checkoutId, shippingRateHandle) => { try { const response = await shopify.graphql({ query: ` mutation ($checkoutId: ID!, $shippingRateHandle: String!) { checkoutShippingLineUpdate(checkoutId: $checkoutId, shippingRateHandle: $shippingRateHandle) { checkout { # Campos do checkout } checkoutUserErrors { # Campos do CheckoutUserError } } } `, variables: { checkoutId: checkoutId, shippingRateHandle: shippingRateHandle, }, }); console.log('Shipping line added to checkout:', response.checkoutShippingLineUpdate.checkout); } catch (error) { console.error('Error adding shipping line to checkout:', error); } }; const shippingRateHandle = '724847198506'; addShippingLineToCheckout(checkoutId, shippingRateHandle);
shippingRates= "weight_based_shipping_rates": [], "price_based_shipping_rates": [ { "id": 724847165738, "name": "Frete", "price": "100.00", "shipping_zone_id": 471171727658, "min_order_subtotal": "1.0", "max_order_subtotal": "99.9" }, { "id": 724847198506, "name": "Frete", "price": "200.00", "shipping_zone_id": 471171727658, "min_order_subtotal": "100.0", "max_order_subtotal": "500.0" }, { "id": 724847231274, "name": "Frete", "price": "300.00", "shipping_zone_id": 471171727658, "min_order_subtotal": "101.0", "max_order_subtotal": "1000.0" } ], "carrier_shipping_rate_providers": [] } ]
Could this be what you need? Link I would require more context in order to help you. Maybe send me the "addShippinLine" object so I can see
const checkoutId = "gid://shopify/Checkout/e44ba7f7e9ee1d7b301f2629325ad11e?key=f8eb10b327d6df6d69571feba95b41f0";
const addShippingLineToCheckout = async (checkoutId, shippingRateHandle) => { try { const response = await shopify.graphql({ query: ` mutation ($checkoutId: ID!, $shippingRateHandle: String!) { checkoutShippingLineUpdate(checkoutId: $checkoutId, shippingRateHandle: $shippingRateHandle) { checkout { # Campos do checkout } checkoutUserErrors { # Campos do CheckoutUserError } } } `, variables: { checkoutId: checkoutId, shippingRateHandle: shippingRateHandle, }, }); console.log('Shipping line added to checkout:', response.checkoutShippingLineUpdate.checkout); } catch (error) { console.error('Error adding shipping line to checkout:', error); } }; const shippingRateHandle = '724847198506'; addShippingLineToCheckout(checkoutId, shippingRateHandle);
shippingRates= "weight_based_shipping_rates": [], "price_based_shipping_rates": [ { "id": 724847165738, "name": "Frete", "price": "100.00", "shipping_zone_id": 471171727658, "min_order_subtotal": "1.0", "max_order_subtotal": "99.9" }, { "id": 724847198506, "name": "Frete", "price": "200.00", "shipping_zone_id": 471171727658, "min_order_subtotal": "100.0", "max_order_subtotal": "500.0" }, { "id": 724847231274, "name": "Frete", "price": "300.00", "shipping_zone_id": 471171727658, "min_order_subtotal": "101.0", "max_order_subtotal": "1000.0" } ], "carrier_shipping_rate_providers": [] } ]
gave this error: Error adding shipping line to checkout: RequestError: The body
option must be a stream.Readable, string or Buffer
Your shippingRateHandle should be a "handle" not a number. Please see the type here
Your shippingRateHandle should be a "handle" not a number. Please see the type here thank you, I'm trying to create a checkout, I got this error, do you know what the reason is
mutation checkoutCreate($input: CheckoutCreateInput!) { checkoutCreate(input: $input) { checkout { id } checkoutUserErrors { code field message } } } { "input": { "lineItems": [ { "variantId": "gid://shopify/ProductVariant/45318806241578", "quantity": 1 } ] } }
{ "errors": [ { "message": "syntax error, unexpected STRING (\"input\") at [14, 3]", "locations": [ { "line": 14, "column": 3 } ] } ] }
this way doesn't work either
mutation { checkoutCreate(input: { lineItems: [{ variantId: "gid://shopify/ProductVariant/45318806241578", quantity: 1 }] }) { checkout { id webUrl lineItems(first: 1) { edges { node { title quantity } } } } } }
{ "errors": [ { "message": "Field 'checkoutCreate' doesn't exist on type 'Mutation'", "locations": [ { "line": 2, "column": 3 } ], "path": [ "mutation", "checkoutCreate" ], "extensions": { "code": "undefinedField", "typeName": "Mutation", "fieldName": "checkoutCreate" } } ] }
Hey guys, I'm having some problems with the checkout when it's completed, [{"message":"Checkout is already completed.","locations":[{"line":1,"column":1417}],"path":["checkoutLineItemsRemove"]}]
which function to check if the checkout is already done? can somebody help me with that?
Here is my store code:
thanks!