Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating Fulfillments #142

Closed
dlazar opened this issue Aug 7, 2014 · 25 comments
Closed

Updating Fulfillments #142

dlazar opened this issue Aug 7, 2014 · 25 comments

Comments

@dlazar
Copy link

dlazar commented Aug 7, 2014

Hi,

I have a cycle to complete. Merchant is fulfilling orders using a custom fulfillment service. The act of fulfilling triggers a webhook to the fulfillment centre where they take some time to fulfill and generate a tracking number.

I need to update the existing fulfillment to reflect the tracking number and quantities actually fulfilled.

There is no way to do this with the API gem code? How does one update existing fulfillments?

@kevinhughes27
Copy link
Contributor

Did you register a Fulfillment Service? If you did then the service can manage inventory and we'll fetch the updated quantities every hour. For the tracking numbers after your service has marked the fulfillment as complete we'll contact the service every hour for a week until we get tracking numbers.

Otherwise if you aren't using the Fulfillment Service API (or even if you are) you can make PUT requests to the fulfillment endpoint and update the fulfillment manually. Would this work or is there a problem with the gem code to actually do this?

@resistorsoftware
Copy link

Hi,

I figured out the Fulfillment Service this morning. I installed one, and it showed up in the merchants fulfillment dropdown. That is all good. I made the endpoint needed and am just waiting for the merchant to test that out.

In the meantime, I do not see any way the current Gem can update a fulfillment. That leaves a big hole in it. And with the Fulfillment Service polling I still see another problem. You poll once an hour and provide an order ID. I can reply with a tracking number. But very often the fulfillment company is providing a Shopify OrderID, and more specifically, they provide a tracking number WITH a line item ID and a quantity. It seems there is no capacity to match at this time. I can only provide a gross answer of this Order has a tracking number. And what about more than one? Does the polling by Shopify gobble up an answer like {"123456789": ["TZR1234455", "YTR613647734"]} or does that kill it?

@kevinhughes27
Copy link
Contributor

You should be able to use the Fulfillment object in the gem to make a PUT request, it won't show the methods because they are all inherited from active resource. Let us know if you are able to get that working.

@resistorsoftware
Copy link

I did this.

f = ShopifyAPI::Fulfillment.first(params: {order_id: 111, id: 222}) 

That gave me a fulfillment object. I set the tracking number via

f.tracking_number = "abcfoobizzbaz"
f.save

That is an update. Unfortunately it did nothing... I notice there was an array attribute tracking_numbers, but I did not set that. Setting notify_customer=true did work and sent a notification with no tracking number... so I stopped there... what do you advise for this?

@kevinhughes27
Copy link
Contributor

yes we deprecated tracking number in favour of tracking_numbers I am not sure 100% why right now and I think we still haven't fully deprecated it. Sorry for the confusion, just set your tracking number as the only element of the array

@resistorsoftware
Copy link

Ok.. will do. Thanks. Is there an answer to the question of how you deal with partial fulfillments?

If I get a tracking number for line item ####### and a quantity of 2, when the original order was fulfilled by the merchant... will that update somehow allow me to update the 2/3 as a partial fulfillment? It seems most of the fulfillment updating is centred around an Order and not a line item.

@kevinhughes27
Copy link
Contributor

An order can have multiple fulfillments - the line items are divided by the fulfillment service. I totally understand why it seems that it is centered around orders but it is really centered around line item groupings.

I'm not 100% sure that I am clear on your exact situation though.

@resistorsoftware
Copy link

I will try and make it clear.

Customer Orders

  • 3 red t-shirts
  • 2 blue t-shirts
  • 1 yellow t-shirt

Fulfillment company ships the yellow t-shirt on Monday, with a tracking number "Hubba"

I get the order ID, the line item ID of the Yellow t-shirt, and a quantity of 1
I update the fulfillment, providing the line item ID, and the quantity, along with the tracking number.

Now on Tuesday I get new information. The fulfillment company sends me this:

  • Order ID
  • 2 tracking numbers "Bubba" and "Charles"
  • line item ID for red t-shirts, quantity = 1 (so this is a partial fulfillment)
  • line item ID for blue t-shirts, quanitty = 2 (so this is totally fulfilled)

