【问题标题】:How can I add item cost to a product variant using ShopifyAPI?如何使用 ShopifyAPI 将商品成本添加到产品变体?
【发布时间】:2019-08-18 00:51:41
【问题描述】:

我正在尝试使用官方 ShopifyAPI Python SDK 以编程方式将几十种产品添加到我的 Shopify 商店,但我不知道如何指定每个变体的成本。

这是我迄今为止尝试过的:

variant = shopify.Variant()
variant.price = price
variant.option1 = size
variant.inventory_quantity = qty
variant.inventory_management = "shopify"
variant.fullfilment_service = "manual"
variant.requires_shipping = True
variant.sku = sku
variant.taxable = False
variant.inventory_policy = 'deny'
variant.cost = cost
new_product.variants.append(variant)

当然,variant.cost 不起作用。我该怎么做?还是还不支持?

我使用的是 ShopifyAPI 版本 5.1.0,API 版本是 2019-07。

【问题讨论】:

    标签: python shopify


    【解决方案1】:

    您无法通过变体更新api调用更新单价,您需要调用inventoryItem api来更新单价。

    **Update a unit cost**
    
    PUT /admin/api/#{api_version}/inventory_items/#{inventory_item_id}.json
    {
      "inventory_item": {
        "id": 808950810,
        "cost": "25.00"
      }
    }
    

    请参考此链接https://help.shopify.com/en/api/reference/inventory/inventoryitem#update-2019-07

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-07-14
      • 1970-01-01
      • 2022-10-25
      • 1970-01-01
      • 1970-01-01
      • 2018-08-31
      • 2022-08-11
      相关资源
      最近更新 更多