Inventory not updating after oder fulfilled

I have created bulk order using custom app with fulfilment with locationId and order is fulfilled and inventory is not updating what i need to do ???

here is my code

async function createBulkOrder(
  line_items,
  locationId,
  locationName,
  monthName,
  year
) {
  let lineItems = [];
  if (line_items.length > 0) {
    lineItems = line_items.map((item) => {
      return {
        variantId: item.variantId,
        quantity: item.quantity,
      };
    });
  }
  const mutation = `mutation OrderCreate($order: OrderCreateOrderInput!) {
    orderCreate(order: $order) {
      userErrors {
        field
        message
      }
      order {
        id
        lineItems(first: 150) {
          nodes {
            variant {
              id
            }
            id
            title
            quantity
          }
        }
      }
    }
  }`;
  const createdVariables = {
    order: {
      lineItems: lineItems,
fulfillment:{
locationId:`gid://shopify/Location/${locationId}`
},
      tags: [`${locationName}`, "auto-generated", `${monthName} ${year}`],
      note: `Auto-generated  order at ${locationName}. month: ${monthName} ${year}. location ID: ${locationId}`,
      test: false,
      currency: "GBP",
    },
  };
  try {
    const response = await shopify.graphql(mutation, createdVariables);
    return response.orderCreate.order;

    // Rest of the success handling logic
    // ...
  } catch (error) {
    console.error("Error creating order:", error.message);
    console.error("Error stack trace:", error.stack);

    // Extract any available error information
    if (error.body) {
      console.error(
        "Error body:",
        typeof error.body === "string"
          ? error.body
          : JSON.stringify(error.body, null, 2)
      );
    }

    if (error.statusCode) {
      console.error("Error status code:", error.statusCode);
    }

    if (error.statusMessage) {
      console.error("Error status message:", error.statusMessage);
    }

    if (error.headers) {
      console.error("Error headers:", error.headers);
    }

    // If there are GraphQL specific errors
    if (error.graphQLErrors) {
      console.error(
        "GraphQL Errors:",
        JSON.stringify(error.graphQLErrors, null, 2)
      );
    }

    // If there are network errors
    if (error.networkError) {
      console.error("Network Error:", error.networkError);
    }

    // Log the entire error object for inspection
    console.error("Full error object keys:", Object.keys(error));

    throw error; // Rethrow to handle it in higher-level code
  }
}

Hi Roman,

If you try the orderCreate mutation in the GraphiQL app are you still seeing the same effect? Also some things to look out for are:

  • Ensure that the inventory is properly managed at the location specified in your fulfillment.
  • If inventory is not updating correctly, you can use the inventoryAdjustQuantities mutation to manually adjust inventory levels.
  • Ensure that the locationId used in your fulfillment matches the location where inventory is being tracked. If the location is incorrect, inventory won’t update as expected.