Fulfill specific line-item.

63 views
Skip to first unread message

ThomasReggi

unread,
Dec 21, 2011, 1:47:17 PM12/21/11
to shopify-api, sandeep...@gmail.com
I am trying to fulfill a specific line-item within an order. I am
using https://github.com/sandeepshetty/shopify.php.

I have a specific order id 108364522
and I have a line-item within that orders id: 177495842

I've tried both:

$shopify('POST', '/admin/orders/'.'108364522'.'/
fulfillments.json',array('id' => '177495842'));
$shopify('POST', '/admin/orders/'.'108364522'.'/fulfillments.json');

and they give me errors

here is the clip from the doc

POST /admin/orders/#{id}/fulfillments.json
Fulfill a single line item by explicitly specifying the line items to
be fulfilled.
Request
{
"fulfillment": {
"line_items": [
{
"id": 466157049
}
],
"tracking_number": null
}
}

Denis Odorcic

unread,
Dec 21, 2011, 1:58:10 PM12/21/11
to shopi...@googlegroups.com
Your request is structured incorrectly.

Take a look at sandeepshetty's example on creating a recurring application charge. He begins the array with a root of 'recurring_application_charge', and in your example you have no root of 'fulfillment'. Also, that array will have to contain an array with a root of 'line_items', which will have the id key-value pairs (in your case, only one pair).

Denis Odorcic
Developer - Shopify

Sandeep Shetty

unread,
Dec 21, 2011, 2:12:57 PM12/21/11
to ThomasReggi, shopify-api
> $shopify('POST', '/admin/orders/'.'108364522'.'/
> fulfillments.json',array('id' => '177495842'));

If I'm reading that right, your not sending the right payload. Haven't
tried this, but looking at the docs, it looks like your payload needs
to look like this (you just have to mirror the json payload as a PHP
array):

$fullfilment = array
(
'fulfillmen' => array
(
'line_items' => array
(
'id'=>466157049
),
'tracking_number' => null
)
);

$shopify('POST', '/admin/orders/108364522/fulfillments.json', $fullfilment);

Shopify.php is optimized for just copy-pasting examples from the doc
and translating to PHP without any added abstractions to avoid
spending time dealing with errors in the abstraction (*cough* prefix
*cough* :)

--
Sandeep Shetty
Founder, Simpthings
http://simpthings.com/
http://sandeep.shetty.in/p/about.html

ThomasReggi

unread,
Dec 28, 2011, 3:53:07 AM12/28/11
to shopify-api
Here is my exact code, and I'm getting an "internal server error", any
ideas?

$fullfilment = array
(
"fulfillment"=>array
(
"line_items"=>array
(
"id"=>177495842

ThomasReggi

unread,
Dec 28, 2011, 4:03:26 AM12/28/11
to shopify-api
I've figured it out using http://jsonviewer.stack.hu/ and
json_encode() I was missing the nesting. Hope this helps someone out
there!

$fullfilment = array
(
"fulfillment"=>array
(
"line_items"=>array
(
array("id"=>"177495842")
Reply all
Reply to author
Forward
0 new messages