Update item variable quantity through API? J Kenneth September 10, 2020 07:45 5 comments Is it possible to update the quantity of an existing item variable through the API? Comments 5 comments Sort by Date Votes Chris Muench September 10, 2020 12:07 This is now possible in the latest 17.7 release. 0 J Kenneth September 10, 2020 21:38 The quantity field for a variation item is in locations-x-variations-quantity? 0 Chris Muench September 10, 2020 22:33 Yes 0 J Kenneth September 11, 2020 01:35 Hi Chris, I am having trouble. It is showing an API call but none of my items quantities are being updated. $data = array('locations'=> array( 1 => array( 'variations' => array( 0 => array( 'quantity' => 8 ) ) ) ) ); 0 Chris Muench Edited September 11, 2020 01:53 Here is a working code example. Make sure you know the item_id and variation_id <?php//////////////////////////////////////////////////////////$api_base_url = 'http://localhost/phppos/PHP-Point-Of-Sale/index.php/api/v1/';$api_key = '8ooosck0sc0w8g0gk48g044c4cokkgc8kwk8sk08';///////////////////////////////////////////////////////////$item_id = 1;$item_variation_id = 2;$post_data = array('locations' => array("1" => array('variations' => array( array('variation_id' => $item_variation_id,'quantity' => 1000)) )));$curl = curl_init();curl_setopt($curl, CURLOPT_URL, $api_base_url.'items/'.$item_id);curl_setopt($curl, CURLOPT_HTTPHEADER, array( 'x-api-key:'.$api_key,'accept: application/json', ));curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl,CURLOPT_POST, 1);curl_setopt($curl,CURLOPT_POSTFIELDS, json_encode($post_data));$result = json_decode(curl_exec($curl), TRUE);echo '<pre>';var_dump($result);echo '</pre>'; 0 Please sign in to leave a comment.
Comments
5 comments
This is now possible in the latest 17.7 release.
The quantity field for a variation item is in locations-x-variations-quantity?
Yes
Hi Chris,
I am having trouble. It is showing an API call but none of my items quantities are being updated.
Here is a working code example. Make sure you know the item_id and variation_id
Please sign in to leave a comment.