[英]How to add a product variant with the Ruby gem
添加產品變體的正確方法是什么?
我成功創建了產品,該產品顯示在我的Shopify管理員中。 但是,價格始終為零,數量始終為無窮大。
我試過創建一個具有stock_quantity和price設置以及在prefix_options中設置product_id的變體。
但是,管理員始終顯示零價格和無窮大。
Rails v3.2.5
shopify_api v3.0.0
shop name: vacation-2
我在執行API調用時不會出錯。 我根本沒有在admin產品中看到我的變體數據。
確保將:inventory_management
屬性設置為"shopify"
,否則數量將不會持久。
我剛剛對此進行了測試,並且效果很好:
product.variants << ShopifyAPI::Variant.new(
:option1 => "Large",
:price => 12.95,
:inventory_management => 'shopify',
:inventory_quantity => 10
)
product.save
在不使用產品關聯的情況下添加變體:
ShopifyAPI::Variant.new(
:product_id => #enter product id,
:option1 => "Large",
:price => 12.95,
:inventory_management => 'shopify',
:inventory_quantity => 10
)
product.save
這樣做的好處是可以使用API返回的值來更新變量對象。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.