Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Re: Help with Changing Order Status from Unfulfilled to Fulfilled via API

Solved

Help with Changing Order Status from Unfulfilled to Fulfilled via API

raulvaquerizo
Shopify Partner
13 3 5

Hello Shopify community,

I hope you're all doing well. I'm currently working on an integration and facing challenges changing the order status of Shopify orders from "Unfulfilled" to "Fulfilled" using the Shopify API with node.js. I've referred to the API documentation and am seeking additional guidance as I'm encountering issues with my approach.

Here is my current approach:

  1. I make a POST request to /admin/api/2024-01/orders/{order_id}/fulfillments.json.
  2. In the request body, I include:
const fulfillmentData = {
  message: null,
  notify_customer: true,
  tracking_info: {
    number: trackingNumber,
    url: `https://company/EU/en/parcel-tracking?match=${trackingNumber}`,
    company: "company"
  },
  line_items: currentOrder.line_items.map(lineItem => ({
    id: lineItem.id,
    quantity: lineItem.quantity,
  })),
  location_id: locationId
};

However, I'm receiving error responses, specifically:

Request failed with status code 400 { errors: { fulfillment: 'Required parameter missing or invalid' } }
 

I would greatly appreciate any guidance, code examples, or additional details that can help me resolve this issue.

 

Thank you in advance!

Accepted Solution (1)

raulvaquerizo
Shopify Partner
13 3 5

This is an accepted solution.

Solution:

 

The solution that finally worked for me was using the shopify-api-node library. Here is the code that resolved my issue:

 

 

 

const fulfillmentDetails = await shopify.order.fulfillmentOrders(orderId);
const fulfillmentOrderId = fulfillmentDetails[0].id;
const fulfillmentLineitemIds = fulfillmentDetails[0].line_items.map(item => ({
    id: item.id,
    quantity: item.quantity
}));

const updateParams = {
    line_items_by_fulfillment_order: [
        {
            fulfillment_order_id: fulfillmentOrderId,
            fulfillment_order_line_items: fulfillmentLineitemIds
        }
    ],
    tracking_info: {
        number: trackingNumber,
        url: `https://company.eu/EU/en/parcel-tracking?match=${trackingNumber}`,
        company: 'company'
    },
    notify_customer: true,
    origin_address: null,
    message: 'Delivery status: ' + trackingNumber
};

const updateFulfillment = await shopify.fulfillment.createV2(updateParams);

 

I hope this proves helpful for those who may encounter a similar issue. Thanks to the community for the support!

Best regards!

View solution in original post

Replies 3 (3)

raulvaquerizo
Shopify Partner
13 3 5

This is an accepted solution.

Solution:

 

The solution that finally worked for me was using the shopify-api-node library. Here is the code that resolved my issue:

 

 

 

const fulfillmentDetails = await shopify.order.fulfillmentOrders(orderId);
const fulfillmentOrderId = fulfillmentDetails[0].id;
const fulfillmentLineitemIds = fulfillmentDetails[0].line_items.map(item => ({
    id: item.id,
    quantity: item.quantity
}));

const updateParams = {
    line_items_by_fulfillment_order: [
        {
            fulfillment_order_id: fulfillmentOrderId,
            fulfillment_order_line_items: fulfillmentLineitemIds
        }
    ],
    tracking_info: {
        number: trackingNumber,
        url: `https://company.eu/EU/en/parcel-tracking?match=${trackingNumber}`,
        company: 'company'
    },
    notify_customer: true,
    origin_address: null,
    message: 'Delivery status: ' + trackingNumber
};

const updateFulfillment = await shopify.fulfillment.createV2(updateParams);

 

I hope this proves helpful for those who may encounter a similar issue. Thanks to the community for the support!

Best regards!

kcram6
Shopify Partner
1 0 0

I was stuck on the same thing. Thanks so much!!

simochouchoudan
Tourist
11 0 1

Hi everyone, Im looking for the same solution using python. yesterday i received an order and im supposed to send the data ( tracking number and company name to the shopify store ) can anyone please help me and share with me how to do this using python