-
Notifications
You must be signed in to change notification settings - Fork 212
How to fulfill an order with Shopify API 2022-07 and above ? #283
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
Comments
Hey Mathieu, $shopify->Order($orderID)->Fulfillment->post uses the below POST link |
I've been using the code below. It took me a while to get the permissions right on the API user, it needed all of the permissions for managing tracking including third party tracking and also reading/writing orders. If you you need to get the fulfillment ID from the order and then use the fulfillment id to update the tracking info. $shopify->Fulfillment($fulfillment['id'])->update_tracking([
"tracking_number" => 'XXXXXXX'
"tracking_urls" => 'https://tracking_url...',
"notify_customer" => true,
"location_id" => 'location_id,
]); |
@tonytoms this is deprecated since Shopify API 2022-07.
|
Thank you @d3v1 this is probably the solution.
|
@d3v1 |
Hey @tonytoms I got the fulfillment ID from the order. In this case we're using the Here's an example bit of code you can start with: $config = array(
'ShopUrl' => 'your-shop-name-here.myshopify.com',
'AccessToken' => YOUR_API_KEY_GOES_HERE,
'ApiVersion' => '2022-10',
);
PHPShopify\ShopifySDK::config($config);
$shopify = new PHPShopify\ShopifySDK;
// get the order
$order = $shopify->Order($theOrderIdHere)->get();
$fulfillments = $order['fulfillments'];
foreach ($fulfillments as $fulfillment) {
// fulfillment id is below, we don't need to assing it to a variable, I thought it'd help make it clearer
$fulfillmentId = $fulfillment['id'];
// build your payload here
$payload = [
'fulfillment' => [
'notify_customer' => true, // you may want to make this false if you're correcting a tracking issue
"tracking_info" => [
'number' => 'NEW_TRACKING_NUMBER_HERE',
'company' => 'SHIPPING_COMPANY_HERE',
'url' => 'https://the-full-tracking-url-here.com/with/path?and=THE_QUERY_STRING'
]
]
];
// submit it to shopify
$result = $shopify->Fulfillment($fulfillmentId)->update_tracking($payload);
// the result is the new fulfillment data in case you want to store it somewhere or check the update worked
// print_r($result);
} |
Perfection. Thank you so much. Appreciate it |
So the solution is to use the Shopify PHP SDK ? No updates on this package ? |
I echo @t-prod question as the FulfillmentOrder API is important for order fulfillment in later versions of the Shopify REST API. There is a lot of new functionality too for applying, retrieving and releasing fulfillment holds |
@williamoconnorme I think we should use the Shopify PHP SDK now for this feature I don't believe there's a planified development for this feature cause the deadline is in April. |
Please check the latest release |
What do you do if you don't have any fulfillment_id's tied to the order. When I query an order for fulfillments, I receive an empty array. Clearly I need to create a fulfillment but I can't find any documentation on this that doesn't include the newer FulfillmentOrder API. Could someone point me in the right direction for creating the request? |
I am facing the same issue. From the official website I can see that we need to grand some permissions to the app. I haven't tried it but I hope that's why the array is null. |
I had the same problem, I needed to add the additional scopes and then the array wasn't empty. If you don't have the correct scopes, it doesn't throw any error, it just returns empty |
I have the additional scopes set and I still get an empty array, unless the order has already shipped. |
I just tried the same and am also getting no fulfillments inside the object of the order. https://myshopify.com/admin/api/2023-01/orders/4779611111/fulfillment_orders.json Does anyone have any luck in getting the fulfillment orders by calling the order.json endpoint like below? |
As was stated by Ismail Patel - if you don't have the right access scopes
defined, you can't see fulfillment orders, but you just get a blank array
rather than an error message!
I was trying to read / write merchant managed fulfillment orders but didn't
have these scopes enabled so was getting a blank array as others have:
write_merchant_managed_fulfillment_orders,
read_merchant_managed_fulfillment_orders
Once I enabled them I could get the fulfillment orders correctly using the
following curl:
curl -X GET "https://{my_store}}.
myshopify.com/admin/api/2023-01/orders/{order_id}/fulfillment_orders.json"
-H "X-Shopify-Access-Token:{my_access_token}"
Tony, note also that in your code you're using the endpoint "2022-01" in
your 2nd request for fulfillment orders. Can't remember if fulfillment
orders were implemented back in that version, anyhow it works with
"2023-01"...
Having got the request working with curl, it also then worked with the
library:
$order_id="1234567890";
$shop=new PHPShopify\ShopifySDK($store_config);
$fo=$shop->Order($order_id)->FulfillmentOrder()->get();
print_r($fo);
I hope that helps someone!
Tim
…On Thu, Feb 23, 2023 at 1:15 AM Tony Toms ***@***.***> wrote:
I have the additional scopes set and I still get an empty array unless the
order has already shipped.
I just tried the same and am also getting no fulfillments inside the
object of the order.
The endpoint I am using is
https://myshopify.com/admin/api/2023-01/orders.json?fulfillment_status=unfulfilled
However, I am getting the fulfilment order IDs when calling the
Fulfillment get api separately . @end2endi <https://github.com/end2endi>
, try it and I think you will get the values.
https://myshopify.com/admin/api/2022-01/orders/4779611111/fulfillment_orders.json
Does anyone have any luck in getting the fulfillment orders by calling the
order.json endpoint?
—
Reply to this email directly, view it on GitHub
<#283 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACERLZ4VCOZRGQ4HAQDO3NDWY222NANCNFSM6AAAAAAS64E6KU>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
I implemented the function of shipping orders on the 2023-04 version. The sample code is as follows:
If you find some bug, please point it out, thanks |
I googled or referred to many other online methods, but none of them succeeded, or I felt that it was not easy to use. Finally, directly refer to the official https://shopify.dev/docs/api/admin-rest/2023-04/resources/fulfillment#post-fulfillments, and then construct the corresponding parameters. |
With Shopify API 2022-01, I fulfilled my orders with these instructions :
With Shopify API 2022-07 and above, this is deprecated as it's mentioned in others issues, but even with the doc and some samples, I'm not able to convert this code to be compliant with the new fulfillment API.
Is someone could provide me an exemple ?
Thank you.
The text was updated successfully, but these errors were encountered: