static function checkDuplicatePo($key) { $purchase = new Purchase($key); //Search Duplicate $records = fRecordSet::build('Purchase', array('po_number=' => $purchase->getPoNumber())); if ($records->count() > 1) { //Generate New PO echo 'Duplicate PO'; $exploded = explode('/', $purchase->getPoNumber()); echo (int) $exploded[2] + 1; $exploded[2] = sprintf("%03d", (int) $exploded[2] + 1); $newPONumber = implode('/', $exploded); $purchase->setPoNumber($newPONumber); $purchase->store(); } }
/** * Добавляем покупку * @param Purchase $purchase */ public function addPurchase(Purchase $purchase) { $id = $purchase->getProduct()->getId(); if (isset($this->purchases[$id])) { $this->purchases[$id]->setCount($this->purchases[$id]->getCount() + $purchase->getCount()); } else { $this->purchases[$id] = $purchase; } $this->customer->addOrder($this); }
public function orders() { require_once '../app/models/Purchase.php'; $model = new Purchase(); $purchaseList = $model->generatePurchaseArray(); $view = new View('purchases/index'); $view->set_title('Your Orders'); $view->pass_data('purchaseList', $purchaseList); $view->load_page(); }
/** * Store a newly created stock in storage. * * @return Response */ public function store() { $stock = new Purchase(); $stock->item = Input::get('item'); $stock->selling_price = Input::get('selling_price'); $stock->price = Input::get('purchase_price'); $stock->quantity = Input::get('quantity'); $stock->status = Input::get('status'); $stock->account = Input::get('account'); $stock->save(); return Redirect::route('purchases.index'); }
public function __construct() { parent::__construct(); $this->load->model('purchase_model'); $this->load->model('product_model'); $this->load->library('form_validation'); }
/** * this method is needed to * delete from a vendor list */ public function delete($id) { $article = Purchase::find_by_id($id); if ($article->delete()) { return true; } }
/** * Search Licenses */ static function search($q = NULL, $param = NULL, $product_code = NULL) { $_tbl_licenses = License::getTableName(); $_tbl_licensesUses = LicensesUses::getTableName(); $_tbl_transactions = Transaction::getTableName(); $_tbl_purchases = Purchase::getTableName(); $_tbl_products = Product::getTableName(); $_tbl_plans = Plan::getTableName(); $_tbl_buyers = Buyer::getTableName(); $fields = array("{$_tbl_licenses}.*", DB::raw("COUNT({$_tbl_licensesUses}.id) AS totalUsed"), "{$_tbl_buyers}.first_name", "{$_tbl_buyers}.last_name", "{$_tbl_buyers}.email", "{$_tbl_products}.code", "{$_tbl_plans}.code AS plan_code", "{$_tbl_products}.api_key"); $licenses = DB::table($_tbl_licenses)->leftJoin($_tbl_licensesUses, "{$_tbl_licensesUses}.license_id", '=', "{$_tbl_licenses}.id")->join($_tbl_transactions, "{$_tbl_transactions}.id", '=', "{$_tbl_licenses}.transaction_id")->join($_tbl_plans, "{$_tbl_transactions}.plan_id", '=', "{$_tbl_plans}.id")->join($_tbl_purchases, "{$_tbl_purchases}.id", '=', "{$_tbl_transactions}.purchase_id")->join($_tbl_products, "{$_tbl_products}.id", '=', "{$_tbl_purchases}.product_id")->join($_tbl_buyers, "{$_tbl_buyers}.id", '=', "{$_tbl_purchases}.buyer_id")->select($fields)->groupBy("{$_tbl_licenses}.id"); $q = $q ? $q : Input::get('q'); $param = $param ? $param : Input::get('param'); if ($q) { if ($param == "key") { $licenses = $licenses->where("license_key", '=', $q); } if ($param == "email") { $licenses = $licenses->where("email", '=', $q); } if ($product_code) { $licenses = $licenses->where($_tbl_licenses . ".license_key", 'LIKE', strtoupper($product_code) . '-%'); } } return $licenses->orderBy($_tbl_licenses . '.created_at', 'DESC')->paginate(25); }
protected static function createBaseFromData(\stdClass $data) { $object = new static(); $object->type = $data->type; $object->uuid = $data->uuid; $object->revisionHash = $data->hash; $object->availableLanguageCodes = $data->languages; $object->status = $data->status; $object->contentProvider = ContentProvider::createFromData($data->content_provider); if (isset($data->location)) { $object->location = Location::createFromData($data->location); } if (isset($data->trigger_zones)) { foreach ($data->trigger_zones as $triggerZoneData) { $object->triggerZones[] = TriggerZone::createFromData($triggerZoneData); } } if (isset($data->purchase)) { $object->purchase = Purchase::createFromData($data->purchase); } if (isset($data->publisher)) { $object->publisher = PublisherBase::createFromData($data->publisher); } if (isset($data->city)) { $object->city = CityBase::createFromData($data->city); } if (isset($data->country)) { $object->country = CountryBase::createFromData($data->country); } return $object; }
function purchase_edit() { $session = Session::getInstance(); if (!$session->checkLogin()) { return false; } $purchase = new Purchase(); $purchase->id = isset($_POST['purchase']) ? $_POST['purchase'] : ""; $purchase->status = isset($_POST['status']) ? $_POST['status'] : ""; $purchase->update(); if (isset($_POST['payment']) && is_numeric($_POST['payment'])) { $purchasePayment = new PurchasePayment(); $purchasePayment->purchaseid = isset($_POST['purchase']) ? $_POST['purchase'] : ""; $purchasePayment->amount = isset($_POST['payment']) ? $_POST['payment'] : ""; $purchasePayment->add(); } }
/** * Display customer profile * * @param $profile * @return Response */ public function show($profile) { $p = User::where('profile_url', '=', $profile)->where('approved', '=', '0')->first(); $page = Page::where('title', '=', 'faq-customer')->first(); $follow = Follow::where('user', $p->id)->where('hub', '=', 0)->get(); $follow_hub = Follow::where('user', $p->id)->where('artist', '=', 0)->get(); $wall = new \Illuminate\Database\Eloquent\Collection(); $events = new \Illuminate\Database\Eloquent\Collection(); $comments = Comment::where('user', '=', $p->id)->orderBy('created_at', 'desc')->get(); $hidden = unserialize(Cookie::get('hide')); //dd( Cookie::get('hide') ); if (count($follow) > 0) { foreach ($follow as $f) { $s = Song::where('artist', '=', $f->artist)->where('completed', '=', '1')->get(); $e = ArtistEvent::where('artist', '=', $f->artist)->where('date', '>', \Carbon\Carbon::now())->get(); $wall = $wall->merge($s); $events = $events->merge($e); } } if (count($follow_hub) > 0) { foreach ($follow_hub as $h) { $hub = Hub::where('id', '=', $h->hub)->first(); if (!is_null($hub)) { $artists = User::where('type', '=', 'artist')->where('hub', '=', $hub->id)->get(); $artists_list = []; $songs = []; $events = []; foreach ($artists as $a) { $artists_list[] = $a->id; } if (count($artists_list) > 0) { $songs = Song::where('completed', '=', '1')->whereIn('artist', $artists_list)->orderBy('created_at', 'desc')->get(); $events = ArtistEvent::whereIn('artist', $artists_list)->get(); } $news = News::where('hub', '=', $hub->id)->take(3)->get(); $wall = $wall->merge($songs); $events = $events->merge($events); } } } $purchased = Purchase::where('customer', '=', $p->id)->get(); foreach ($purchased as $pp) { $song_purchased = Song::withTrashed()->where('id', '=', $pp->song)->get(); $download = Download::where('customer', '=', $p->id)->where('song', '=', $pp->song)->first(); $song_purchased[0]->purchased = true; if (isset($download)) { $song_purchased[0]->link = $download->url; } $wall = $wall->merge($song_purchased); } $wall->sortByDesc('created_at'); if (!isset($news)) { $news = null; } return View::make('customer.profile-new', ['profile' => $p, 'wall' => $wall, 'page' => $page, 'events' => $events, 'comments' => $comments, 'hidden' => $hidden, 'news' => $news]); }
public static function create(DB $db, Amount $denom, Purchase $p) { $prepared = $db->prepare(' INSERT INTO `bills` ( `entered_at`, `denomination`, `purchase_id` ) VALUES ( NOW(), :denomination, :purchase_id ) '); $result = $prepared->execute(array(':denomination' => $denom->get(), ':purchase_id' => $p->getId())); if ($result === false) { throw new Exception("Unable to log bill."); } return self::load($db, $db->lastInsertId()); }
public function __construct() { parent::__construct(); $this->load->model('purchase_finance_model'); $this->load->model('purchase_order_model'); $this->load->model('product_model'); $this->load->model('user_model'); $this->load->helper('purchase_order'); $this->load->library('form_validation'); }
public function getDetail() { //$id = \Input::get('id'); $input = \Input::all(); if ($input['type'] == 'sale') { $detail = Sale::find($input['id']); } else { $detail = Purchase::find($input['id']); } return \Response::json($detail); }
public static function boot() { parent::boot(); static::deleted(function ($supplier) { $supplier->purchases()->delete(); $purchases = Purchase::where('supplier_id', '=', $supplier->id); dd($purchases); $purchases->items()->detach(); $purchases->receivings()->delete(); $purchases->payments()->delete(); }); }
public function __construct() { parent::__construct(); $this->load->model('purchase_statistics_model'); $this->load->model('stock_model'); $this->load->model('product_model'); $this->load->model('solr/solr_base_model'); $this->load->model('solr/solr_statistics_model'); $this->load->helper('solr'); $this->load->helper('db_helper'); $this->template->add_js('static/js/sorttable.js'); }
/** * Delivers order export files to the browser * * @since 1.1 * * @return void **/ function export_purchases () { if (!current_user_can('ecart_financials') || !current_user_can('ecart_export_orders')) exit(); if (!isset($_POST['settings']['purchaselog_columns'])) { $Purchase = Purchase::exportcolumns(); $Purchased = Purchased::exportcolumns(); $_POST['settings']['purchaselog_columns'] = array_keys(array_merge($Purchase,$Purchased)); $_POST['settings']['purchaselog_headers'] = "on"; } $this->Settings->saveform(); $format = $this->Settings->get('purchaselog_format'); if (empty($format)) $format = 'tab'; switch ($format) { case "csv": new PurchasesCSVExport(); break; case "xls": new PurchasesXLSExport(); break; case "iif": new PurchasesIIFExport(); break; default: new PurchasesTabExport(); } exit(); }
public function updatePurchase($Id, &$amount) { $model = Purchase::model()->findByPk($Id); $amount = $model->amount; $ttlamount = 0; foreach($model->purchaseproducts as $product) { $ttlamount += $product->amount; } $model->amount= $ttlamount; $status = $model->save(); if($status) { $amount = $ttlamount; } return $status; }
public function getCallData() { return parent::getCallData(); }
public function executeGeneratePurchase(sfWebRequest $request) { $invoice = Doctrine_Query::create()->from('Invoice i')->where('i.id = ' . $request->getParameter('id'))->fetchOne(); //create purchase $purchase = new Purchase(); $purchase->setDate(date("Y-m-d")); $purchase->setPono(date('h:i:s a')); $purchase->save(); //create purchase details foreach ($invoice->getInvoicedetail() as $invdetail) { $purchdetail = new PurchaseDetail(); $purchdetail->setPurchaseId($purchase->getId()); $purchdetail->setProductId($invdetail->getProductId()); $purchdetail->setDescription($invdetail->getProduct()->getName()); $purchdetail->setQty($invdetail->getQty()); $purchdetail->setPrice(0); $purchdetail->setTotal(0); $purchdetail->setUnittotal(0); $purchdetail->save(); $purchdetail->updateStockentry(); } $this->redirect("purchase/view?id=" . $purchase->getId()); }
public function testPurchase() { $mediator = new Mediator(); $purchase = new Purchase($mediator); $purchase->buyIBMComputer(100); }
<?php // Check if there is a request to see product detail. if (isset($_GET['item']) || isset($_POST['qty'])) { require_once 'model/productPage.php'; require_once 'view/productPage.php'; $product = new productPage($_GET['item'], $session); $product->setContent(); $purchase = null; // Check for purchase request if (isset($_POST['qty'])) { require_once 'model/purchase.php'; $purchase = new Purchase($session); $purchase->getCid(); $purchase->input($_POST['selection'], $_POST['qty']); $boxMsg = $purchase->boxMsg; $errMsg = $purchase->errMsg; } $productView = new productPageView($product, $session, $purchase); $productView->output(); } else { if (isset($_GET['filtered'])) { } else { require_once 'model/itemTile.php'; require_once 'view/itemTile.php'; $tile = new itemTile($session); $tile->setContent(); $tilePanel = new itemTileView($tile); $tilePanel->output(); } }
/** * Sets transaction information to create the purchase record * * @since 1.1 * * @param string $id Transaction ID * @param string $status (optional) Transaction status (PENDING, CHARGED, VOID, etc) * @param float $fees (optional) Transaction fees assesed by the processor * * @return true **/ function transaction ($id,$status="PENDING",$fees=0) { $this->txnid = $id; $this->txnstatus = $status; $this->fees = $fees; if (empty($this->txnid)) return new EcartError(sprintf('The payment gateway %s did not provide a transaction id. Purchase records cannot be created without a transaction id.',$this->gateway),'ecart_order_transaction',ECART_DEBUG_ERR); $Purchase = new Purchase($this->txnid,'txnid'); if (!empty($Purchase->id)) $Purchase->save(); else do_action('ecart_create_purchase'); return true; }
function shopp_transaction_tracking($push) { global $Shopp; // Only process if we're in the checkout process (receipt page) if (version_compare(substr(SHOPP_VERSION, 0, 3), '1.1') >= 0) { // Only process if we're in the checkout process (receipt page) if (function_exists('is_shopp_page') && !is_shopp_page('checkout')) { return $push; } if (empty($Shopp->Order->purchase)) { return $push; } $Purchase = new Purchase($Shopp->Order->purchase); $Purchase->load_purchased(); } else { // For 1.0.x // Only process if we're in the checkout process (receipt page) if (function_exists('is_shopp_page') && !is_shopp_page('checkout')) { return $push; } // Only process if we have valid order data if (!isset($Shopp->Cart->data->Purchase)) { return $push; } if (empty($Shopp->Cart->data->Purchase->id)) { return $push; } $Purchase = $Shopp->Cart->data->Purchase; } $push[] = "'_addTrans'," . "'" . $Purchase->id . "'," . "'" . GA_Filter::ga_str_clean(get_bloginfo('name')) . "'," . "'" . number_format($Purchase->total, 2) . "'," . "'" . number_format($Purchase->tax, 2) . "'," . "'" . number_format($Purchase->shipping, 2) . "'," . "'" . $Purchase->city . "'," . "'" . $Purchase->state . "'," . "'.{$Purchase->country}.'"; // Country foreach ($Purchase->purchased as $item) { $sku = empty($item->sku) ? 'PID-' . $item->product . str_pad($item->price, 4, '0', STR_PAD_LEFT) : $item->sku; $push[] = "'_addItem'," . "'" . $Purchase->id . "'," . "'" . $sku . "'," . "'" . str_replace("'", "", $item->name) . "'," . "'" . $item->optionlabel . "'," . "'" . number_format($item->unitprice, 2) . "'," . "'" . $item->quantity . "'"; } $push[] = "'_trackTrans'"; return $push; }
var target_text = $(v).find('td:eq(1)').text(); target_text = target_text.toLowerCase(); if(target_text.indexOf(this_text) != -1){ i++; obj.find('td:first').text(i); obj.removeClass('hide'); }else{ obj.addClass('hide'); } }); }); }); </script> <?php include_once "api/purchase.php"; $Purchase = new Purchase(); $Purcahses = $Purchase->getPurchases(); ?> <div class="container"> <div class="page-header"> <h2>Purchase <small>Order by date</small></h2> </div> <table class="table table-hover table-condensed"> <caption><h2>Purchase Table</h2></caption> <thead> <tr> <th width="20px">#</th> <th>Name</th> <th>Product</th>
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model=Purchase::model()->findByPk($id); if($model===null) throw new CHttpException(404,'The requested page does not exist.'); return $model; }
<p class="form-title">Compras por Pagar</p> <?php if (!Forms::checkPermission(FORM_PURCHASE_PAYABLE)) { return; } require 'inc/class.purchase.php'; require 'inc/class.formatter.php'; $purchases = Purchase::getAllOutstanding("`date`", "DESC"); ?> <table class="default"> <thead> <tr> <th style="width:8em">Código</th> <th style="width:8em">Fecha</th> <th style="width:12em">Proveedor</th> <th>Estado</th> <th>Observación</th> <th style="width:8em">Monto <?php echo SB_CURRENCY; ?> </th> <th style="width:8em">Saldo <?php echo SB_CURRENCY; ?> </th> <th colspan="2"> </th> </tr> </thead> <tbody> <?php
public function __construct() { parent::__construct(); }
/** * Orders admin flow handlers */ function orders_list() { global $Shopp, $Orders; $db = DB::get(); $defaults = array('page' => false, 'deleting' => false, 'selected' => false, 'update' => false, 'newstatus' => false, 'pagenum' => 1, 'per_page' => false, 'start' => '', 'end' => '', 'status' => false, 's' => '', 'range' => '', 'startdate' => '', 'enddate' => ''); $args = array_merge($defaults, $_GET); extract($args, EXTR_SKIP); if (!current_user_can(SHOPP_USERLEVEL)) { wp_die(__('You do not have sufficient permissions to access this page.', 'Shopp')); } if ($page == "shopp-orders" && !empty($deleting) && !empty($selected) && is_array($selected)) { foreach ($selected as $selection) { $Purchase = new Purchase($selection); $Purchase->load_purchased(); foreach ($Purchase->purchased as $purchased) { $Purchased = new Purchased($purchased->id); $Purchased->delete(); } $Purchase->delete(); } } $statusLabels = $this->Settings->get('order_status'); if (empty($statusLabels)) { $statusLabels = array(''); } $txnStatusLabels = array('PENDING' => __('Pending', 'Shopp'), 'CHARGED' => __('Charged', 'Shopp'), 'REFUNDED' => __('Refunded', 'Shopp'), 'VOID' => __('Void', 'Shopp')); if ($update == "order" && !empty($selected) && is_array($selected)) { foreach ($selected as $selection) { $Purchase = new Purchase($selection); $Purchase->status = $newstatus; $Purchase->save(); } } $Purchase = new Purchase(); if (!empty($start)) { $startdate = $start; list($month, $day, $year) = explode("/", $startdate); $starts = mktime(0, 0, 0, $month, $day, $year); } if (!empty($end)) { $enddate = $end; list($month, $day, $year) = explode("/", $enddate); $ends = mktime(23, 59, 59, $month, $day, $year); } $pagenum = absint($pagenum); if (empty($pagenum)) { $pagenum = 1; } if (!$per_page || $per_page < 0) { $per_page = 20; } $start = $per_page * ($pagenum - 1); $where = ''; if (!empty($status) || $status === '0') { $where = "WHERE status='{$status}'"; } if (!empty($s)) { $s = stripslashes($s); if (preg_match_all('/(\\w+?)\\:(?="(.+?)"|(.+?)\\b)/', $s, $props, PREG_SET_ORDER) > 0) { foreach ($props as $search) { $keyword = !empty($search[2]) ? $search[2] : $search[3]; switch (strtolower($search[1])) { case "txn": $where .= (empty($where) ? "WHERE " : " AND ") . "transactionid='{$keyword}'"; break; case "gateway": $where .= (empty($where) ? "WHERE " : " AND ") . "gateway LIKE '%{$keyword}%'"; break; case "cardtype": $where .= (empty($where) ? "WHERE " : " AND ") . "cardtype LIKE '%{$keyword}%'"; break; case "address": $where .= (empty($where) ? "WHERE " : " AND ") . "(address LIKE '%{$keyword}%' OR xaddress='%{$keyword}%')"; break; case "city": $where .= (empty($where) ? "WHERE " : " AND ") . "city LIKE '%{$keyword}%'"; break; case "province": case "state": $where .= (empty($where) ? "WHERE " : " AND ") . "state='{$keyword}'"; break; case "zip": case "zipcode": case "postcode": $where .= (empty($where) ? "WHERE " : " AND ") . "postcode='{$keyword}'"; break; case "country": $where .= (empty($where) ? "WHERE " : " AND ") . "country='{$keyword}'"; break; } } if (empty($where)) { $where .= (empty($where) ? "WHERE " : " AND ") . " (id='{$s}' OR CONCAT(firstname,' ',lastname) LIKE '%{$s}%')"; } } elseif (strpos($s, '@') !== false) { $where .= (empty($where) ? "WHERE " : " AND ") . " email='{$s}'"; } else { $where .= (empty($where) ? "WHERE " : " AND ") . " (id='{$s}' OR CONCAT(firstname,' ',lastname) LIKE '%{$s}%')"; } } if (!empty($starts) && !empty($ends)) { $where .= (empty($where) ? "WHERE " : " AND ") . ' (UNIX_TIMESTAMP(created) >= ' . $starts . ' AND UNIX_TIMESTAMP(created) <= ' . $ends . ')'; } $ordercount = $db->query("SELECT count(*) as total,SUM(total) AS sales,AVG(total) AS avgsale FROM {$Purchase->_table} {$where} ORDER BY created DESC"); $query = "SELECT * FROM {$Purchase->_table} {$where} ORDER BY created DESC LIMIT {$start},{$per_page}"; $Orders = $db->query($query, AS_ARRAY); $num_pages = ceil($ordercount->total / $per_page); $page_links = paginate_links(array('base' => add_query_arg('pagenum', '%#%'), 'format' => '', 'total' => $num_pages, 'current' => $pagenum)); $ranges = array('all' => __('Show All Orders', 'Shopp'), 'today' => __('Today', 'Shopp'), 'week' => __('This Week', 'Shopp'), 'month' => __('This Month', 'Shopp'), 'quarter' => __('This Quarter', 'Shopp'), 'year' => __('This Year', 'Shopp'), 'yesterday' => __('Yesterday', 'Shopp'), 'lastweek' => __('Last Week', 'Shopp'), 'last30' => __('Last 30 Days', 'Shopp'), 'last90' => __('Last 3 Months', 'Shopp'), 'lastmonth' => __('Last Month', 'Shopp'), 'lastquarter' => __('Last Quarter', 'Shopp'), 'lastyear' => __('Last Year', 'Shopp'), 'lastexport' => __('Last Export', 'Shopp'), 'custom' => __('Custom Dates', 'Shopp')); $exports = array('tab' => __('Tab-separated.txt', 'Shopp'), 'csv' => __('Comma-separated.csv', 'Shopp'), 'xls' => __('Microsoft® Excel.xls', 'Shopp'), 'iif' => __('Intuit® QuickBooks.iif', 'Shopp')); $formatPref = $Shopp->Settings->get('purchaselog_format'); if (!$formatPref) { $formatPref = 'tab'; } $columns = array_merge(Purchase::exportcolumns(), Purchased::exportcolumns()); $selected = $Shopp->Settings->get('purchaselog_columns'); if (empty($selected)) { $selected = array_keys($columns); } include "{$this->basepath}/core/ui/orders/orders.php"; }
public function done() { $taskdetails_id = Input::get('taskdetails_id'); $taskd = TaskDetails::find($taskdetails_id); $taskd->status = "Done"; $docs = Document::find($taskd->doc_id); $id = $docs->pr_id; $delcount = Count::where('doc_id', $docs->id)->delete(); $users = User::get(); foreach ($users as $user) { $count = new Count(); $count->user_id = $user->id; $count->doc_id = $docs->id; $count->save(); } $birth = new DateTime($taskd->dateReceived); $today = new DateTime(); $diff = $birth->diff($today); $aDays = $diff->format('%d'); $taskd->daysOfAction = $aDays; $taskd->dateFinished = $today; $taskd->save(); date_default_timezone_set("Asia/Manila"); $upDate = date('Y-m-d H:i:s'); DB::table('purchase_request')->where('id', $id)->update(array('updated_at' => $upDate)); $tasknext = TaskDetails::find($taskdetails_id + 1); if ($tasknext->doc_id == $taskd->doc_id) { $counter = 1; $tasknext = TaskDetails::find($taskdetails_id + $counter); while ($tasknext->status == "Lock") { $counter = $counter + 1; $tasknext = TaskDetails::find($taskdetails_id + $counter); } $tasknext->status = "New"; $tasknext->save(); } else { $purchase = Purchase::find($docs->pr_id); $purchase->status = "Closed"; $purchase->save(); } $request_id = Input::get('pr_id'); return Redirect::to("purchaseRequest/vieweach/{$request_id}"); }
$app->delete('/shoppingcart', function ($request, $response, $args) { return json_encode(Shoppingcart::clean()); }); // Delete Product Shopping Cart // Remove a specific product of the shopping cart $app->delete('/shoppingcart/{id}', function ($request, $response, $args) { Shoppingcart::removeProduct($args['id']); return json_encode(Shoppingcart::countProducts()); }); // Get Count Shopping Cart // Return the count of products in the shopping cart $app->get('/shoppingcart/count', function ($request, $response, $args) { return json_encode(Shoppingcart::countProducts()); }); // Post Quantity Product // Update quantity of the product in shopping cart $app->post('/shoppingcart/{id}', function ($request, $response, $args) { $data = $request->getParsedBody(); return json_encode(Shoppingcart::updateQuantityProduct($args['id'], $data['quantity'])); }); // Post Shopping Cart // Purchase shopping cart $app->post('/shoppingcart', function ($request, $response, $args) { $data = $request->getParsedBody(); if (count($data['shoppingcart']['products'])) { $purchase = new Purchase(); $purchase->loadPropierties($data); Shoppingcart::clean(); return json_encode(true); } });