示例#1
0
echo "<p>Token: {$access_token}<br> Shop: {$shop_domain}</p>";
echo "<p>Lets send some test requests:</p>";
//
// Send Create
//
$res = $merchium->createRequest('products', array('product_code' => 'test', 'product' => 'Test product', 'price' => '25.0', 'company_id' => 1, 'status' => 'A', 'main_category' => '166', 'category_ids' => array('166')));
if ($res === false) {
    echo "<p>Error raised on create request: <b>" . $merchium->getLastError() . "</b></p>";
    exit;
}
$new_product_id = $res['product_id'];
echo "<p>Product with product_id={$new_product_id} was successfully created.</p>";
//
// Send Update
//
$res = $merchium->updateRequest("products/{$new_product_id}", array('price' => 2500.0));
if ($res === false) {
    echo "<p>Error raised on update request: <b>" . $merchium->getLastError() . "</b></p>";
    exit;
}
echo "<p>Price for product with product_id={$res['product_id']} was successfully updated.</p>";
//
// Send
//
$gres = $merchium->getRequest('products', array('q' => 'Test product', 'pname' => 'Y'));
if ($gres === false) {
    echo "<p>Error raised on get request: <b>" . $merchium->getLastError() . "</b></p>";
    exit;
}
$product_id = $gres['products'][0]['product_id'];
echo "<p>Product with product_id={$product_id} was successfully found.</p>";