public function widget() { $cart = new CartModel(); $cart->loadCurrent(); $items = $cart->getItems(); // Prevent caching when called in body format $this->touchCache($items); $this->getView()->assign('quickcheckout', $this->hasId() && $this->getId() == 'quickcheckout'); $this->getView()->assign('items', $items); return $this->render(); }
public static function mergeUserToClient() { if ($user = Ajde_User::getLoggedIn()) { // Do we have a saved cart for logged in user? $userCart = new CartModel(); if ($userCart->loadByUser($user)) { // Do we have a saved cart for client? $clientCart = new CartModel(); if ($clientCart->loadByClient() === false) { $clientCart->client = md5($_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT']); $clientCart->insert(); } foreach ($userCart->getItems() as $item) { /* @var $item Ajde_Shop_Cart_Item */ $clientCart->addItem($item->getEntity(), null, $item->getQty()); } $userCart->delete(); } } }
public function updateFromCart(Ajde_Shop_Transaction $transaction) { $cart = new CartModel(); $cart->loadCurrent(); if ($cart->countItems() > 0) { $transaction->shipment_description = $cart->getHtmlSummaryTable(); $transaction->shipment_itemsqty = $cart->countQty(); $transaction->shipment_itemsvatamount = $cart->getItems()->getVATAmount(); $transaction->shipment_itemstotal = $cart->getItems()->getTotal(); $transaction->payment_amount = $transaction->shipment_itemstotal + $transaction->shipment_cost; } else { $transaction->shipment_description = ''; $transaction->shipment_itemsqty = 0; $transaction->shipment_itemsvatamount = 0; $transaction->shipment_itemstotal = 0; $transaction->payment_amount = 0; } $transaction->setItemsFromCart($cart); $transaction->save(); }