</tr> </thead> <tbody> <?php $i = 0; $k = 0; $subtotal = 0; ?> <?php foreach ($items as $item) { ?> <?php $link = K2StoreItem::getK2Link($item->product_id); $link = JRoute::_($link); $image_path = K2StoreItem::getK2Image($item->product_id, $this->params); ?> <tr class="row<?php echo $k; ?> "> <td> <?php if ($this->params->get('show_thumb_cart')) { ?> <span class="pull-left k2store-cart-item-image"> <?php if (!empty($image_path)) { ?> <img src="<?php
public function getTerms() { $app = JFactory::getApplication(); $id = $app->input->getInt('k2item_id'); require_once JPATH_COMPONENT_ADMINISTRATOR . '/library/k2item.php'; $k2item = new K2StoreItem(); $data = $k2item->display($id); $view = $this->getView('checkout', 'html'); $view->set('_controller', 'checkout'); $view->set('_view', 'checkout'); $view->set('_doTask', true); $view->set('hidemenu', true); $view->assign('html', $data); $view->setLayout('checkout_terms'); ob_start(); $view->display(); $html = ob_get_contents(); ob_end_clean(); echo $html; $app->close(); }
function setquantities() { $app = JFactory::getApplication(); $product_id = $app->input->getInt('product_id'); $model = $this->getModel('productquantities'); $model->setState('filter_productid', $product_id); $items = $model->getAll(); $row = K2StoreItem::_getK2Item($product_id); K2StoreItem::doProductQuantitiesReconciliation($row->id); $ns = 'com_k2store.productquantities.setquantities'; $filter_order = $app->getUserStateFromRequest($ns . 'filter_order', 'filter_order', 'tbl.productquantity_id', 'cmd'); $filter_order_Dir = $app->getUserStateFromRequest($ns . 'filter_order_Dir', 'filter_order_Dir', '', 'word'); // table ordering $model->setState('direction', $filter_order_Dir); $model->setState('order', $filter_order); $view = $this->getView('productquantities', 'html'); $view->set('_controller', 'products'); $view->set('_view', 'productquantities'); $view->set('_action', "index.php?option=com_k2store&view=products&task=setquantities&product_id={$row->id}&tmpl=component"); $view->setModel($model, true); $view->assign('state', $model->getState()); $view->assign('row', $row); $view->assign('items', $model->getList()); $view->setLayout('setquantities'); $view->display(); }
echo $image_path; ?> " class="itemImg<?php echo $this->params->get('cartimage_size', 'small'); ?> " /> <?php } ?> </td> <?php } ?> <td><a href="<?php echo JRoute::_(K2StoreItem::getK2Link($item->product_id)); ?> "> <?php echo JText::_($item->orderitem_name); ?> </a> <br /> <!-- start of orderitem attributes --> <!-- backward compatibility --> <?php if (!K2StoreOrdersHelper::isJSON(stripslashes($item->orderitem_attribute_names))) { ?> <?php
<th><?php echo JText::_("K2STORE_CARTSUMMARY_TOTAL"); ?> </th> </tr> </thead> <tbody> <?php $i = 0; $k = 0; ?> <?php foreach ($items as $item) { ?> <?php $link = K2StoreItem::getK2Link($item->product_id); ?> <tr class="row<?php echo $k; ?> "> <td> <a href="<?php echo JRoute::_($link); ?> "><?php echo $item->orderitem_name; ?> </a> x <?php
public function getRate($shipping_method_id, $product_id = '', $use_weight = '0', $weight = '0') { // TODO Give this better error reporting capabilities JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_k2store' . DS . 'models'); $model = JModelLegacy::getInstance('ShippingRates', 'K2StoreModel'); $model->setState('filter_shippingmethod', $shipping_method_id); JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_k2store' . DS . 'tables'); require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_k2store' . DS . 'library' . DS . 'k2item.php'; $product_helper = new K2StoreItem(); $isShips = $product_helper->isShippingEnabled($product_id); if (empty($isShips)) { // product doesn't require shipping, therefore cannot impact shipping costs return JTable::getInstance('ShippingRates', 'Table'); } if (!empty($use_weight) && $use_weight == '1') { if (!empty($weight)) { $model->setState('filter_weight', $weight); } } $items = $model->getList(); if (empty($items)) { return JTable::getInstance('ShippingRates', 'Table'); } return $items[0]; }
/** * This displays the content article * specified in the plugin's params * * @return unknown_type */ function _displayArticle() { $html = ''; $articleid = $this->params->get('articleid'); if ($articleid) { require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_k2store' . DS . 'library' . DS . 'k2item.php'; $html = K2StoreItem::display($articleid); } return $html; }
public function getShippingIsEnabled() { $model = JModelLegacy::getInstance('MyCart', 'K2StoreModel'); $list = $model->getDataNew(); // If no item in the list, return false if (empty($list)) { return false; } require_once JPATH_ADMINISTRATOR . '/components/com_k2store/library/k2item.php'; $product_helper = new K2StoreItem(); foreach ($list as $item) { $shipping = $product_helper->isShippingEnabled($item['product_id']); if ($shipping) { return true; } } return false; }
public static function getAvailableQuantity($id, $attribute) { $db = JFactory::getDbo(); $query = $db->getQuery(true); $tableQuantity = JTable::getInstance('ProductQuantities', 'Table'); $tableProduct = JTable::getInstance('Products', 'Table'); $K2Item = K2StoreItem::_getK2Item($id); $tableProduct->load(array('product_id' => $id)); if (!isset($tableProduct->manage_stock) || $tableProduct->manage_stock == 0) { $tableProduct->quantity = '9999'; return $tableProduct; } $select[] = "quantities.quantity"; $select[] = "product.manage_stock"; $query->select($select); $query->from($tableProduct->getTableName() . " AS product"); $leftJoinCondition = $tableQuantity->getTableName() . " as quantities ON product.product_id = quantities.product_id "; $query->leftJoin($leftJoinCondition); $whereClause[] = "quantities.product_id = " . (int) $id; $whereClause[] = "quantities.product_attributes='" . $attribute . "'"; $whereClause[] = "product.manage_stock =1 "; $query->where($whereClause, "AND"); $db = JFactory::getDBO(); $db->setQuery((string) $query); $item = $db->loadObject(); if (empty($item)) { $return = new JObject(); $return->product_id = $id; $return->product_name = $K2Item->title; $return->quantity = 0; $return->manage_stock = $tableProduct->manage_stock; return $return; } return $item; }
/** * Adds any necessary _productsquantities records * * @param unknown_type $product_id * Product ID * @param unknown_type $vendor_id * Vendor ID * @param array $items * Array of productQuantities objects * @param unknown_type $csvs * CSV output from getProductAttributeCSVs * @return array $items Array of objects */ static function reconcileProductAttributeCSVs($product_id, $vendor_id, $items, $csvs) { // remove extras $done = array(); foreach ($items as $key => $item) { if (!in_array($item->product_attributes, $csvs) || in_array($item->product_attributes, $done)) { $row = JTable::getInstance('ProductQuantities', 'Table'); if (!$row->delete($item->productquantity_id)) { JError::raiseNotice('1', $row->getError()); } unset($items[$key]); } $done[] = $item->product_attributes; } // add new ones $existingEntries = K2StoreItem::getColumn($items, 'product_attributes'); JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_k2store/tables'); foreach ($csvs as $csv) { if (!in_array($csv, $existingEntries)) { $row = JTable::getInstance('ProductQuantities', 'Table'); $row->product_id = $product_id; $row->product_attributes = $csv; if (!$row->save()) { JError::raiseNotice('1', $row->getError()); } $items[] = $row; } } return $items; }