phpclassic / php-shopify

PHP SDK for Shopify API
Apache License 2.0
570 stars 210 forks source link

Can't update variant #138

Closed usfox closed 4 years ago

usfox commented 4 years ago

Shopify API reference PUT /admin/api/2020-01/variants/#{variant_id}.json { "variant": { "id": 808950810, "option1": "Not Pink", "price": "99.00" } }

My code is: $putArray = array( "id" => $variants_id, "option1" => "1 PACK", "option2" => "450ml", "price" => 3.00 ); $this->shopify->Product->Variant($variants_id)->post($putArray);

Recive this error:

`PHP Fatal error: Uncaught PHPShopify\Exception\CurlException: Request failed with HTTP Code 406. in /home/Tools/shopify_2-12-2020/vendor/phpclassic/php-shopify/lib/ShopifyResource.php:489 Stack trace:

0 /home/Tools/shopify_2-12-2020/vendor/phpclassic/php-shopify/lib/ShopifyResource.php(401): PHPShopify\ShopifyResource->processResponse(NULL, 'variant')

1 /home/Tools/shopify_2-12-2020/shopify.php(139): PHPShopify\ShopifyResource->put(Array)`

Could you give me any suggestions, Thank you!

usfox commented 4 years ago

O, I know how to solve that.

$this->shopify->Product($product_id)->Variant($variants_id)->put($putArray);