Order Created using GraphQL Api are marked as Shipping not Required

Hi,

I am creating order using orderCreate - GraphQL Admin API, I am passing Billing address, Shipping address, Line items and discountcode in input variable. Order gets created but its marked as Shipping not required.

Below is my input variables

  order = new
  {
      email = request.OrderRequest.Email,
      lineItems = request.OrderRequest.Items.Select(item => new
      {
          quantity = (int)item.Quantity,
          variantId = "gid://shopify/ProductVariant/" + item.VariantId,
          
      }).ToList(),
      billingAddress = new
      {
          firstName = request.OrderRequest.BillingAddress.Firstname,
          lastName = request.OrderRequest.BillingAddress.Lastname,
          address1 = request.OrderRequest.BillingAddress.Address1,
          city = request.OrderRequest.BillingAddress.City,
          province = request.OrderRequest.BillingAddress.Province,
          country = request.OrderRequest.BillingAddress.Country,
          zip = request.OrderRequest.BillingAddress.Zip
      },
      shippingAddress = new
      {
          firstName = request.OrderRequest.ShippingAddress.Firstname,
          lastName = request.OrderRequest.ShippingAddress.Lastname,
          address1 = request.OrderRequest.ShippingAddress.Address1,
          city = request.OrderRequest.ShippingAddress.City,
          province = request.OrderRequest.ShippingAddress.Province,
          country = request.OrderRequest.ShippingAddress.Country,
          zip = request.OrderRequest.ShippingAddress.Zip
      },
      note = request.OrderRequest.Note,
      tags = request.OrderRequest.Tags.Split(",").ToList(),
      discountCode = request.OrderRequest.DiscountCodes.Count > 0 ? new
      {
          itemPercentageDiscountCode = request.OrderRequest.DiscountCodes.Any(x => x.Type == "percentage") ? new
          {
              code = request.OrderRequest.DiscountCodes.FirstOrDefault(x => x.Type == "percentage")?.Code,
              percentage = HelperFunctions.ParseDecimal(request.OrderRequest.DiscountCodes.FirstOrDefault(x => x.Type == "percentage")?.Amount)
          } : null
      } : null
  }

please help me what I am missing to remove this shipping not required

Have you ensured the product is marked as a physical product?

yes its their inside product variant.

Hi @Maulik_Shah_RAB! This is a common gotcha when using the GraphQL orderCreate mutation.

The requiresShipping field on line items defaults to false in GraphQL, which is different from the REST API where it defaulted to true. Even though your product variant has “This is a physical product” checked, that setting isn’t automatically inherited when creating orders via orderCreate - you need to explicitly set it.

Add requiresShipping: true to each line item in your mutation variables:

{
  "order": {
    "lineItems": [
      {
        "variantId": "gid://shopify/ProductVariant/123456",
        "quantity": 1,
        "requiresShipping": true
      }
    ]
  }
}

That should sort, it but if the issue persists after making the above change, please share an x-request-id from the response header of an affected call and I’ll be happy to have a look in our logs!

You are great. Thanks its worked.

2 Likes