Fulfillment LineItems have a property called `fulfillable_quantity` with the following description:
1. Can someone explain that in human terms?
2. What is the definition of each of those properties?
3. How do they come together to represent "Fulfillable Quantity"?
Well, I understand part of it now.
So an order comes in with a single variant bought. The customer bought 4. So 4 need to be fulfilled (shipped).
Then let's say the order is shipped in 4 boxes.
1 box arrives. It is delivered. It is fulfilled. fulfilled_quantity = 1
1 box is in transit. I think that means it is pending. pending_fulfilled_quantity = 1
1 box hasn't yet been shipped. The shipped (maybe your warehouse) has the order, they will be shipping it soon, but not yet. open_fulfilled_quantity = 1
So at this point fulfillable_quantity is 1 because 1 still needs to be shipped. 4 -1 - 1 - 1 = 1.
THEN, the customer cancels everything. refunded_quantity = 4.
The arrived box still remains fulfilled. The fulfillment status is success. Can't take that away. fulfilled_quantity = 1
The pending one is cancelled I guess. pending_fulfilled_quantity = 0
And the one the warehouse was preparing to ship is cancelled also. open_fulfilled_quantity = 0.
So at this point fulfillable_quantity is 0 because 0 need to be shipped. 4 - max(4,1).
I think the reason for this complication is that a fulfillment can be cancelled up until the point that it is delivered. So while pending_fulfilled_quantity and open_fulfilled_quantity can go to 0, fulfilled_quantity can't. So you don't want to count refunds and fulfilled twice.
What if the customer orders 4, then they cancel 3? fulfillable_quantity = 3. 4 - 3 = 1.
Then the store fulfills the last 1. And it arrives. fulfilled_quantity = 1.
So at this point, fulfillable_quantity should equal 0, but by the formula 4 - max(3,1) = 1...?!
Completely agree with you @HorseCowboy! The formula doesn't make sense if some items have been refunded and some items have been fulfilled. I don't understand why the formula isn't just:
quantity - refunded_quantity - fulfilled_quantity - pending_fulfilled_quantity - open_fulfilled_quantity
And then just make the minimum value of fulfillable_quantity equal to zero, so that it can never be negative, as would happen if, taking @HorseCowboy's example, all items have been refunded but one was already fulfilled.
Would appreciate some clarity on this, and whether @HorseCowboy's example really would lead to a false fulfillable_quantity.