brucealdridge / VendAPI

Class for accessing the api for vend on vendhq.com
Other
36 stars 22 forks source link

How can you register a new order/sale? #4

Closed Lepozepo closed 11 years ago

Lepozepo commented 11 years ago

I've looked over the sdk but I can't find any functions to create a new order/sale. Is there any way to do this? Thank you for spending time on this!

brucealdridge commented 11 years ago

Here is some code straight out of my app you will need the latest copy of the VendAPI class which I've just committed

after setup of $vendapi object...

$sale = new \VendAPI\VendSale(null, $vendapi);
$sale->register_id = $register_id;
$sale->customer_id = $customer_id;
$sale->status = 'OPEN';
$products = array();
foreach ($items as $item) {
    $products[] = array(
        'product_id' => $item->product_id,
        'quantity' => $item->quantity,
        'price' => $item->price
    );
}
$sale->register_sale_products = $products;
$sale->save();

echo "Created new order with id: ".$sale->id;
Lepozepo commented 11 years ago

This is great! Thank you so much for spending time on this!