question

davidrichied avatar image
davidrichied asked clover-community-helper commented

How to Update Stock of Clover Product with PHP

This is not actually a question. I just wanted to post the answer that a Clover rep helped me find. Here is how to update stock of a clover product with PHP.

require_once 'Requests/library/ Requests.php';Requests::register_autoloader();

$CLOVER_API_URL = ' https://api.clover.com/v3/merchants';

$MERCHANT_ID = 'your_merchant_id';

$API_TOKEN = 'your_api_token';

$CLOVER_AUTH = "Bearer " . $API_TOKEN;

$headers = array( 'Content-Type' => 'application/json', 'Authorization' => $CLOVER_AUTH,);

$data = array( 'item' => array( 'id' => 'id_of_product'), 'quantity' => '37' );

$request = Requests::post($CLOVER_API_URL . '/' . $MERCHANT_ID . '/item_stocks/id_of_product', $headers, json_encode($data));
API Token
1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

clover-community-helper avatar image clover-community-helper commented ·

Hi David,

Thanks for the insights. We are working out some issues with our code block formatting, but I would recommend using pastebin.org to share code snippets.

Best,

0 Likes 0 ·

0 Answers

Welcome to the
Clover Developer Community