When completing an unfulfilled order fulfillment through the Shopify Admin ("Mark as fulfilled"), which has a status of pending or open, the fulfillments/create webhook topic is triggered. This is not expected, given it's an update and not a creation operation. The fulfillment's status in the webhook event is success.
When updating the order's fulfillment through the API, the fulfillments/create topic is not triggered, which I expect.
Maybe there is intended to be a difference between the Shopify Admin and API, so I'd appreciate if that could be clarified here. In any case, there's a mismatch between completing the order fulfillment through API vs the Shopify Admin.
I can help clarify this. The expected behaviour is for the fulfillments#create webhook to fire every time a new fulfillment resource is created. In other words, the webhook will fire each time a new fulfillment_id is created for the shop.
You described a scenario where you press the "Mark as Fulfilled" button in the admin for an order that already has a pending or open fulfillment. If the order has a pending/open fulfillment, that means it hasn't been fulfilled yet and so the webhook shouldn't have fired at this point. When a fulfillment is pending, you can action the order 2 different ways: you can create a fulfillment using the FulfillmentService, or you can press "Mark as Fulfilled" in the admin. Both of these actions create a new fulfillment object, at which point the webhook will fire.
When completing a fulfillment through the API, you are indicating that you will be taking no further action on an already existing fulfillment. The webhook for that fulfillment would've fired during creation, and so the complete action is treated as an update.
I hope that helps clear things up. Please don't hesitate to reach out there are any other questions I can answer.
JB | Developer Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Click Accept as Solution