nozzlegear / ShopifySharp

ShopifySharp is a .NET library that helps developers easily authenticate with and manage Shopify stores.
https://nozzlegear.com/shopify-development-handbook
MIT License
747 stars 309 forks source link

Adding Multiple Tracking Numbers with Fulfillment.TrackingNumbers #1050

Open donaldrainwater opened 6 months ago

donaldrainwater commented 6 months ago

Hi, I hope you can help me. I am trying to find a code sample that shows how to add multiple tracking numbers to one Fulfillment Order in ShopifySharp. I cannot find the code to make this happen.

nozzlegear commented 6 months ago

Hey @donaldrainwater! I'm looking into this now, I'll update as soon as I can. Feel free to ping me if it seems like I've forgotten it.

mbaugus commented 5 months ago

@donaldrainwater I don't use ShopifySharp, but I checked the generated schema class with the fulfillment object against their documentation.

https://shopify.dev/docs/api/admin-graphql/2024-04/mutations/fulfillmentCreateV2?example=Fulfill+a+fulfillment+order+with+two+tracking+numbers+and+tracking+urls+from+different+tracking+tracking+providers

The documentation on the website is as-per-usual inconsistent and confusing.

In the API documentation, (you have to check the examples on the right side for the real expected input), it will expect a single trackingInfo object with an array of tracking numbers, but will convert this into an array of trackingInfo[] objects in the returned response.

the input for multiple tracking numbers according to their documentation

    "trackingInfo": {
      "company": "UPS",
      "numbers": [
        "1Z001985YW99744790",
        "1Z001985YW99744791"
      ]
    }

versus the response

      "trackingInfo": [
        {
          "company": "UPS",
          "number": "1Z001985YW99744790",
          "url": "https://www.ups.com/WebTracking?loc=en_US&requester=ST&trackNums=1Z001985YW99744790"
        },
        {
          "company": "UPS",
          "number": "1Z001985YW99744791",
          "url": "https://www.ups.com/WebTracking?loc=en_US&requester=ST&trackNums=1Z001985YW99744791"
        }
      ]

I've only ever fulfilled single tracking numbers, so you'll need to test if their provided example outline works,

I pasted it below.

mutation fulfillmentCreateV2($fulfillment: FulfillmentV2Input!) {
  fulfillmentCreateV2(fulfillment: $fulfillment) {
    fulfillment {
      id
      status
      trackingInfo(first: 10) {
        company
        number
        url
      }
    }
    userErrors {
      field
      message
    }
  }
}

variables
{
  "fulfillment": {
    "lineItemsByFulfillmentOrder": {
      "fulfillmentOrderId": "gid://shopify/FulfillmentOrder/940656279"
    },
    "trackingInfo": {
      "numbers": [
        "1Z001985YW99744790",
        "MS123"
      ],
      "urls": [
        "https://www.ups.com/WebTracking?loc=en_US&requester=ST&trackNums=1Z001985YW99744790",
        "http://shopify-unsupported-tracking-company.com?tracking_number=MS123"
      ]
    }
  }
}
timlaughlin commented 4 months ago

I am interested in this as well.

If I'm reading the most up to date information it seems that the GraphQL supports multiple tracking numbers for a fulfillment but the rest api doesn't? Is that still correct?

Any updates on this would be appreciated!