inakiabt / etsy-php

Etsy API wrapper for PHP
74 stars 59 forks source link

updateInventory fails with multiple values in price_on_property, quantity_on_property, and sku_on_property #59

Open geewhzz opened 4 years ago

geewhzz commented 4 years ago

This drove me crazy for a day.

from methods.json on updateInventory these must be changed from;

"price_on_property": "array(int)", "quantity_on_property": "array(int)", "sku_on_property": "array(int)"

to:

"price_on_property": "string", "quantity_on_property": "string", "sku_on_property": "string"

When submitting the request to Etsy, array(int) will only work with one value, but if you need to add another property_id such as array(int, int) it will fail. This was actually crashing my Apache server so it was rather hard to debug. On the Etsy documentation it asks for array(int) but a string will actually work just fine for one propert_id or two property_id's. ie;

$args = array( 'params' => array( 'listing_id' => $product['id_etsy'] ), 'data' => array( 'products' => json_encode( $ListingProducts ), 'price_on_property' => "100,200", 'quantity_on_property' => "100,200" ) );