5
votes

I'm using this PHP framework for use with Shopify's API

Can anyone help me with updating a product's variant attributes, specifically the inventory quantity?

The corresponding api call as listed in the Shopify docs is:

/admin/variants/#{id}.json

To update a product attribute such as the title it's a case of:

$fields = array('title' => 'My New Product Edit');

$api->product->modify(89605609, $fields);

Changing these to reflect a variant doesn't work in the same way.

As always, any help greatly appreciated.

2

2 Answers

3
votes

The library you are using is deprecated. You should use one of the libraries mentioned here: http://wiki.shopify.com/Shopify_App_Development#.E2.80.9CI.E2.80.99m_a_PHP_developer.E2.80.9D

3
votes

you can use the following code and update variant values:

$product_array = array(
    'variant'=>array(               
    'id'=>#{id},
    'price'=>15.00
));

$put = $shopify('PUT /admin/variants/#{id}.json', array(), $product_array);

(See the relevant Shopify documentation)