ShopifySharp icon indicating copy to clipboard operation
ShopifySharp copied to clipboard

create fulfilment with trackingnumbers does not work

Open angelinos opened this issue 4 years ago • 13 comments

When creating a new fulfillment for an order if you specific fulfillment.trackingnumber it works (single tracking number), however when you use fulfillment.trackingnumbers for multiple tracking numbers it doesn't work. It doesn't give any errors, it just doesn't add the tracking numbers.

according to documentation this should work

https://shopify.dev/docs/admin-api/rest/reference/shipping-and-fulfillment/fulfillment#create-2020-01

***example from link above

Fulfill all line items for an order with multiple tracking numbers POST /admin/api/2020-01/orders/#{order_id}/fulfillments.json { "fulfillment": { "location_id": 905684977, "tracking_numbers": [ "8943339d604bb0c379465e3a8da3f9b7", "3e2c58466d6a63b897edad26a70eec1a", "1ff4458da2c5ed2f68a355d2b894309f" ], "line_items": [ { "id": 466157049 }, { "id": 518995019 }, { "id": 703073504 } ] } }

angelinos avatar Mar 28 '20 18:03 angelinos

I'm still trying to get it to work with a single tracking number, fulfillment gets created but carrier, tracking and notify_customer not populated.

I'm just throwing this out in case it helps you though:

[JsonProperty("tracking_numbers")] public IEnumerable TrackingNumbers { get; set; }

kdc415 avatar Apr 08 '20 21:04 kdc415

Thanks for the report! I've run into something similar in one of my own Shopify apps. I'll look into this and get it fixed soon.

nozzlegear avatar Apr 14 '20 21:04 nozzlegear

Okay, after some testing around I'm not able to reproduce this problem. Whether I use the single TrackingNumber or the list TrackingNumbers, both are always populated and will appear in the Shopify order dashboard too. You're not talking about the tracking URLs, are you? If that's the case, it's possible the TrackingUrls list and TrackingUrl string will be empty if Shopify doesn't recognize the shipping carrier, but the tracking numbers will still be populated.

nozzlegear avatar Apr 23 '20 20:04 nozzlegear

When I used single TrackingNumber it works, when I us the list TrackingNumbers it doesn't work (for the tracking #'s).

However TrackingUrl(s) didn't work for single or list for me, one of the shipping carriers we use is OnTrack, shopify doesn't recognize ontrack so we need to upload/push our own tracking url so that it works. However when we check in Shopify it uses another carriers tracking links (I believe dhl or another). However I'm not sure it's because it's not getting uploaded or shopify is force filling it's on url. But what is the purpose of pushing the url if shopify will override it regardless? Doesn't make sense..

angelinos avatar Apr 23 '20 20:04 angelinos

I think the behavior is confusing, but I was just reading the docs for this and I think this will clear it up:

About tracking urls

If you're creating a fulfillment for a supported carrier, then you can send the tracking_company and tracking_numbers fields, and Shopify will generate the tracking_url for you. If you're creating a fulfillment for an unsupported carrier (not in the tracking_company list), then send the tracking_company, tracking_numbers, and tracking_urls fields.

Note

If you send an unsupported carrier without a tracking URL, then Shopify will still try to generate a valid tracking URL by using pattern matching on the tracking number.

So they're probably seeing your OnTrack tracking numbers and it happens to match the pattern of another carrier they do support, so they override it. If you add the TrackingCompany alongside TrackingUrls and TrackingNumbers, it should leave your URLs/numbers alone and just use what you give it.

nozzlegear avatar Apr 23 '20 20:04 nozzlegear

Thanks for clearing it up, I will try to add the TrackingCompany and see if that makes a difference and report back.

angelinos avatar Apr 23 '20 21:04 angelinos

Also i'm running version 5.0.4 if that makes any difference? I will updated to the latest release.

angelinos avatar Apr 23 '20 21:04 angelinos

As long as you're on v5 or above it should work. Let me know how it goes!

nozzlegear avatar Apr 23 '20 21:04 nozzlegear

I just checked my code, actually I am passing TrackingCompany.

angelinos avatar Apr 23 '20 21:04 angelinos

Shoot, okay. Are you able to paste some code so I can try to reproduce the problem? And can you clarify what exactly isn't happening as expected -- the tracking numbers aren't showing up in the order dashboard; or the tracking numbers are null/empty on the fulfillment object after creating; or they're null/empty on the fulfillment object when you use GetAsync/ListAsync, etc.

nozzlegear avatar Apr 23 '20 21:04 nozzlegear

