Closed alandolt closed 1 year ago
@alandolt
Your code is fine, in_stock_quantity
is a protected property that the system updates. We block updates on this property in case it is inadvertantly changed.
you can pass an override if you want to update this property, simply add
update_in_stock_quantity=true
ie
$product = $ninja->products->update("ProductIDIwanttoUpdate", ['in_stock_quantity' => 77, 'update_in_stock_quantity' => 'true']);
And the property will update.
Thank you very much, the proposed snippet works without problem. Maybe a short reasoning why I want to update the in stock quantity of products. I want to be able to sell kits, consisting of multiple sub products (items). The invoice should then only consist of the kit, however, in my inventory I should have the individual items a kit consist of. My idea is now to automatically update the available number of kits based on the in stock quantity of the individual items a kit consist of by updating its number directly over the API.
@alandolt
That makes sense when using it in that context. :+1:
Hello First thanks a lot for your work on invoiceninja. Everything seems to work, however, when updating the in_stock_quantity variable of a product over the sdk, the variable won't get updated, no matter what I try. I can update any other variable using the PHP SDK, however not the in_stock_quantity . The code I am using is the following:
When printing the array of possible variables, the in_stock_quantity variable is present, so I think it should also be possible to update it over the SDK. .
Is there anything wrong with my code or is there a bug? Thanks a lot for any answer.