A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
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?
thanks,
k
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":
continue
location_id = fo.assigned_location_id
if location_id != settings.SHOPIFY_FRM_FULFILLMENT_SERVICE_ID:
continue
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)
shopify_fo_line_items.append(
{"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"
fulfillment.save()
Hi Kenneth,
Never used that library so can't give you any feedback on that.. I did notice a couple things though.
Cheers,
Gary
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(
shopify_variant.inventory_item_id
)
inventory_item.cost = price_wholesale_dct[shopify_variant.sku]
inventory_item.tracked = True
inventory_item.save()
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.
Cheers,
Gary