Ad

I Am Not Able To Update Products In Shopify Using PHP

- 1 answer

I want update Products variant but the following code is not working:

$shopify = shopify\client($store, SHOPIFY_APP_API_KEY, $access_token);

$product_array = array(
                        'id'    => 37247835908, 
                        'price' => "75.00"
                    ); 

$put = $shopify('PUT', '/admin/products/632910392.json',array(),$product_array); 
print_r($put);

if anyone have answer to this question then reply me thanks.

Ad

Answer

I got answer of this question:

$shopify = shopify\client($store, SHOPIFY_APP_API_KEY, $access_token);

$product_array = array(
                        'id'    => 37247835908, 
                        'price' => "75.00"
                    ); 

$put = $shopify('PUT', '/admin/products/632910392.json',array(),$product_array); 
print_r($put);

I have replace above put request like below and get the solution:

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

));

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

And I have successfully updated price of variant.

Ad
source: stackoverflow.com
Ad