Create fulfillment of an order using ShopifyAPI python library

Create fulfillment of an order using ShopifyAPI python library

kloudship
Shopify Partner
1 0 1

We are building an app in Django to fulfill orders. We are able to fulfill orders by HTTP request but are unable to do the same with the python ShopifyAPI library.  Below is the code.

 

 

 

shopify.Session.setup(
            api_key=settings.SHOPIFY_API_KEY, secret=settings.SHOPIFY_API_SECRET)
        api_version = settings.SHOPIFY_API_VERSION
        shop_url = settings.SHOPIFY_SELLER_URL.replace(
            "storeName", store['referenceName'])
        session = shopify.Session(shop_url, api_version, store['token'])
        shopify.ShopifyResource.activate_session(session)
        locationId = body.get('locationId')
        trackingCode = body.get('trackingNumber')
        carrierCompany = body.get('carrierCompany')
        trackingURL = body.get('trackingURL')
        fulfillment = {}
        fulfillment['tracking_info'] = {}
        fulfillment['line_items_by_fulfillment_order'] = []
        fulfillment['location_id'] = f'{locationId}'  # location id
        fulfillment['notify_customer'] = False
        fulfillment['status'] = 'success'
        fulfillment['tracking_info']['number'] = f'{trackingCode}'
        fulfillment['tracking_info']['company'] = f'{carrierCompany}'
        fulfillment['tracking_info']['tracking_urls'] = f'{trackingURL}'
        fulfillment['line_items_by_fulfillment_order'].append({'fulfillment_order_id': orderId})
        fulfillments = shopify.Fulfillment.create(fulfillment, order_id = orderId)

 

 

 

 

Any help would be greatly appreciated!

Replies 3 (3)

Melbot
Shopify Partner
6 0 5

Hello, did you figure it out? I'm having a similar issue and it's really hard finding any help!

Boneoh
Tourist
10 0 3

Same here, I can't seem to make the fulfillment work.

Boneoh
Tourist
10 0 3

I gave up on the python ShopifyAPI library and just did a post of the json.  Shopify line item fulfillment example python code