So I ran it through fiddler to see what's sent & received from shopify when creating the order using OrderService.CreateAsync(), here are the results. Seems like the proper information is being sent, so is shopify overriding the tracking_url regardless of what I'm telling it to use?

The tracking_url we are pushing is "https://www.ontrac.com/tracking.asp?trackingres=submit&tracking_number=D10011574176650" but the response comes back with "https://trackmyitem.whistl.co.uk/tracking/D10011574176650"

here is the request "fulfillments": [ { "location_id": 16473063487, "notify_customer": false, "tracking_company": "OnTrac", "tracking_number": "D10011574176650", "tracking_url": "https://www.ontrac.com/tracking.asp?trackingres=submit&tracking_number=D10011574176650" }

here is the response "fulfillments": [ { "id": 2040711413823, "order_id": 2176468385855, "status": "success", "created_at": "2020-04-23T14:37:28-07:00", "service": "manual", "updated_at": "2020-04-23T14:37:28-07:00", "tracking_company": "OnTrac", "shipment_status": null, "location_id": 16473063487, "line_items": [ { "id": 4751269625919, "variant_id": 31928827281471, "title": "Delivery Package", "quantity": 1, "sku": "082", "variant_title": "2 boxes", "vendor": "Coffee", "fulfillment_service": "manual", "product_id": 4510420500543, "requires_shipping": true, "taxable": false, "gift_card": false, "name": "Delivery Package - 2 boxes", "variant_inventory_management": null, "properties": [], "product_exists": true, "fulfillable_quantity": 0, "grams": 0, "price": "24.95", "total_discount": "0.00", "fulfillment_status": "fulfilled", "price_set": { "shop_money": { "amount": "24.95", "currency_code": "USD" }, "presentment_money": { "amount": "24.95", "currency_code": "USD" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "USD" }, "presentment_money": { "amount": "0.00", "currency_code": "USD" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/4751269625919", "tax_lines": [] }, { "id": 4751269658687, "variant_id": 14858075144255, "title": "Breakfast Blend", "quantity": 1, "sku": "813", "variant_title": null, "vendor": "Coffee", "fulfillment_service": "manual", "product_id": 1823021334591, "requires_shipping": true, "taxable": false, "gift_card": false, "name": "Breakfast Blend", "variant_inventory_management": null, "properties": [], "product_exists": true, "fulfillable_quantity": 0, "grams": 0, "price": "0.00", "total_discount": "0.00", "fulfillment_status": "fulfilled", "price_set": { "shop_money": { "amount": "0.00", "currency_code": "USD" }, "presentment_money": { "amount": "0.00", "currency_code": "USD" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "USD" }, "presentment_money": { "amount": "0.00", "currency_code": "USD" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/4751269658687", "tax_lines": [] }, { "id": 4751269691455, "variant_id": 14858074062911, "title": "Colombian Nariño", "quantity": 1, "sku": "814", "variant_title": null, "vendor": "Coffee", "fulfillment_service": "manual", "product_id": 1823021072447, "requires_shipping": true, "taxable": false, "gift_card": false, "name": "Colombian Nariño", "variant_inventory_management": null, "properties": [], "product_exists": true, "fulfillable_quantity": 0, "grams": 0, "price": "0.00", "total_discount": "0.00", "fulfillment_status": "fulfilled", "price_set": { "shop_money": { "amount": "0.00", "currency_code": "USD" }, "presentment_money": { "amount": "0.00", "currency_code": "USD" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "USD" }, "presentment_money": { "amount": "0.00", "currency_code": "USD" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/4751269691455", "tax_lines": [] } ], "tracking_number": "D10011574176650", "tracking_numbers": [ "D10011574176650" ], "tracking_url": "https://trackmyitem.whistl.co.uk/tracking/D10011574176650", "tracking_urls": [ "https://trackmyitem.whistl.co.uk/tracking/D10011574176650" ], "receipt": {}, "name": "2265013.1", "admin_graphql_api_id": "gid://shopify/Fulfillment/2040711413823" }

angelinos avatar Apr 23 '20 21:04 angelinos

So this is what I found

If I call OrderService.CreateAsync() to create the order and fulfillment in one shot I get the above behavior were it is overriding my tracking_url.

However if I call OrderService.CreateAsync() to only create the order and then call FulfillmentService.CreateAsync() to fulfill the order it works properly and retains the tracking_url I pass.

My conclusion is that this is a Shopify issue, do you concur?

angelinos avatar Apr 23 '20 22:04 angelinos

I think I agree, that behavior sounds incorrect. I guess at this point I'd suggest reaching out to the Shopify support to see what they have to say about the situation.

nozzlegear avatar Apr 24 '20 13:04 nozzlegear