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’: ,
‘fulfillment_order_line_items’: [{‘id’: , ‘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()