First off.... can I present that to the Fulfillment Service API polling endpoint or is that not going to work since it expects ONLY an order ID and a tracking number?

If I decide to do the fulfillment myself... can I update the individual line items with a save? I suppose so eh? So really, I am better off not using the fulfillment service endpoint?

@kevinhughes27
Copy link
Contributor

When an order is fulfilled on shopify we create a fulfillment for each grouping of line items. The idea is that fulfillment services subscribe to the fulfillment/create webhook and then filter on their endpoint whether or not they need to do anything based on the service name.

As far as partial fulfillments go yeah the API isn't really set up for them. You can update the fulfillment as you go but only set the status to complete once it is completely fulfilled. It sounds like what you are trying to do is in fact more complicated than the standard idea that we created the end point for but you can always augment with direct API calls to the fulfillment itself.

I would recommend to keep using the service because that adds the UI element for the merchant but it sounds like you will need to make your backend more complicated and make some additional calls to the fulfilment object itself.

Does that sound right? Can we close this issue?

@resistorsoftware
Copy link

Makes sense. Thanks so much for all this. Indeed I learned a lot of new tricks here, and it works for me now, hence the clients are going to be happy. Close it!

@resistorsoftware
Copy link

I am having a tough time with this. Client does a partial using Shopify. I capture that request and submit it to the shipper, and they ship the order and provide tracking numbers. I set the fulfillment correctly and it sits in a pending state... nothing is updated in Shopify. The only way to force the tracking numbers on the partial is to close the fulfillment. That screws up Shopify as now the merchant can no longer fulfill their remaining partial. This is chaos.... needs a fix... I now have really grumpy customers. The only way to do partials is wait till their are ALL shipped, and then complete the order... the time between partials thus is time that tracking numbers cannot be communicated. That is not ideal.

@kevinhughes27
Copy link
Contributor

so if I am understanding the issue correctly you are unable to add a tracking number while in the pending state? like it just won't actually save it?

Maybe we need a partial state. I'll look into this

@resistorsoftware
Copy link

Here is a short list of problems:

Merchant used Shopify to partially fulfill an order (2 line items, 1 fully, 1 partially) and left another untouched.

I received two tracking numbers, one for each fulfillment, and I received a quantity and line item ID of the proper fulfillments.

I updated the Fulfillment record to have 2 tracking numbers, notify the customer and the quantities fulfilled.

Result: A fulfillment record with status pending, 2 line items marked partial and one stayed at nil.

PROBLEMS

Merchant had no idea of this. Saving the record DOES NOT update Shopify Admin. Customer did not receive any tracking numbers.

I decided to complete the fulfillment to see what that does. It completed the order. The order was partially fulfilled. The merchant could no longer do anything to fulfillments. One tracking number was assigned to both fulfillments, and that was that.

I then manually fulfilled the rest of the order with the API since the merchant could not.

How do you handle multiple Tracking Numbers?
Why does Shopify Admin not respect partial API requests by updating the Admin?

Pretty crazy stuff going on... here... :)

@kevinhughes27
Copy link
Contributor

we're doing our best to understand exactly what is going on - can I bug you to add some screenshots or a screencast of exactly what the fulfillment looks like before you've touched it with the API. That way we can get to the same state and try and figure out what to do.

This is the state I am talking about:

Merchant used Shopify to partially fulfill an order (2 line items, 1 fully, 1 partially) and left another untouched

@resistorsoftware
Copy link

An Order has 3 Line Items (I will just include the ID and Quantity values here... )
{id: 111, sku: AAA, quantity: 1}
{id: 222, sku: BBB, quantity: 2}
{id: 333, sku: CCC, quantity: 1}
A Merchant uses Shopify to fulfill 2 line items. That results in a Fulfillment being created that the App gets...

Merchant uses Shopify to: fulfill sku AAA, quantity = 1, sku BBB, quantity = 1

Shipper does just that. Returns to the App:
tracking numbers ["12345", "54321"]
{id: 111, quantity = 1}
{id: 222, quantity = 1}

