What is the correct way to add a product variant?
I create the product successfully and it shows up in my Shopify admin. However the price is always zero and the quantity is always infinity.
I've tried creating a variant with inventory_quantity and price set, as well as with product_id set in prefix_options.
However admin is always showing price zero and quantity infinity.
Rails v3.2.5
shopify_api v3.0.0
shop name: vacation-2
I don't get errors doing the API calls. I simply don't see my variant data in the product in admin.
Make sure that you set the :inventory_management
attribute to "shopify"
, or the quantity won't persist.
I just tested this out, and it works perfectly:
product.variants << ShopifyAPI::Variant.new(
:option1 => "Large",
:price => 12.95,
:inventory_management => 'shopify',
:inventory_quantity => 10
)
product.save