/** * Method to getItem * @params type int id * @result products */ public function getItem() { $id = $this->getId(); $product = J2StoreHelperCart::getItemInfo($id); //set the correct quantity if (isset($product->min_sale_qty) && $product->min_sale_qty > 1 && J2STORE_PRO == 1) { $product->product_quantity = (int) $product->min_sale_qty; $product->item_minimum_notice = JText::sprintf('J2STORE_MINIMUM_QUANTITY_NOTIFICATION', $product->product_name, (int) $product->min_sale_qty); } else { $product->product_quantity = 1; } //include the model file path JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_j2store/models'); //create obj for cartmodel class $cart_model = JModelLegacy::getInstance('Mycart', 'J2StoreModel'); //now get the productoptions based on the id $attributes = $cart_model->getProductOptions($id); //let calcuate the product option based on the stock if (count($attributes) && $product->manage_stock == 1 && J2STORE_PRO == 1) { //get unavailable attribute options $attributes = $cart_model->processAttributeOptions($attributes, $product); } //assign the attributes $product->attributes = $attributes; //assign th prices $product->prices = J2StorePrices::getPrice($id, $product->product_quantity); if (J2STORE_PRO == 1 && $product->manage_stock == 1) { JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_j2store/models'); $qtyModel = JModelLegacy::getInstance('ProductQuantities', 'J2StoreModel'); $qtyModel->setState('filter_product', $product->product_id); $qtyModel->setState('filter_productid', $product->product_id); $product->option_stock = $qtyModel->getList(); $product->product_stock = $qtyModel->getQuantityTotal(); } else { $product->product_stock = 99; } $product->product = $product; $product->inventory = J2StoreInventory::isAllowed($product); //get all tags if (version_compare(JVERSION, '3.0', 'ge')) { $product->product_tags = $this->getProductTags($id); } $this->executePlugins($product); return $product; }
require_once JPATH_SITE . '/components/com_j2store/helpers/cart.php'; require_once JPATH_ADMINISTRATOR . '/components/com_j2store/library/select.php'; require_once JPATH_ADMINISTRATOR . '/components/com_j2store/library/inventory.php'; $action = JRoute::_('index.php?option=com_j2store&view=mycart'); if ($item->attribs) { $registry = new JRegistry(); $registry->loadString($item->attribs); $attribs = $registry->toObject(); } if (isset($attribs->item_cart_text) && JString::strlen($attribs->item_cart_text) > 0) { $cart_text = $attribs->item_cart_text; } else { $cart_text = JText::_('J2STORE_ADD_TO_CART'); } //Check for stock before displaying $inventoryCheck = J2StoreInventory::isAllowed($item); ?> <div id="j2store-product-<?php echo $item->product_id; ?> " class="j2store j2store-product-info"> <?php if (count(JModuleHelper::getModules('j2store-addtocart-top')) > 0) { ?> <div class="j2store_modules"> <?php echo J2StoreHelperModules::loadposition('j2store-addtocart-top'); ?> </div> <?php