/** * @param array $data * @return $this */ public function bindData($data = array()) { if (!$this->getOrder()->id) { JBCart::getInstance()->setModifier($this->identifier, $data); } return parent::bindData($data); }
/** * @param bool $addNoindex * @return string */ public function render($addNoindex = true) { if (!JBCart::getInstance()->canAccess($this->app->user->get())) { return JText::_('JBZOO_CART_UNABLE_ACCESS'); } return parent::render($addNoindex); }
/** * @param $code */ public function ajaxSetCode($code = null) { $this->bindData(array('code' => $code)); $inList = $this->_isInList(); $result = array('cart' => JBCart::getInstance()->recount()); if (!$inList) { $result['message'] = JText::_('JBZOO_ELEMENT_MODIFIERORDERPRICE_DISCOUNTCODE_NOTFOUND'); $this->bindData(array('code' => '')); } $this->app->jbajax->send($result, $inList); }
/** * Action for robot from payment system * Validate and check order as success * @throws AppException */ public function paymentCallback() { $this->_init(); $this->app->jbevent->fire($this->order, 'basket:paymentCallback'); $this->app->jbdoc->rawOutput(); $cart = JBCart::getInstance(); /** @type JBCartElementPayment $payment */ $payment = $this->order->getPayment(); // check payment element if (empty($payment)) { $this->_error('Saved without payment element'); } // payment is exists if (!$this->_orderInfo->get('type')) { $this->_error('Undefined payment system'); } // check payment type if ($payment->getType() != $this->_orderInfo->get('type')) { $this->_error('Payment type is not correct'); } // current status is not completed if ($payment->getStatus() == $cart->getPaymentSuccess()) { $this->_error('Payment status is "' . $payment->getStatus()->getCode() . '" already'); } // check sum $realSum = $payment->getOrderSumm(); $requestSum = $payment->getRequestOrderSum(); if ($realSum->compare($requestSum, '!=', 5)) { $this->_error('Not correct amount'); } // check if sum was empty if ($realSum->compare(0, '<=')) { $this->_error('Amount less or equal zero'); } // checking of payment element if ($payment->isValid()) { $payment->setSuccess(); $this->app->event->dispatcher->notify($this->app->event->create($this->order, 'basket:paymentSuccess')); $payment->renderResponse(); } else { $this->_error('No valid request'); } }
/** * Add to cart * @return $this */ public function addToCart() { JBCart::getInstance()->addItem($this->_getCartData()); return $this; }
/** * Default params to Call Service. * @return array */ public function _getDefaultParams() { $prop = $this->getCartProperties(); $params = array('city' => $this->_getDefaultCity(), 'weight' => JBCart::getInstance()->getWeight(), 'height' => $prop['height'], 'width' => $prop['width'], 'depth' => $prop['length'], 'date' => date('Y-m-d H:i:s')); return $params; }
/** * @param array $filter * @return array */ public function getList($filter = array()) { $select = $this->_getSelectByCond($filter); // create objects and bind data $rows = $this->fetchAll($select, true); $result = array(); if (!empty($rows)) { foreach ($rows as $row) { $order = JBCart::getInstance()->newOrder(); $order->setData($row); $result[$order->id] = $order; } } return $result; }
/** * Include JBZoo Tools script */ public function tools() { static $isAdded = false; if (!$isAdded) { $isAdded = true; $this->jQuery(); $this->addScript(implode("\n\t", array('JBZoo.DEBUG = ' . (int) JDEBUG . ';', 'jQuery.migrateMute = false;')), false); $this->js(array('jbassets:js/libs/browser.min.js', 'jbassets:js/libs/cookie.min.js', 'jbassets:js/libs/sweet-alert.min.js', 'jbassets:js/helper.js', 'jbassets:js/widget.js', 'jbassets:js/jbzoo.js'), self::GROUP_LIBRARY); $this->js(array('jbassets:js/widget/goto.js', 'jbassets:js/widget/select.js', 'jbassets:js/widget/money.js', 'jbassets:js/widget/heightfix.js')); $this->css(array('jbassets:css/libs/sweet-alert.css'), self::GROUP_LIBRARY); if ($this->app->jbenv->isSite()) { $cartItems = JBCart::getInstance()->getItems(); $this->addVar('currencyList', $this->app->jbmoney->getData()); $this->addVar('cartItems', $this->app->jbarray->map($cartItems, 'element_id', 'element_id', 'item_id')); } $this->addVar('JBZOO_DIALOGBOX_OK', JText::_('JBZOO_DIALOGBOX_OK')); $this->addVar('JBZOO_DIALOGBOX_CANCEL', JText::_('JBZOO_DIALOGBOX_CANCEL')); $this->widget('.jbzoo .jsGoto', 'JBZoo.Goto'); $this->widget('.jbzoo select', 'JBZoo.Select'); } }
/** * @param $identifier * @return JBCartElementShipping */ protected function _getElement($identifier) { $shippingList = JBCart::getInstance()->getShippingList(); if ($shipping = $this->_order->getShippingElement($identifier)) { if (isset($shippingList[$identifier])) { $shipping->bindData($shippingList[$identifier]); } } return $shipping; }
/** * Get session key and check if variant is in cart * @param AppData|array $params * @return array */ protected function _interfaceParams($params = array()) { $cart = JBCart::getInstance(); $key = $this->getJBPrice()->getList()->getSessionKey(); return array('key' => $key, 'item_id' => $this->item_id, 'element_id' => $this->element_id, 'isModal' => $this->_isModal(), 'basket' => $this->_getBasketUrl(), 'isInCart' => (int) $cart->inCart($this->item_id, $this->element_id)); }
<?php /** * JBZoo App is universal Joomla CCK, application for YooTheme Zoo component * @package jbzoo * @version 2.x Pro * @author JBZoo App http://jbzoo.com * @copyright Copyright (C) JBZoo.com, All rights reserved. * @license http://jbzoo.com/license-pro.php JBZoo Licence * @coder Sergey Kalistratov <*****@*****.**> */ // no direct access defined('_JEXEC') or die('Restricted access'); $this->app->jbassets->less('jbassets:less/cart/mobile-tools.less'); $order = JBCart::getInstance()->newOrder(); ?> <div class="jbcart-mobile-tools"> <div class="jbtool-total-price"> <span class="jbtool-label"><?php echo JText::_('JBZOO_CART_TOTAL_SUM'); ?> :</span> <span class="jbtool-value jsTotal"><?php echo $order->getTotalSum()->html(); ?> </span> </div> <?php echo $this->partial('basket', 'mobile_buttons');
/** * Set success payment status to order */ public function setSuccess() { $order = $this->getOrder(); $payment = $order->getPayment(); $cart = JBCart::getInstance(); if ($payment) { $successStatus = $cart->getPaymentSuccess(); $payment->setStatus($successStatus); JBModelOrder::model()->save($order); } }
/** * Remove from cart method * @param string $key - Session key * @return mixed */ public function ajaxRemoveFromCart($key = null) { if (!(int) $this->config->get('remove_variant', 0)) { $key = null; } $item_id = $this->getItem()->id; $result = JBCart::getInstance()->remove($item_id, $this->identifier, $key); $this->app->jbajax->send(array('removed' => $result)); }
/** * JBZoo App is universal Joomla CCK, application for YooTheme Zoo component * @package jbzoo * @version 2.x Pro * @author JBZoo App http://jbzoo.com * @copyright Copyright (C) JBZoo.com, All rights reserved. * @license http://jbzoo.com/license-pro.php JBZoo Licence * @coder Alexander Oganov <*****@*****.**> */ // no direct access defined('_JEXEC') or die('Restricted access'); $this->app->jbassets->less('jbassets:less/cart/table.less'); $string = $this->app->jbstring; $jbhtml = $this->app->jbhtml; $cart = JBCart::getInstance(); $order = $cart->newOrder(); $config = $cart->getConfig(); $bootstrap = $this->app->jbbootstrap; echo $this->partial('basket', 'table.styles'); ?> <table class="jbcart-table jsJBZooCartTable"> <thead> <tr> <th class="jbcart-col jbcart-col-image"></th> <th class="jbcart-col jbcart-col-name"><?php echo JText::_('JBZOO_CART_ITEM_NAME'); ?> </th> <th class="jbcart-col jbcart-col-price"><?php
/** * Get modifiers rates * @return array */ public function getModifiersRates() { $cart = JBCart::getInstance(); $data = $cart->getItem($this->getSessionKey()); $order = $cart->newOrder(); $elements = $order->getModifiersItemPrice($this->_jbprice, $data); $modifiers = array(); if (!empty($elements)) { foreach ($elements as $id => $element) { $modifiers[$id] = (array) $element->getOrderData(); } } return $modifiers; }
/** * Method using to take data from element with ajax */ public function callElement() { // get request $group = $this->app->request->getCmd('group', ''); $elementId = $this->app->request->getCmd('element', ''); $orderId = $this->app->request->getInt('order_id', ''); $method = $this->app->request->getCmd('method', ''); $args = $this->app->request->getVar('args', array(), 'default', 'array'); if ($orderId > 0) { $order = JBModelOrder::model()->getById($orderId); } else { $order = JBCart::getInstance()->newOrder(); } if (empty($order)) { return $this->app->error->raiseError(404, JText::_('Order not found')); } // get element if ($group == JBCart::CONFIG_SHIPPINGS) { // custom init with session data $element = $order->getShippingElement($elementId); } elseif ($group == JBCart::CONFIG_MODIFIER_ORDER_PRICE) { // custom init with session data $element = $order->getModifierOrderPriceElement($elementId); } else { $element = $order->getElement($elementId, $group); } if (empty($element)) { return $this->app->error->raiseError(404, JText::_('Element not forund')); } if (!$element->canAccess($this->app->user->get())) { return $this->app->error->raiseError(403, JText::_('Unable to access item')); } $element->callback($method, $args); }
/** * Get order item list * @param bool $loadItem * @return JSONData */ public function getItems($loadItem = true) { $items = $this->_items; if (!$this->id) { $items = JBCart::getInstance()->getItems(); } $result = array(); foreach ($items as $key => $data) { if ($loadItem) { $item = $this->app->table->item->get($data['item_id']); $data['item'] = $item; } $result[$key] = $this->app->data->create($data); } $result = $this->app->data->create($result); return $result; }