-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_products.php
36 lines (33 loc) · 1 KB
/
create_products.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
namespace root;
use auth\curl\CurlHandler;
use models\Store;
use models\Product;
include 'auth\auth.php';
include 'auth\curl\curl.php';
require 'models\Product.php';
/**
* This function creates a new product
*/
function createNewProduct(Store $s, Product $product)
{
$arr = json_encode(array(
'name' => $product->getName(),
'price' => $product->getPrice(),
'weight' => $product->getWeight(),
'type' => $product->getType()
));
$curl_url = $s->getApiPath() . "v2/products";
$newOrder = CurlHandler::POST($curl_url, $s->getAccessToken(), $arr);
return $newOrder;
}
/**
* TESTING
*/
$myProduct = new Product();
$myProduct->setName("Baby Blue Hamper");
$myProduct->setPrice(10.00);
$myProduct->setWeight(2);
$myProduct->setType("physical");
echo "NEWLY CREATED PRODUCT => " . createNewProduct($myStore, $myProduct) . "\n\n";
?>