Now the Fulfillment is PENDING. YAY!
Now the Fulfillment has two tracking numbers. YAY!
Now the Fulfillment has notify customer TRUE, YAY!

However, Shopify Admin shows NOTHING has been done. No tracking numbers. No fulfillments. Only the underlying API view of the Fulfillment shows anything.

So now... I waited... and waited... and the customer wanted to see something... So I completed the fulfillment. And then MAGIC.

One tracking number of the two was issued to both line items. The merchant could see the partial fulfillments and was happy. But, the merchant could no longer do anything to the remaining fulfillments.

Is that clearer... if not, PLEASE CALL ME TO DISCUSS. I know everything about this issue.

@kevinhughes27
Copy link
Contributor

Okay I am seeing 2 issues that need to be addressed from this, let me know if I have this right:

  1. Shopify does not show updates to pending fulfillments in the Admin
  2. Completing a fulfillment messed up multiple tracking numbers

@resistorsoftware
Copy link

Yes. When you save changes to a pending fulfillment, the Shopify Admin fails to reflect the changes.

When providing more than one tracking number for an update to a fulfillment, there is no way to match the tracking number to the item, and it seems Shopify just uses the first one in the list for the entire update.

@resistorsoftware
Copy link

Hi. So this client is very antsy... a lot of things are riding on having partials work right. Any chance of a contact and discussion to where this is all at?

@kevinhughes27
Copy link
Contributor

I worked through this flow today and here is what I found:

Issue 1

  • totally an issue and we should watch for update events and append them to the order history. I have opened an issue for this and someone will pick it up. Its really just a UI nicety though and not many of our merchants are using advanced fulfillments so it may not be added for a bit.

Issue 2

This one is a bit more complicated.

First I'd like to bring up an important point that comes from the coupling of orders and fulfillments - Orders can be partially fulfilled but fulfillments cannot be partially completed at this time, there is no state for this. What this means is that if the merchant partially or completely fulfills an order the fulfillment service can only cancel or complete that fulfillment request. If additional states are needed you will need to do this in an interface in your app. Your app can indicate the partial state of the fulfillment and then tell Shopify only when it is completed. Anyways I'm not sure if this was relevant to the discussion but came across it in my findings and thought I would add this explanation.

Anyways for the main point, when you completed the fulfillment there was a UI change but you didn't actually lose the second tracking number - its still there (at least it is on my order where I just worked through this). I've opened an issue to better display multiple tracking numbers in our admin UI as well. Again I wouldn't expect an immediate fix as this is a more rare use case for us.

Are you experiencing any other functional issues with multiple tracking numbers? The data is in tact but its possible that some other systems might just pull the first one like the admin UI does.

Basically everything is working only our fulfillment UI doesn't handle these more rare cases very well. Issues have been created and we'll get to work on it!

@resistorsoftware
Copy link

Thanks for the update!

@RichardBlair
Copy link
Contributor

Hey there!

I just wanted to let you know that a fix went out today so that multiple tracking numbers will now be displayed and can be edited in the admin, in the order history.

@resistorsoftware
Copy link

Excellent. That is a good thing. Next up. Fixing it so that updates to pending fulfillments update the UI in the admin too. Customers do need their tracking numbers in a timely fashion...

@resistorsoftware
Copy link

Did you know that when a merchant uses the admin to create a pending fulfillment, there is no way for them to cancel it? It can be cancelled using the API and a POST call, but there is no complement to that in the admin UI.

@kevinhughes27
Copy link
Contributor

yup we're aware

@resistorsoftware
Copy link

Hi, Client is asking if Shopify has fixed this bug/feature with partial fulfillments. Is there anything new to report since August 26th on this. It is important they get some idea of the progress here.

mkevinosullivan pushed a commit that referenced this issue Mar 8, 2022
Bumps [sorbet-runtime](https://github.com/sorbet/sorbet) from 0.5.9531 to 0.5.9542.
- [Release notes](https://github.com/sorbet/sorbet/releases)
- [Commits](https://github.com/sorbet/sorbet/commits)

---
updated-dependencies:
- dependency-name: sorbet-runtime
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants