Can't add a quantity to a product variant through the Shopify API in python

Hi!

I’m trying to build my own script in python to sync the products from a website to my Shopify store. I’m using the Shopify python api, you can check it out on github https://github.com/Shopify/shopify_python_api

The problem is, I can’t edit the variant quantities after adding the variants, in the shopify api doc, it says:

Apps can no longer set inventory using 'inventory_quantity’ or 'inventory_quantity_adjustment’. For more information, refer to the 'Inventory Level ’ resource.

So I went to the Inventory Level and tried to understand it, but with no luck.

Here is what I have right now

variants = []
    for index, value in enumerate(size_list):
        variant = shopify.Variant()
        variant.option1 = value
        variant.price = price_sek
        variant.inventory_management = 'shopify'
        variant.inventory_policy = 'continue'
        variants.append(variant)
        time.sleep(1)
    
    product.variants = variants
    if product.save():
        print('New product created with ID:', product.id)
    else:
        print('Failed to create new product')

So I need some help, I want to be able to:
1- Enable the “Track quantity”
2- Disable the “Continue selling when out of stock”
3- And lastly edit the variant quantity

Thanks for helping in advance.

1 Like