Closed cbetech closed 1 year ago
any update on this issue ? I am facing the same problem.
This problem happens here too
there is one mistake in the request:
you should firstly get the fulfillment_order_id then use it into create request.
const fulfillment_order = await shopify.order.fulfillmentOrders('Order ID goes here');
const _fulfillment_order_id = fulfillment_order[0].id;
var body = { location_id: data.location_id, tracking_number: data.tracking_number, tracking_company: data.tracking_company, notify_customer: true, order_id: data.order_id, line_items_by_fulfillment_order: [{ fulfillment_order_id: _fulfillment_order_id fulfillment_order_line_items: fulfillment_order[0].line_items || [] }] };
await shopify.fulfillment.createV2(body);
Here's what I have as a param for fulfillments.createV2 for API version 2023-01:
interface FulfillmentOrderTrackingInfo {
number?: string | number
url?: string | null
company?: string | null
}
interface FulfillmentOrderLineItem {
id: number
quantity: number
}
interface FulfillmentOrderLineItemsByFulfillmentOrder {
fulfillment_order_id: number
fulfillment_order_line_items: FulfillmentOrderLineItem[]
}
interface FulfillmentOrder {
message: string | null
notify_customer: boolean
tracking_info: FulfillmentOrderTrackingInfo
line_items_by_fulfillment_order: FulfillmentOrderLineItemsByFulfillmentOrder[]
}
// Example
const data: FulfillmentOrder = {}
await shopifyService.fulfillment.createV2(data)
Im still with the same error code: 'ERR_NON_2XX_3XX_RESPONSE',
const fullfilment = await currentShopify.connection.fulfillment.get(order_id)
const fullfillmentId = fullfilment[0].id
const objetoMapeado = {
id: fullfilment[0].line_items[0].id,
quantity: fullfilment[0].line_items[0].quantity
};
var body = {
notify_customer: true,
tracking_info: { number: "999999999", company: "ACS Courier" },
line_items_by_fulfillment_order: [
{
fulfillment_order_id: fullfillmentId,
fulfillment_order_line_items: objetoMapeado || [],
},
],
};
await currentShopify.connection.fulfillment.insert(body).then(function (response) {
res.json({ success: response.status })
}).catch(function (error) {
logger.error(error.statusMessage)
})
i have tried with objetoMapeado and also with fullfilment[0].line_items. I had also test with location_id and order_id on the body but still the same error.
this is my insert function:
insert: function(body) {
return shopify.fulfillment.createV2(body);
},
@genuinemx Not sure but there may be some syntax / code issues with the snippet you provided.
Can you try to do the following to see if it works? I think your body
object is valid so lets try to isolate.
const response = await shopify.fulfillment.createV2(body);
fulfillment: {
insert: async function(body) {
const response = await shopify.fulfillment.createV2(body);
return response
},
}
I tried as you say, still the same error @ikudosi
@genuinemx Can you verify you have the proper scopes enabled for this app to do fulfillments?
Also can you paste the full error? Only the code was provided.
@ikudosi the problem was that is not fullfilment[0].id in the cases when a product was fullfilled and then canceled, you need to grab the last line of the line_items where the status is Opened.
Now it works fine! Thanks
I've found the problem, my main problem was that I was testing with an order that i've been fulfilling and unfulfilling many times, so I was trying this
const fulfillment_order = await shopify.order.fulfillmentOrders('Order ID goes here');
const fulfillment_order_id = fulfillment_order[0].id;
instead, you need to get the fulfillment_order_id from the last element of the array returned from the order.fulfillmentOrders(id) function (the one with the status 'open')
const fulfillment_order = await shopify.order.fulfillmentOrders('Order ID goes here');
const fulfillment_order_id = fulfillment_order[fulfillment_order.length - 1].id;
const fulfillment_order_items = fulfillment_order[fulfillment_order.length - 1].line_items;
and then I used this code
var body = {
location_id: 'location id goes here',
order_id: 'order id goes here',
notify_customer: true,
tracking_info: { number: "999999999", company: "DHL Express" },
line_items_by_fulfillment_order: [
{
fulfillment_order_id: fulfillment_order_id,
fulfillment_order_line_items: fulfillment_order_items || []
}
]
};
const response = await shopify.fulfillment.createV2(body);
Hi, I'have been using the fulfillment.create for a while and eventually started giving me this error:
I tried using createV2 but the error still the same
I'm using node version 15.2.1 Shopify-api-node version latest
This is my code, I'm testing with a order with only one product