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

Help with FulfillmentService #871

Closed
swalsh88 opened this issue Apr 17, 2023 · 11 comments
Closed

Help with FulfillmentService #871

swalsh88 opened this issue Apr 17, 2023 · 11 comments
Labels
fulfillments Questions and issues dealing with Shopify's fulfillment and fulfillment orders systems. question

Comments

@swalsh88
Copy link

I'm trying to convert my fulfillment code over to the 2022-07 API. I've read through the comments on issue #828 and attempted to work with the sample code that was provided. However, when I execute the code below, I receive a 404 error.

var fulfillment = await fulfillments.CreateAsync(new FulfillmentShipping
{
  Message = "items are shipping!",
  FulfillmentRequestOrderLineItems = lineItems,
  NotifyCustomer = true,
  TrackingInfo = new TrackingInfo
  {
    Company = "UPS",
    Url = "...",
    Number = "..."
  }
});

I'm not using a third party fulfilment service. I (the merchant) want to fulfill our own orders as mentioned in https://shopify.dev/docs/apps/fulfillment/order-management-apps

Can anyone help me understand what I might be missing?

@smart222zx
Copy link

Hi.I also have the same problem. Have you solved your problem?

@nozzlegear
Copy link
Owner

Hey, sorry I missed this. This should be possible still after Shopify's fulfillment changes. I'm not at my computer at the moment, but I'll post some example code for you later today that should help.

@nozzlegear
Copy link
Owner

Looks like I forgot to get that example code, @swalsh88 and @smart222zx did you get this working yet?

@smart222zx
Copy link

Looks like I forgot to get that example code, @swalsh88 and @smart222zx did you get this working yet?

Yes, I am using HttpClient to directly call the API, but this is just a temporary workaround.

@nozzlegear
Copy link
Owner

Thanks! Can you post the code you're using to create a fulfillment with the HttpClient? I'm curious what it might be doing differently.

@nozzlegear
Copy link
Owner

nozzlegear commented Jul 13, 2023

Here's an example for using ShopifySharp's FulfillmentOrderService and FulfillmentService to create a fulfillment with ShopifySharp v6.1.2:

var fulfillments = new FulfillmentService(domain, accessToken);
var fulfillmentOrders = new FulfillmentOrderService(domain, accessToken);
var orderId = 123456;

// Find open fulfillment orders for this order
var openFulfillmentOrders = await fulfillmentOrders.ListAsync(orderId);
openFulfillmentOrders = openFulfillmentOrders.Where(f => f.Status == "open").ToList();

// Fulfill the line items
var lineItems = openFulfillmentOrders.Select(o => new LineItemsByFulfillmentOrder
{
  FulfillmentOrderId = o.Id.Value
  // Optionally specify a list of line items if you're doing a partial fulfillment
  // FulfillmentRequestOrderLineItems = ...
});
var fulfillment = await fulfillments.CreateAsync(new FulfillmentShipping
{
  Message = "items are shipping!",
  FulfillmentRequestOrderLineItems = lineItems,
  NotifyCustomer = true,
  TrackingInfo = new TrackingInfo
  {
    Company = "UPS",
    Url = "...",
    Number = "..."
  }
});

Can everyone in here try that and let me know how it works? This is functionally the same as creating fulfillments used to be before Shopify's API change, it's just using their recommended fulfillment orders flow.

Note that you need to have the write_merchant_managed_fulfillment_orders permission or else the fulfillmentOrders.ListAsync is going to return an empty list or it's going to 404.

@James-Jackson-South
Copy link

@nozzlegear I had to enable write_third_party_fulfillment_orders for FulfillmentOrderService.ListAsync(...) to work since the location is externally managed.

Your code has an error.

var lineItems = openFulfillmentOrders.Select(o => new LineItemsByFulfillmentOrder
{
  FulfillmentOrderId = o.Id.Value
  // Optionally specify a list of line items if you're doing a partial fulfillment
  // FulfillmentRequestOrderLineItems = ...
});

Should be...

var lineItems = openFulfillmentOrders.Select(o => new LineItemsByFulfillmentOrder
{
  FulfillmentOrderId = o.FulfillmentOrderId.Value
  // Optionally specify a list of line items if you're doing a partial fulfillment
  // FulfillmentRequestOrderLineItems = ...
});

I can hit the API successfully following those changes.

@themultiv3rs3
Copy link

I've set the write_merchant_managed_fulfillment_orders permission and I'm still receiving the 404. I'm running version v6.2. Has anyone been able to get this working?

@nozzlegear
Copy link
Owner

Hey @themultiv3rs3, sorry you're having issues. What specifically is giving you a 404: trying to list fulfillment orders, getting the order itself, or something else?

@themultiv3rs3
Copy link

themultiv3rs3 commented Jul 24, 2023

when calling:

var fulfillment = await fulfillments.CreateAsync(new FulfillmentShipping
{
  Message = "items are shipping!",
  FulfillmentRequestOrderLineItems = lineItems,
  NotifyCustomer = true,
  TrackingInfo = new TrackingInfo
  {
    Company = "UPS",
    Url = "...",
    Number = "..."
  }
});

@nozzlegear
Copy link
Owner

@davitgr @themultiv3rs3 Solution posted here! You need to add the specific fulfillment order line items to the LineItemsFulfillmentOrder object.

@nozzlegear nozzlegear added question fulfillments Questions and issues dealing with Shopify's fulfillment and fulfillment orders systems. labels Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fulfillments Questions and issues dealing with Shopify's fulfillment and fulfillment orders systems. question
Projects
None yet
Development

No branches or pull requests

5 participants