Fulfillment error

Shopify Partner
4 0 0

I'm using the python sdk  ShopifyAPI==12.2.0 and api version "2023-01."

Whenever i try to save my fulfillment I get the error

Cannot create fulfillment for the fulfillment order


In [50]: fulfillment.to_dict()
{'location_id': xxx,
'notify_customer': False,
'line_items_by_fulfillment_order': [{'fulfillment_order_id': <the id of the FulfillmentOrder>,
'fulfillment_order_line_items': [{'id': <the id of the line item in the fulfillmentOrder>, 'quantity': 1}]}],
'message': 'The order has been submitted for processing'}
when i try fulfillment.save()  it returns False and i get the error posted above.

Here are my scopes:

write_products write_orders write_fulfillments write_assigned_fulfillment_orders write_customers write_inventory write_locations write_merchant_managed_fulfillment_orders write_shipping write_third_party_fulfillment_orders read_products read_orders read_fulfillments read_assigned_fulfillment_orders read_customers read_inventory read_locations read_merchant_managed_fulfillment_orders read_shipping read_third_party_fulfillment_orders


and here is the FulfillmentService

{'id': xxx,
'name': 'xxx',
'email': None,
'service_name': 'xxx',
'handle': 'xxx',
'fulfillment_orders_opt_in': True,
'include_pending_stock': False,
'provider_id': None,
'location_id': xxx,
'callback_url': 'https://xxx/shopify-hooks/',
'tracking_support': True,
'inventory_management': True,
'admin_graphql_api_id': 'gid://shopify/ApiFulfillmentService/xxx',
'permits_sku_sharing': True


i'm also setting shopify.Fulfillment._prefix_source = ""   before i save since it appears the current sdk is wrong there.


any ideas?





and here is the rough code i am using ... 


new_orders = shopify.Order.find()
for order in new_orders:
    fos = shopify.FulfillmentOrders.find(order_id=order.id)
    for fo in fos:
        if fo.status != "open":
         location_id = fo.assigned_location_id
         if location_id != settings.SHOPIFY_FRM_FULFILLMENT_SERVICE_ID:
         fulfillment = shopify.Fulfillment()
         fulfillment.location_id = location_id
         fulfillment.notify_customer = False

         shopify_fo_line_items = []
         for line_item in fo.line_items:
              variant = shopify.Variant.find(line_item.variant_id)
                        {"id": line_item.id, "quantity": line_item.fulfillable_quantity}
         fulfillment.line_items_by_fulfillment_order = [
                 "fulfillment_order_id": fo.id,
                 "fulfillment_order_line_items": shopify_fo_line_items,

     shopify.Fulfillment._prefix_source = ""
     fulfillment.message = "The order has been submitted for processing"


Replies 3 (3)

Shopify Partner
397 40 166


Hi Kenneth,


Never used that library so can't give you any feedback on that.. I did notice a couple things though.

  • The location_id is not needed for the new fulfillment api a fulfillment order is always assigned to a location anyway.
  • you can skip sending the fulfillment_order_line_items if you are always fulfilling the entire order, you only need to send the individual line items if the quantity being fuliflled differs from the fulfillment order quantity.




- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
Shopify Partner
4 0 0

Thanks.  I've tried this... dropping the line items or the location_id doesn't seem to change anything.  Any other ideas? could it be a setting issue on the fulfillment service?  or on the "InventoryItem"?


inventory_item = shopify.InventoryItem.find(
inventory_item.cost = price_wholesale_dct[shopify_variant.sku]
inventory_item.tracked = True

Shopify Partner
397 40 166

Hi Kenneth,


I would try to do it without using any middleware.


Install the graphiql app on the dev shop and use the fulfillmentCreatev2 mutation to try and fulfill the order. Or use postman to talk to the restapi "admin/api/2023-01/fulfillments.json" endpoint.


Make sure that the fulfillmentorder is open and has the appropriate "suppoted_actions" e.g."create_fulfillment". Without the "create_fulfillment" action present on the fulfillment order you won't be able to create a fulfillment for the order.





- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution