function onBeforeRender() { if ($this->app->isAdmin()) { return; } $app = JFactory::getApplication(); $option = $app->input->get('option'); $view = $app->input->get('view'); $tmpl = $app->input->get('tmpl'); $document = JFactory::getDocument(); if ($app->isSite() && $tmpl != 'component') { if (!defined('SMART_JQUERY') && (int) $this->params->get('include_jquery', '1')) { $document->addScript(JURI::root(true) . '/plugins/system/plg_sj_vm_quickview/assets/js/jquery-1.8.2.min.js'); $document->addScript(JURI::root(true) . '/plugins/system/plg_sj_vm_quickview/assets/js/jquery-noconflict.js'); define('SMART_JQUERY', 1); } if (!class_exists('VmConfig')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php'; } VmConfig::loadConfig(); if (class_exists('vmJsApi')) { vmJsApi::jPrice(); } $document->addScript(JURI::root(true) . '/plugins/system/plg_sj_vm_quickview/assets/js/jquery.fancybox.js'); $document->addStyleSheet(JURI::root(true) . '/plugins/system/plg_sj_vm_quickview/assets/css/jquery.fancybox.css'); $document->addStyleSheet(JURI::root(true) . '/plugins/system/plg_sj_vm_quickview/assets/css/quickview.css'); } return true; }
static function store($config, $item) { // Load the language file of com_virtuemart. JFactory::getLanguage()->load('com_virtuemart'); // Load path constant if (!defined('VMPATH_ADMIN')) { define('VMPATH_ADMIN', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart'); } // Load VM configuration if necessary if (!class_exists('VmConfig')) { require JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php'; VmConfig::loadConfig(); } // load necessary classes if (!class_exists('calculationHelper')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'calculationh.php'; } if (!class_exists('CurrencyDisplay')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'currencydisplay.php'; } if (!class_exists('VirtueMartModelVendor')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'models' . DS . 'vendor.php'; } if (!class_exists('VmImage')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'image.php'; } if (!class_exists('shopFunctionsF')) { require JPATH_SITE . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'shopfunctionsf.php'; } if (!class_exists('calculationHelper')) { require JPATH_COMPONENT_SITE . DS . 'helpers' . DS . 'cart.php'; } if (!class_exists('VirtueMartModelProduct')) { JLoader::import('product', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'models'); } // load the base $productModel = new VirtueMartModelProduct(); $product = $productModel->getProduct($item['id'], 100, true, true, true); $currency = CurrencyDisplay::getInstance(); $price = '<strong>' . $currency->createPriceDiv($config['vm_show_price_type'], '', $product->prices, true) . '</strong>'; if ($config['vm_add_to_cart'] == 1 && JRequest::getCmd('option') != 'com_virtuemart') { vmJsApi::jPrice(); vmJsApi::addJScript('facebox'); vmJsApi::css('facebox'); vmJsApi::writeJS(); } $news_price = '<div>'; // if ($config['vm_show_price_type'] != 'none') { if ($config['vm_display_type'] == 'text_price') { $news_price .= '<span>' . JText::_('MOD_NEWS_PRO_GK5_PRODUCT_PRICE') . ' ' . $price . '</span>'; } else { $news_price .= '<span>' . $price . '</span>'; } } // 'Add to cart' button if ($config['vm_add_to_cart'] == 1) { if (isset($product->customfields) && count($product->customfields)) { foreach ($product->customfields as $field) { if (isset($field->is_cart_attribute) && $field->is_cart_attribute == 1 || isset($field->layout_pos) && $field->layout_pos == 'addtocart') { $product->orderable = 0; break; } } } $code = '<div class="addtocart-area">'; if ($product->orderable != 0) { $code .= '<form method="post" class="product" action="index.php">'; } else { $code .= '<form method="post" class="product-variant" action="' . static::itemLink($item, $config) . '">'; } $code .= '<div class="addtocart-bar">'; $code .= '<span class="quantity-box" style="display: none"><input type="text" class="quantity-input" name="quantity[]" value="1" /></span>'; $addtoCartButton = ''; if ($product->addToCartButton) { $addtoCartButton = $product->addToCartButton; } else { $addtoCartButton = shopFunctionsF::getAddToCartButton($product->orderable); } $code .= str_replace('addtocart-button-disabled"', 'addtocart-button" type="submit"', $addtoCartButton); if ($product->orderable != 0) { $code .= '</div> <input type="hidden" class="pname" value="' . $product->product_name . '"/> <input type="hidden" name="option" value="com_virtuemart" /> <input type="hidden" name="view" value="cart" /> <noscript><input type="hidden" name="task" value="add" /></noscript> <input type="hidden" name="virtuemart_product_id[]" value="' . $product->virtuemart_product_id . '" /> <input type="hidden" name="virtuemart_category_id[]" value="' . $product->virtuemart_category_id . '" /> </form>'; } else { $code .= '</div></form>'; } $code .= '</div>'; $news_price .= $code; } // display discount if ($config['vm_show_discount_amount'] == 1) { $disc_amount = $currency->priceDisplay($product->prices['discountAmount'], $currency->getId()); $news_price .= '<small class="nspDiscount">' . JText::_('MOD_NEWS_PRO_GK5_PRODUCT_DISCOUNT_AMOUNT') . $disc_amount . '</small>'; } // display tax if ($config['vm_show_tax'] == 1) { $taxAmount = $currency->priceDisplay($product->prices['taxAmount'], $currency->getId()); $news_price .= '<small class="nspTax">' . JText::_('MOD_NEWS_PRO_GK5_PRODUCT_TAX_AMOUNT') . $taxAmount . '</small>'; } // results return $news_price != '<div>' ? $news_price . '</div>' : ''; }
/** * Collect all data to show on the template * * @author RolandD, Max Milbers */ function display($tpl = null) { //TODO get plugins running // $dispatcher = JDispatcher::getInstance(); // $limitstart = JRequest::getVar('limitstart', 0, '', 'int'); VmConfig::loadJLang('com_virtuemart', true); $show_prices = VmConfig::get('show_prices', 1); if ($show_prices == '1') { if (!class_exists('calculationHelper')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php'; } } $this->assignRef('show_prices', $show_prices); $document = JFactory::getDocument(); // add javascript for price and cart, need even for quantity buttons, so we need it almost anywhere vmJsApi::jPrice(); $mainframe = JFactory::getApplication(); $pathway = $mainframe->getPathway(); $task = JRequest::getCmd('task'); if (!class_exists('VmImage')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'image.php'; } // Load the product //$product = $this->get('product'); //Why it is sensefull to use this construction? Imho it makes it just harder $product_model = VmModel::getModel('product'); $this->assignRef('product_model', $product_model); $virtuemart_product_idArray = JRequest::getVar('virtuemart_product_id', 0); if (is_array($virtuemart_product_idArray) and count($virtuemart_product_idArray) > 0) { $virtuemart_product_id = (int) $virtuemart_product_idArray[0]; } else { $virtuemart_product_id = (int) $virtuemart_product_idArray; } $quantityArray = JRequest::getVar('quantity', array()); //is sanitized then JArrayHelper::toInteger($quantityArray); $quantity = 1; if (!empty($quantityArray[0])) { $quantity = $quantityArray[0]; } $product = $product_model->getProduct($virtuemart_product_id, TRUE, TRUE, TRUE, $quantity); if (!class_exists('shopFunctionsF')) { require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php'; } $last_category_id = shopFunctionsF::getLastVisitedCategoryId(); if (empty($product->slug)) { //Todo this should be redesigned to fit better for SEO $mainframe->enqueueMessage(JText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND')); $categoryLink = ''; if (!$last_category_id) { $last_category_id = JRequest::getInt('virtuemart_category_id', false); } if ($last_category_id) { $categoryLink = '&virtuemart_category_id=' . $last_category_id; } if (VmConfig::get('handle_404', 1)) { $mainframe->redirect(JRoute::_('index.php?option=com_virtuemart&view=category' . $categoryLink . '&error=404', FALSE)); } else { JError::raise(E_ERROR, '404', 'Not found'); } return; } if (!empty($product->customfields)) { foreach ($product->customfields as $k => $custom) { if (!empty($custom->layout_pos)) { $product->customfieldsSorted[$custom->layout_pos][] = $custom; unset($product->customfields[$k]); } } $product->customfieldsSorted['normal'] = $product->customfields; unset($product->customfields); } $product->event = new stdClass(); $product->event->afterDisplayTitle = ''; $product->event->beforeDisplayContent = ''; $product->event->afterDisplayContent = ''; if (VmConfig::get('enable_content_plugin', 0)) { shopFunctionsF::triggerContentPlugin($product, 'productdetails', 'product_desc'); } $product_model->addImages($product); $this->assignRef('product', $product); if (isset($product->min_order_level) && (int) $product->min_order_level > 0) { $min_order_level = $product->min_order_level; } else { $min_order_level = 1; } $this->assignRef('min_order_level', $min_order_level); if (isset($product->step_order_level) && (int) $product->step_order_level > 0) { $step_order_level = $product->step_order_level; } else { $step_order_level = 1; } $this->assignRef('step_order_level', $step_order_level); // Load the neighbours if (VmConfig::get('product_navigation', 1)) { $product->neighbours = $product_model->getNeighborProducts($product); } // Load the category $category_model = VmModel::getModel('category'); shopFunctionsF::setLastVisitedCategoryId($product->virtuemart_category_id); if ($category_model) { $category = $category_model->getCategory($product->virtuemart_category_id); $category_model->addImages($category, 1); $this->assignRef('category', $category); //Seems we dont need this anylonger, destroyed the breadcrumb if ($category->parents) { foreach ($category->parents as $c) { if (is_object($c) and isset($c->category_name)) { $pathway->addItem(strip_tags($c->category_name), JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $c->virtuemart_category_id, FALSE)); } else { vmdebug('Error, parent category has no name, breadcrumb maybe broken, category', $c); } } } $category->children = $category_model->getChildCategoryList($product->virtuemart_vendor_id, $product->virtuemart_category_id); $category_model->addImages($category->children, 1); } if (!empty($tpl)) { $format = $tpl; } else { $format = JRequest::getWord('format', 'html'); } if ($format == 'html') { // Set Canonic link $document->addHeadLink($product->canonical, 'canonical', 'rel', ''); } $pathway->addItem(strip_tags($product->product_name)); // Set the titles // $document->setTitle should be after the additem pathway if ($product->customtitle) { $document->setTitle(strip_tags($product->customtitle)); } else { $document->setTitle(strip_tags(($category->category_name ? $category->category_name . ' : ' : '') . $product->product_name)); } $ratingModel = VmModel::getModel('ratings'); $allowReview = $ratingModel->allowReview($product->virtuemart_product_id); $this->assignRef('allowReview', $allowReview); $showReview = $ratingModel->showReview($product->virtuemart_product_id); $this->assignRef('showReview', $showReview); if ($showReview) { $review = $ratingModel->getReviewByProduct($product->virtuemart_product_id); $this->assignRef('review', $review); $rating_reviews = $ratingModel->getReviews($product->virtuemart_product_id); $this->assignRef('rating_reviews', $rating_reviews); } $showRating = $ratingModel->showRating($product->virtuemart_product_id); $this->assignRef('showRating', $showRating); if ($showRating) { $vote = $ratingModel->getVoteByProduct($product->virtuemart_product_id); $this->assignRef('vote', $vote); $rating = $ratingModel->getRatingByProduct($product->virtuemart_product_id); $this->assignRef('rating', $rating); } $allowRating = $ratingModel->allowRating($product->virtuemart_product_id); $this->assignRef('allowRating', $allowRating); // Check for editing access // @todo build edit page if (!class_exists('Permissions')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'permissions.php'; } //if (Permissions::getInstance()->check("admin,storeadmin")) { $perm = Permissions::getInstance(); $admin = $perm->check("admin"); if (!$admin) { vmdebug('No admin'); } $storeadmin = $perm->check("admin,storeadmin"); if (!$storeadmin) { vmdebug('No $storeadmin'); } $superVendor = $perm->isSuperVendor(); if (!$superVendor) { vmdebug('No $superVendor'); } if ($admin or $perm->isSuperVendor() == $product->virtuemart_vendor_id and $storeadmin) { $edit_link = JURI::root() . 'index.php?option=com_virtuemart&tmpl=component&view=product&task=edit&virtuemart_product_id=' . $product->virtuemart_product_id; $edit_link = $this->linkIcon($edit_link, 'COM_VIRTUEMART_PRODUCT_FORM_EDIT_PRODUCT', 'edit', false, false); } else { $edit_link = ""; } $this->assignRef('edit_link', $edit_link); // todo: atm same form for "call for price" and "ask a question". Title of the form should be different $askquestion_url = JRoute::_('index.php?option=com_virtuemart&view=productdetails&task=askquestion&virtuemart_product_id=' . $product->virtuemart_product_id . '&virtuemart_category_id=' . $product->virtuemart_category_id . '&tmpl=component', FALSE); $this->assignRef('askquestion_url', $askquestion_url); // Load the user details $user = JFactory::getUser(); $this->assignRef('user', $user); // More reviews link $uri = JURI::getInstance(); $uri->setVar('showall', 1); $uristring = vmURI::getCleanUrl(); $this->assignRef('more_reviews', $uristring); if ($product->metadesc) { $document->setDescription($product->metadesc); } if ($product->metakey) { $document->setMetaData('keywords', $product->metakey); } if ($product->metarobot) { $document->setMetaData('robots', $product->metarobot); } if ($mainframe->getCfg('MetaTitle') == '1') { $document->setMetaData('title', $product->product_name); //Maybe better product_name } if ($mainframe->getCfg('MetaAuthor') == '1') { $document->setMetaData('author', $product->metaauthor); } $showBasePrice = Permissions::getInstance()->check('admin'); //todo add config settings $this->assignRef('showBasePrice', $showBasePrice); $productDisplayShipments = array(); $productDisplayPayments = array(); if (!class_exists('vmPSPlugin')) { require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php'; } JPluginHelper::importPlugin('vmshipment'); JPluginHelper::importPlugin('vmpayment'); $dispatcher = JDispatcher::getInstance(); $returnValues = $dispatcher->trigger('plgVmOnProductDisplayShipment', array($product, &$productDisplayShipments)); $returnValues = $dispatcher->trigger('plgVmOnProductDisplayPayment', array($product, &$productDisplayPayments)); $this->assignRef('productDisplayPayments', $productDisplayPayments); $this->assignRef('productDisplayShipments', $productDisplayShipments); if (empty($category->category_template)) { $category->category_template = VmConfig::get('categorytemplate'); } shopFunctionsF::setVmTemplate($this, $category->category_template, $product->product_template, $category->category_product_layout, $product->layout); shopFunctionsF::addProductToRecent($virtuemart_product_id); $currency = CurrencyDisplay::getInstance(); $this->assignRef('currency', $currency); if (JRequest::getCmd('layout', 'default') == 'notify') { $this->setLayout('notify'); } //Added by Seyi Awofadeju to catch notify layout parent::display($tpl); }
public function _processDataAjax($datas, $params) { $_arr_datas = array(); parse_str($datas, $_arr_datas); if (!empty($_arr_datas)) { $list = array(); $_categories = isset($_arr_datas['categories']) ? $_arr_datas['categories'] : 0; $_manufacturers = isset($_arr_datas['manufacturers']) ? $_arr_datas['manufacturers'] : 0; $_customfields = isset($_arr_datas['custom_id']) ? $_arr_datas['custom_id'] : 0; $_price_min = isset($_arr_datas['ft_price_min']) ? $_arr_datas['ft_price_min'] : ''; $_price_max = isset($_arr_datas['ft_price_max']) ? $_arr_datas['ft_price_max'] : ''; $_orderby = isset($_arr_datas['orderby']) ? $_arr_datas['orderby'] : 'ordering'; $limit_result = $params->get('limit_results', 5) <= 0 ? 5 : $params->get('limit_results', 5); $_limit = isset($_arr_datas['limit']) && $_arr_datas['limit'] != '' ? (int) $_arr_datas['limit'] : $limit_result; $_start = isset($_arr_datas['limitstart']) && $_arr_datas['limitstart'] != '' ? (int) $_arr_datas['limitstart'] : 0; if ($_categories == 0 && $_manufacturers == 0 && $_customfields == 0 && $_price_min == '' && $_price_max == '') { die(json_encode('noresults')); } $productExtModel = new VirtuemartModelProductFilter(); $productExtModel->filter_order = $_orderby; JRequest::setVar('orderby', $_orderby); $productExtModel->updateRequests(); $virtuemart_category_id = $_categories; $productExtModel->virtuemart_manufacturer_id = $_manufacturers; $productExtModel->searchcustoms = ''; $productExtModel->searchcustoms = $_customfields; $productExtModel->_virtuemart_product_price = $_price_min == '' && $_price_max == '' ? false : array($_price_min, $_price_max); $productExtModel->_limitStart = $_start; $productExtModel->_limit = $_limit; //$productExtModel->_noLimit = true; $ids = $productExtModel->sortSearchListQuery(true, $virtuemart_category_id); $result = new stdClass(); //$path_template = JPATH_VM_SITE . DS . 'views' . DS . 'category' . DS . 'tmpl' . DS . 'default.php'; $ratingModel = VmModel::getModel('ratings'); $showRating = $ratingModel->showRating(); $productExtModel->withRating = $showRating; $show_prices = VmConfig::get('show_prices', 1); $this->show_prices = $show_prices; vmJsApi::jPrice(); $this->showRating = $showRating; $this->products = $productExtModel->getProducts($ids); $currency = CurrencyDisplay::getInstance(); $this->currency = $currency; $productExtModel->addImages($this->products, 1); $orderByList = $productExtModel->getOrderByList(0); if (isset($orderByList['manufacturer'])) { $orderByList['manufacturer'] = ''; } $this->orderByList = $orderByList; $this->perRow = VmConfig::get('products_per_row', 3); $productExtModel->_total = $productExtModel->getTotal(); $pagination = $productExtModel->getPagination($this->perRow); //$pagination->set('pages.current',1); $this->vmPagination = $pagination; $this->category = new stdClass(); $this->category->category_name = 'Results'; $this->category->category_description = ''; $this->category->limit_list_step = '0'; $this->category->limit_list_initial = '0'; foreach ($this->products as $item) { $item->stock = $productExtModel->getStockIndicator($item); } $this->showproducts = 1; $this->productsLayout = 'products'; ob_start(); require JModuleHelper::getLayoutPath($this->_module->module, 'default' . '_results'); $buffer = ob_get_contents(); $result->filter_product = preg_replace(array('/ {2,}/', '/<!--.*?-->|\\t|(?:\\r?\\n[ \\t]*)+/s'), array(' ', ''), $buffer); ob_end_clean(); $list = $this->_productFiltering($_arr_datas); ob_start(); require JModuleHelper::getLayoutPath($this->_module->module, 'default' . '_product_filter'); $buffer2 = ob_get_contents(); $result->items_markup = preg_replace(array('/ {2,}/', '/<!--.*?-->|\\t|(?:\\r?\\n[ \\t]*)+/s'), array(' ', ''), $buffer2); ob_end_clean(); die(json_encode($result)); } }
/** * Collect all data to show on the template * * @author RolandD, Max Milbers */ function display($tpl = null) { //TODO get plugins running // $dispatcher = JDispatcher::getInstance(); // $limitstart = JRequest::getVar('limitstart', 0, '', 'int'); $this->show_prices = VmConfig::get('show_prices', 1); if ($this->show_prices == 1) { JLoader::register('calculationHelper', JPATH_VM_ADMINISTRATOR . '/helpers/calculationh.php'); } $document = JFactory::getDocument(); // add javascript for price and cart, need even for quantity buttons, so we need it almost anywhere vmJsApi::jPrice(); $app = JFactory::getApplication(); $pathway = $app->getPathway(); $task = JRequest::getCmd('task'); JLoader::register('VmImage', JPATH_VM_ADMINISTRATOR . '/helpers/image.php'); // Load the product //$product = $this->get('product'); //Why it is sensefull to use this construction? Imho it makes it just harder $this->product_model = VmModel::getModel('product'); $virtuemart_product_idArray = JRequest::getVar('virtuemart_product_id', 0); if (is_array($virtuemart_product_idArray) and count($virtuemart_product_idArray) > 0) { $virtuemart_product_id = (int) $virtuemart_product_idArray[0]; } else { $virtuemart_product_id = (int) $virtuemart_product_idArray; } $quantityArray = JRequest::getVar('quantity', array()); //is sanitized then JArrayHelper::toInteger($quantityArray); $quantity = 1; if (!empty($quantityArray[0])) { $quantity = $quantityArray[0]; } $onlyPublished = true; // set unpublished product when it's editable by its owner for preview if ($canEdit = ShopFunctions::can('edit', 'product')) { $onlyPublished = false; } $product = $this->product_model->getProduct($virtuemart_product_id, TRUE, TRUE, $onlyPublished, $quantity); if ($product && $canEdit) { JLoader::register('Permissions', JPATH_VM_ADMINISTRATOR . '/helpers/permissions.php'); $vendor = Permissions::getInstance()->isSuperVendor(); if ($vendor > 1 && $product->virtuemart_vendor_id !== $vendor) { $product = null; } elseif (!$product->published) { $app->enqueueMessage(JText::_('COM_VIRTUEMART_ORDER_PRINT_PRODUCT_STATUS') . ' : ' . JText::_('COM_VIRTUEMART_UNPUBLISHED'), 'warning'); } } $last_category_id = shopFunctionsF::getLastVisitedCategoryId(); if (empty($product->slug)) { //Todo this should be redesigned to fit better for SEO $app->enqueueMessage(JText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND')); $categoryLink = ''; if (!$last_category_id) { $last_category_id = JRequest::getInt('virtuemart_category_id', false); } if ($last_category_id) { $categoryLink = '&virtuemart_category_id=' . $last_category_id; } if (VmConfig::get('handle_404', 1)) { $app->redirect(JRoute::_('index.php?option=com_virtuemart&view=category' . $categoryLink . '&error=404', FALSE)); } else { JError::raise(E_ERROR, '404', 'Not found'); } return; } if (!empty($product->customfields)) { foreach ($product->customfields as $k => $custom) { if (!empty($custom->layout_pos)) { $product->customfieldsSorted[$custom->layout_pos][] = $custom; unset($product->customfields[$k]); } } $product->customfieldsSorted['normal'] = $product->customfields; unset($product->customfields); } $product->event = new stdClass(); $product->event->afterDisplayTitle = ''; $product->event->beforeDisplayContent = ''; $product->event->afterDisplayContent = ''; if (VmConfig::get('enable_content_plugin', 0)) { // add content plugin // $dispatcher =& JDispatcher::getInstance(); JPluginHelper::importPlugin('content'); $product->text = $product->product_desc; // jimport( 'joomla.html.parameter' ); // $params = new JParameter(''); $params = new JRegistry(); $product->event = new stdClass(); $results = $dispatcher->trigger('onContentPrepare', array('com_virtuemart.productdetails', &$product, &$params, 0)); // More events for 3rd party content plugins // This do not disturb actual plugins, because we don't modify $product->text $res = $dispatcher->trigger('onContentAfterTitle', array('com_virtuemart.productdetails', &$product, &$params, 0)); $product->event->afterDisplayTitle = trim(implode("\n", $res)); $res = $dispatcher->trigger('onContentBeforeDisplay', array('com_virtuemart.productdetails', &$product, &$params, 0)); $product->event->beforeDisplayContent = trim(implode("\n", $res)); $res = $dispatcher->trigger('onContentAfterDisplay', array('com_virtuemart.productdetails', &$product, &$params, 0)); $product->event->afterDisplayContent = trim(implode("\n", $res)); $product->product_desc = $product->text; } $this->product_model->addImages($product); if (isset($product->min_order_level) && (int) $product->min_order_level > 0) { $this->min_order_level = $product->min_order_level; } else { $this->min_order_level = 1; } if (isset($product->step_order_level) && (int) $product->step_order_level > 0) { $this->step_order_level = $product->step_order_level; } else { $this->step_order_level = 1; } // Load the neighbours if (VmConfig::get('product_navigation', 1)) { $product->neighbours = $this->product_model->getNeighborProducts($product); } // Product vendor multiX if ($multix = Vmconfig::get('multix', 'none') === 'admin') { $vendor_model = VmModel::getModel('vendor'); $this->vendor = $vendor_model->getVendor($product->virtuemart_vendor_id); } else { $this->vendor = null; } // echo 'multi'.$multix; // Load the category $category_model = VmModel::getModel('category'); shopFunctionsF::setLastVisitedCategoryId($product->virtuemart_category_id); $catTitle = array(); if ($category_model) { $category = $category_model->getCategory($product->virtuemart_category_id); $category_model->addImages($category, 1); $this->assignRef('category', $category); //Seems we dont need this anylonger, destroyed the breadcrumb if ($category->parents) { foreach ($category->parents as $c) { if (is_object($c) and isset($c->category_name)) { $pathway->addItem(strip_tags($c->category_name), JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $c->virtuemart_category_id, FALSE)); $catTitle[] = $c->category_name; } else { vmdebug('Error, parent category has no name, breadcrumb maybe broken, category', $c); } } } $vendorId = JRequest::getInt('virtuemart_vendor_id', null); $category->children = $category_model->getChildCategoryList($vendorId, $product->virtuemart_category_id); $category_model->addImages($category->children, 1); } if (!empty($tpl)) { $format = $tpl; } else { $format = JRequest::getWord('format', 'html'); } if ($format == 'html') { // Set Canonic link $document->addHeadLink($product->canonical, 'canonical', 'rel', ''); } $uri = JURI::getInstance(); //$pathway->addItem(JText::_('COM_VIRTUEMART_PRODUCT_DETAILS'), $uri->toString(array('path', 'query', 'fragment'))); $pathway->addItem(strip_tags($product->product_name)); // Set the titles // $document->setTitle should be after the additem pathway if ($product->customtitle) { $document->setTitle(strip_tags($product->customtitle)); } else { $document->setTitle(($catTitle ? implode(" / ", $catTitle) . ' / ' : '') . $product->product_name); } $ratingModel = VmModel::getModel('ratings'); $this->allowReview = $ratingModel->allowReview($product->virtuemart_product_id); $this->showReview = $ratingModel->showReview($product->virtuemart_product_id); if ($this->showReview) { $this->review = $ratingModel->getReviewByProduct($product->virtuemart_product_id); $this->rating_reviews = $ratingModel->getReviews($product->virtuemart_product_id); } $this->showRating = $ratingModel->showRating($product->virtuemart_product_id); if ($this->showRating) { $this->vote = $ratingModel->getVoteByProduct($product->virtuemart_product_id); $this->rating = $ratingModel->getRatingByProduct($product->virtuemart_product_id); } $this->allowRating = $ratingModel->allowRating($product->virtuemart_product_id); // todo: atm same form for "call for price" and "ask a question". Title of the form should be different $this->askquestion_url = JRoute::_('index.php?option=com_virtuemart&view=productdetails&task=askquestion&virtuemart_product_id=' . $product->virtuemart_product_id . '&virtuemart_category_id=' . $product->virtuemart_category_id . '&tmpl=component', FALSE); // Load the user details $this->user = JFactory::getUser(); // More reviews link $uri = JURI::getInstance(); $uri->setVar('showall', 1); $uristring = $uri->toString(); $this->more_reviews = $uristring; if ($product->metadesc) { $document->setDescription($product->metadesc); } if ($product->metakey) { $document->setMetaData('keywords', $product->metakey); } if ($product->metarobot) { $document->setMetaData('robots', $product->metarobot); } if ($app->getCfg('MetaTitle') == '1') { $document->setMetaData('title', $product->product_name); //Maybe better product_name } if ($app->getCfg('MetaAuthor') == '1') { $document->setMetaData('author', $product->metaauthor); } $this->showBasePrice = Permissions::getInstance()->check('admin'); //todo add config settings $productDisplayShipments = array(); $productDisplayPayments = array(); JLoader::register('vmPSPlugin', JPATH_VM_PLUGINS . 'vmpsplugin.php'); JPluginHelper::importPlugin('vmshipment'); JPluginHelper::importPlugin('vmpayment'); $dispatcher = JDispatcher::getInstance(); $returnValues = $dispatcher->trigger('plgVmOnProductDisplayShipment', array($product, &$productDisplayShipments)); $returnValues = $dispatcher->trigger('plgVmOnProductDisplayPayment', array($product, &$productDisplayPayments)); $this->productDisplayPayments = $productDisplayPayments; $this->productDisplayShipments = $productDisplayShipments; if (empty($category->category_template)) { $category->category_template = VmConfig::get('categorytemplate'); } $this->product = $product; shopFunctionsF::setVmTemplate($this, $category->category_template, $product->product_template, $category->category_product_layout, $product->layout); shopFunctionsF::addProductToRecent($virtuemart_product_id); $this->currency = CurrencyDisplay::getInstance(); if (JRequest::getCmd('layout', 'default') == 'notify') { $this->setLayout('notify'); } //Added by Seyi Awofadeju to catch notify layout parent::display($tpl); }
<?php // no direct access defined('_JEXEC') or die('Restricted access'); // add javascript for price and cart, need even for quantity buttons, so we need it almost anywhere vmJsApi::jPrice(); $col = 1; $pwidth = 'width' . floor(100 / $products_per_row); if ($products_per_row > 1) { $float = "floatleft"; } else { $float = "center"; } ?> <div class="vmgroup<?php echo $params->get('moduleclass_sfx'); ?> "> <?php if ($headerText) { ?> <div class="vmheader"><?php echo $headerText; ?> </div> <?php } if ($display_style == "div") { ?> <div class="vmproduct<?php echo $params->get('moduleclass_sfx');
function get_store($config, $id) { if ($this->mode != 'com_virtuemart') { return array("price" => '', "cart" => ''); } else { // if the VM is available if (!class_exists('VmConfig')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php'; } VmConfig::loadConfig(); // Load the language file of com_virtuemart. JFactory::getLanguage()->load('com_virtuemart'); // load necessary classes if (!class_exists('calculationHelper')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'calculationh.php'; } if (!class_exists('CurrencyDisplay')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'currencydisplay.php'; } if (!class_exists('VirtueMartModelVendor')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'models' . DS . 'vendor.php'; } if (!class_exists('VmImage')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'image.php'; } if (!class_exists('shopFunctionsF')) { require JPATH_SITE . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'shopfunctionsf.php'; } if (!class_exists('calculationHelper')) { require JPATH_COMPONENT_SITE . DS . 'helpers' . DS . 'cart.php'; } if (!class_exists('VirtueMartModelProduct')) { JLoader::import('product', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'models'); } // load the base $productModel = new VirtueMartModelProduct(); $product = $productModel->getProduct($id, 100, true, true, true); $currency = CurrencyDisplay::getInstance(); $price = '<strong>' . $currency->createPriceDiv($config['vm_show_price_type'], '', $product->prices, true) . '</strong>'; if ($config['vm_add_to_cart'] == 1) { vmJsApi::jPrice(); vmJsApi::writeJS(); } $news_price = '<div class="PricebasePriceWithTax">'; // if ($config['vm_show_price_type'] != 'none') { if ($config['vm_display_type'] == 'text_price') { $news_price .= '<span class="PricebasePriceWithTax">' . JText::_('MOD_NEWS_PRO_GK5_PRODUCT_PRICE') . ' ' . $price . '</span>'; } else { $news_price .= '<span class="PricebasePriceWithTax">' . $price . '</span>'; } } $news_price .= '</div>'; // display discount if ($config['vm_show_discount_amount'] == 1) { $disc_amount = $currency->priceDisplay($product->prices['discountAmount'], $currency->getId()); $news_price .= '<div class="PricetaxAmount">' . JText::_('MOD_NEWS_PRO_GK5_PRODUCT_DISCOUNT_AMOUNT') . $disc_amount . '</div>'; } // display tax if ($config['vm_show_tax'] == 1) { $taxAmount = $currency->priceDisplay($product->prices['taxAmount'], $currency->getId()); $news_price .= '<div class="PricetaxAmount">' . JText::_('MOD_NEWS_PRO_GK5_PRODUCT_TAX_AMOUNT') . $taxAmount . '</div>'; } $news_cart = ''; // 'Add to cart' button if ($config['vm_add_to_cart'] == 1) { $code = '<div class="addtocart-area">'; $code .= '<form method="post" class="product" action="index.php">'; $code .= '<div class="addtocart-bar">'; $code .= '<span class="quantity-box" style="display: none"><input type="text" class="quantity-input" name="quantity[]" value="1" /></span>'; $addtoCartButton = ''; if ($product->addToCartButton) { $addtoCartButton = $product->addToCartButton; } else { $addtoCartButton = shopFunctionsF::getAddToCartButton($product->orderable); } $code .= $addtoCartButton; $code .= '</div> <input type="hidden" class="pname" value="' . $product->product_name . '"/> <input type="hidden" name="option" value="com_virtuemart" /> <input type="hidden" name="view" value="cart" /> <input type="hidden" name="task" value="add" /> <input type="hidden" name="virtuemart_product_id[]" value="' . $product->virtuemart_product_id . '" /> <input type="hidden" name="virtuemart_category_id[]" value="' . $product->virtuemart_category_id . '" /> </form>'; $code .= '</div>'; $news_cart .= $code; } // results return array("price" => $news_price, "cart" => $news_cart); } }
public function display($tpl = null) { $vendorId = vRequest::getInt('vendorid', 1); $vendorModel = VmModel::getModel('vendor'); $vendorIdUser = VmConfig::isSuperVendor(); $vendorModel->setId($vendorId); $vendor = $vendorModel->getVendor(); if(!class_exists('shopFunctionsF'))require(VMPATH_SITE.DS.'helpers'.DS.'shopfunctionsf.php'); if (VmConfig::get ('enable_content_plugin', 0)) { shopFunctionsF::triggerContentPlugin($vendor, 'vendor','vendor_store_desc'); shopFunctionsF::triggerContentPlugin($vendor, 'vendor','vendor_terms_of_service'); } $app = JFactory::getApplication(); $menus = $app->getMenu(); $menu = $menus->getActive(); if(!empty($menu->id)){ ShopFunctionsF::setLastVisitedItemId($menu->id); } else if($itemId = vRequest::getInt('Itemid',false)){ ShopFunctionsF::setLastVisitedItemId($itemId); } $this->assignRef('vendor',$vendor); $document = JFactory::getDocument(); if(!VmConfig::get('shop_is_offline',0)){ vmJsApi::jPrice(); //if($vendorIdUser){ //$user = JFactory::getUser(); if( $vendorIdUser ){ $add_product_link = JURI::root() . 'index.php?option=com_virtuemart&tmpl=component&view=product&task=edit&virtuemart_product_id=0&manage=1' ; $add_product_link = $this->linkIcon($add_product_link, 'COM_VIRTUEMART_PRODUCT_FORM_NEW_PRODUCT', 'edit', false, false); } else { $add_product_link = ""; } $this->assignRef('add_product_link', $add_product_link); //} $categoryModel = VmModel::getModel('category'); $productModel = VmModel::getModel('product'); $ratingModel = VmModel::getModel('ratings'); $productModel->withRating = $this->showRating = $ratingModel->showRating(); $this->products = array(); $categoryId = vRequest::getInt('catid', 0); $categoryChildren = $categoryModel->getChildCategoryList($vendorId, $categoryId); $categoryModel->addImages($categoryChildren,1); $this->assignRef('categories', $categoryChildren); if(!class_exists('CurrencyDisplay'))require(VMPATH_ADMIN.DS.'helpers'.DS.'currencydisplay.php'); $currency = CurrencyDisplay::getInstance( ); $this->assignRef('currency', $currency); $products_per_row = VmConfig::get('homepage_products_per_row',3); $featured_products_rows = VmConfig::get('featured_products_rows',1); $featured_products_count = $products_per_row * $featured_products_rows; if (!empty($featured_products_count) and VmConfig::get('show_featured', 1)) { $this->products['featured'] = $productModel->getProductListing('featured', $featured_products_count); $productModel->addImages($this->products['featured'],1); } $latest_products_rows = VmConfig::get('latest_products_rows'); $latest_products_count = $products_per_row * $latest_products_rows; if (!empty($latest_products_count) and VmConfig::get('show_latest', 1)) { $this->products['latest']= $productModel->getProductListing('latest', $latest_products_count); $productModel->addImages($this->products['latest'],1); } $topTen_products_rows = VmConfig::get('topTen_products_rows'); $topTen_products_count = $products_per_row * $topTen_products_rows; if (!empty($topTen_products_count) and VmConfig::get('show_topTen', 1)) { $this->products['topten']= $productModel->getProductListing('topten', $topTen_products_count); $productModel->addImages($this->products['topten'],1); } $recent_products_rows = VmConfig::get('recent_products_rows'); $recent_products_count = $products_per_row * $recent_products_rows; $recent_products = $productModel->getProductListing('recent'); if (!empty($recent_products_count) and VmConfig::get('show_recent', 1) and !empty($recent_products)) { $this->products['recent']= $productModel->getProductListing('recent', $recent_products_count); $productModel->addImages($this->products['recent'],1); } if ($this->products) { $currency = CurrencyDisplay::getInstance( ); $this->assignRef('currency', $currency); $display_stock = VmConfig::get('display_stock',1); $showCustoms = VmConfig::get('show_pcustoms',1); if($display_stock or $showCustoms){ if(!$showCustoms){ foreach($this->products as $pType => $productSeries){ foreach($productSeries as $i => $productItem){ $productItem->stock = $productModel->getStockIndicator($productItem); } } } else { $customfieldsModel = VmModel::getModel ('Customfields'); if (!class_exists ('vmCustomPlugin')) { require(JPATH_VM_PLUGINS . DS . 'vmcustomplugin.php'); } foreach($this->products as $pType => $productSeries){ foreach($productSeries as $i => $productItem){ if (!empty($productItem->customfields)) { $product = clone($productItem); $customfields = array(); foreach($productItem->customfields as $cu){ $customfields[] = clone ($cu); } $customfieldsSorted = array(); $customfieldsModel -> displayProductCustomfieldFE ($product, $customfields); $product->stock = $productModel->getStockIndicator($product); foreach ($customfields as $k => $custom) { if (!empty($custom->layout_pos) ) { $customfieldsSorted[$custom->layout_pos][] = $custom; unset($customfields[$k]); } } $customfieldsSorted['normal'] = $customfields; $product->customfieldsSorted = $customfieldsSorted; unset($product->customfields); $this->products[$pType][$i] = $product; } else { $productItem->stock = $productModel->getStockIndicator($productItem); $this->products[$pType][$i] = $productItem; } } } } } } $user = JFactory::getUser(); $showBasePrice = ($user->authorise('core.admin','com_virtuemart') or $user->authorise('core.manage','com_virtuemart') or VmConfig::isSuperVendor()); $this->assignRef('showBasePrice', $showBasePrice); $layout = VmConfig::get('vmlayout','default'); $this->setLayout($layout); $productsLayout = VmConfig::get('productsublayout','products'); if(empty($productsLayout)) $productsLayout = 'products'; $this->productsLayout = empty($menu->query['productsublayout'])? $productsLayout:$menu->query['productsublayout']; // Add feed links if ($this->products && (VmConfig::get('feed_featured_published', 0)==1 or VmConfig::get('feed_topten_published', 0)==1 or VmConfig::get('feed_latest_published', 0)==1)) { $link = '&format=feed&limitstart='; $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); $document->addHeadLink(JRoute::_($link . '&type=rss', FALSE), 'alternate', 'rel', $attribs); $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'); $document->addHeadLink(JRoute::_($link . '&type=atom', FALSE), 'alternate', 'rel', $attribs); } } else { $this->setLayout('off_line'); } $error = vRequest::getInt('error',0); //Todo this may not work everytime as expected, because the error must be set in the redirect links. if(!empty($error)){ $document->setTitle(vmText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND').vmText::sprintf('COM_VIRTUEMART_HOME',$vendor->vendor_store_name)); } else { if(empty($vendor->customtitle)){ if ($menu){ $menuTitle = $menu->params->get('page_title'); if(empty($menuTitle)) { $menuTitle = vmText::sprintf('COM_VIRTUEMART_HOME',$vendor->vendor_store_name); } $document->setTitle($menuTitle); } else { $title = vmText::sprintf('COM_VIRTUEMART_HOME',$vendor->vendor_store_name); $document->setTitle($title); } } else { $document->setTitle($vendor->customtitle); } if(!empty($vendor->metadesc)) $document->setMetaData('description',$vendor->metadesc); if(!empty($vendor->metakey)) $document->setMetaData('keywords',$vendor->metakey); if(!empty($vendor->metarobot)) $document->setMetaData('robots',$vendor->metarobot); if(!empty($vendor->metaauthor)) $document->setMetaData('author',$vendor->metaauthor); } if(!class_exists('VmTemplate')) require(VMPATH_SITE.DS.'helpers'.DS.'vmtemplate.php'); vmTemplate::setTemplate(); parent::display($tpl); }
/** * Plugin that returns the object list for DJ-Mediatools album * * Each object must contain following properties (mandatory): title, description, image * Optional properties: link, target (_blank or _self), alt (alt attribute for image) * * @param object The album params */ public function onAlbumPrepare(&$source, &$params) { // Lets check the requirements $check = $this->onCheckRequirements($source); if (is_null($check) || is_string($check)) { return null; } $app = JFactory::getApplication(); // Load the language file of com_virtuemart. JFactory::getLanguage()->load('com_virtuemart'); /* Load VM fonction */ if (!class_exists('VmConfig')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php'; } VmConfig::loadConfig(); VmConfig::loadJLang('mod_virtuemart_product', true); include_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'tables' . DS . 'categories.php'; if (!class_exists('calculationHelper')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'calculationh.php'; } if (!class_exists('CurrencyDisplay')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'currencydisplay.php'; } if (!class_exists('VirtueMartModelVendor')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'models' . DS . 'vendor.php'; } if (!class_exists('VmImage')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'image.php'; } if (!class_exists('shopFunctionsF')) { require JPATH_SITE . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'shopfunctionsf.php'; } if (!class_exists('calculationHelper')) { require JPATH_COMPONENT_SITE . DS . 'helpers' . DS . 'cart.php'; } if (!class_exists('VirtueMartModelProduct')) { JLoader::import('product', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'models'); } $category_id = $params->get('plg_virtuemart_category_id', null); $product_group = $params->get('plg_virtuemart_product_group', 'latest'); $max_items = $params->get('max_images'); $show_price = (bool) $params->get('plg_virtuemart_show_price', 1); $show_addtocart = (bool) $params->get('plg_virtuemart_show_addtocart', 1); $default_image = $params->get('plg_virtuemart_image'); $filter_category = $category_id ? TRUE : FALSE; $productModel = VmModel::getModel('Product'); $products = $productModel->getProductListing($product_group, $max_items, $show_price, true, false, $filter_category, $category_id); $productModel->addImages($products); //$this->debug($productModel); $currency = CurrencyDisplay::getInstance(); if ($show_addtocart) { vmJsApi::jPrice(); vmJsApi::cssSite(); } //$this->debug($products); $slides = array(); foreach ($products as $product) { $slide = (object) array(); //$this->debug($product->images); if (isset($product->images[0])) { $slide->image = $product->images[0]->file_url; } else { if ($default_image) { $slide->image = $default_image; } else { continue; } } $slide->title = $product->product_name; $slide->description = $product->product_s_desc; if (empty($slide->description)) { $slide->description = $product->product_desc; } $slide->canonical = $slide->link = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $product->virtuemart_product_id . '&virtuemart_category_id=' . $product->virtuemart_category_id); $slide->id = $product->virtuemart_product_id . ':' . $product->slug; if ($comments = $params->get('commnets', 0)) { $host = str_replace(JURI::root(true), '', JURI::root()); $host = preg_replace('/\\/$/', '', $host); switch ($comments) { case 1: // jcomments $slide->comments = array('id' => $item->virtuemart_product_id, 'group' => 'com_virtuemart'); break; case 2: // disqus $disqus_shortname = $params->get('disqus_shortname', ''); if (!empty($disqus_shortname)) { $slide->comments = array(); $slide->comments['url'] = $host . $slide->link; $slide->comments['identifier'] = $disqus_shortname . '-virtuemart-' . $item->virtuemart_product_id; // ?? } break; case 3: // facebook $slide->comments = $host . $slide->link; break; case 4: //komento // not implemented break; } } if ($show_price && isset($product->prices)) { $slide->extra = '<div class="vmproduct"><div class="product-price">' . $currency->createPriceDiv('salesPrice', '', $product->prices, FALSE, FALSE, 1.0, TRUE); if (!empty($product->prices['salesPriceWithDiscount'])) { $slide->extra .= $currency->createPriceDiv('salesPriceWithDiscount', '', $product->prices, FALSE, FALSE, 1.0, TRUE); } $slide->extra .= '</div>'; } if ($show_addtocart) { if (!isset($slide->extra)) { $slide->extra = '<div class="vmproduct">'; } ob_start(); echo $this->addtocart($product); $slide->extra .= ob_get_clean(); } if (isset($slide->extra)) { $slide->extra .= '</div>'; } $slides[] = $slide; } return $slides; }
function store_vm($config, $news_id, $news_cid, $news_price, $news_price_currency, $news_discount_amount, $news_discount_is_percent, $news_discount_start, $news_discount_end, $news_tax, $news_manufacturer) { // if (!class_exists('VmConfig')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php'; } VmConfig::loadConfig(); // Load the language file of com_virtuemart. JFactory::getLanguage()->load('com_virtuemart'); if (!class_exists('calculationHelper')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'calculationh.php'; } if (!class_exists('CurrencyDisplay')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'currencydisplay.php'; } if (!class_exists('VirtueMartModelVendor')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'models' . DS . 'vendor.php'; } if (!class_exists('VmImage')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'image.php'; } if (!class_exists('shopFunctionsF')) { require JPATH_SITE . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'shopfunctionsf.php'; } if (!class_exists('calculationHelper')) { require JPATH_COMPONENT_SITE . DS . 'helpers' . DS . 'cart.php'; } if (!class_exists('VirtueMartModelProduct')) { JLoader::import('product', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'models'); } $mainframe = Jfactory::getApplication(); $virtuemart_currency_id = $mainframe->getUserStateFromRequest("virtuemart_currency_id", 'virtuemart_currency_id', JRequest::getInt('virtuemart_currency_id', 0)); $currency = CurrencyDisplay::getInstance(); $productModel = new VirtueMartModelProduct(); $product = $productModel->getProduct($news_id, 100, true, true, true); if ($config['vm_add_to_cart'] == 1) { vmJsApi::jQuery(); vmJsApi::jPrice(); vmJsApi::cssSite(); } $news_price = ''; if ($config['vm_show_price_type'] != 'none' && $config['vm_show_price_type'] == 'base') { if ($config['vm_show_price_with_tax'] == 1) { if ($config['vm_display_type'] == 'text_price') { $news_price .= $currency->createPriceDiv('basePriceWithTax', 'MOD_NEWS_PRO_GK4_PRODUCT_BASEPRICE_WITHTAX', $product->prices); } else { $news_price .= $currency->createPriceDiv('basePriceWithTax', '', $product->prices); } } else { if ($config['vm_display_type'] == 'text_price') { $news_price .= $currency->createPriceDiv('priceWithoutTax', 'MOD_NEWS_PRO_GK4_PRODUCT_BASEPRICE_WITHOUTTAX', $product->prices); } else { $news_price .= $currency->createPriceDiv('priceWithoutTax', '', $product->prices); } } } if ($config['vm_show_price_type'] != 'none' && $config['vm_show_price_type'] == 'sale') { if ($config['vm_show_price_with_tax'] == 1) { if ($config['vm_display_type'] == 'text_price') { $news_price .= $currency->createPriceDiv('salesPrice', 'MOD_NEWS_PRO_GK4_PRODUCT_SALESPRICE', $product->prices); } else { $news_price .= $currency->createPriceDiv('salesPrice', '', $product->prices); } } else { if ($config['vm_display_type'] == 'text_price') { $news_price .= $currency->createPriceDiv('priceWithoutTax', 'MOD_NEWS_PRO_GK4_PRODUCT_SALESPRICE_WITHOUT_TAX', $product->prices); } else { $news_price .= $currency->createPriceDiv('priceWithoutTax', '', $product->prices); } } } if ($config['vm_add_to_cart'] == 1) { $code = ''; $code .= '<form method="post" class="product" action="index.php">'; $code .= '<div class="addtocart-bar">'; $code .= '<span class="quantity-box" style="display: none"> <input type="text" class="quantity-input" name="quantity[]" value="1" /> </span>'; $button_lbl = JText::_('COM_VIRTUEMART_CART_ADD_TO'); $button_cls = ''; $stockhandle = VmConfig::get('stockhandle', 'none'); $code .= '<span class="addtocart-button"> <input type="submit" name="addtocart" class="addtocart-button" value="' . $button_lbl . '" title="' . $button_lbl . '" /></span>'; $code .= '<div class="clear"></div></div> <input type="hidden" class="pname" value="' . $product->product_name . '"/> <input type="hidden" name="option" value="com_virtuemart" /> <input type="hidden" name="view" value="cart" /> <noscript><input type="hidden" name="task" value="add" /></noscript> <input type="hidden" name="virtuemart_product_id[]" value="' . $product->virtuemart_product_id . '" /> <input type="hidden" name="virtuemart_category_id[]" value="' . $product->virtuemart_category_id . '" /> </form>'; $news_price .= $code; } if ($config['vm_show_discount_amount'] == 1) { $disc_amount = $currency->createPriceDiv('discountAmount', 'MOD_NEWS_PRO_GK4_PRODUCT_DISCOUNT_AMOUNT', $product->prices); $disc_amount = strip_tags($disc_amount, '<div>'); $news_price .= $disc_amount; } if ($config['vm_show_tax'] == 1) { $taxAmount = $currency->createPriceDiv('taxAmount', 'MOD_NEWS_PRO_GK4_PRODUCT_TAX_AMOUNT', $product->prices); $taxAmount = strip_tags($taxAmount, '<div>'); $news_price .= $taxAmount; } return $news_price != '' ? '<div class="nspVmStore">' . $news_price . '</div>' : ''; }
public function display($tpl = null) { $show_prices = VmConfig::get('show_prices', 1); if ($show_prices == '1') { if (!class_exists('calculationHelper')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php'; } } $this->assignRef('show_prices', $show_prices); // add javascript for price and cart, need even for quantity buttons, so we need it almost anywhere vmJsApi::jPrice(); $document = JFactory::getDocument(); $app = JFactory::getApplication(); $pathway = $app->getPathway(); if (!class_exists('VmImage')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'image.php'; } $categoryModel = VmModel::getModel('category'); $productModel = VmModel::getModel('product'); // set search and keyword if ($keyword = vmRequest::uword('keyword', false, ' ,-,+,.,_')) { $pathway->addItem($keyword); //$title .=' ('.$keyword.')'; } //$search = VmRequest::uword('keyword', null); $this->searchcustom = ''; $this->searchcustomvalues = ''; if (!empty($keyword)) { $this->searchcustom = $this->getSearchCustom(); $search = $keyword; } else { $keyword = ''; $search = NULL; } $this->assignRef('search', $search); $this->assignRef('keyword', $keyword); $categoryId = JRequest::getInt('virtuemart_category_id', false); $virtuemart_manufacturer_id = JRequest::getInt('virtuemart_manufacturer_id', false); if ($categoryId === false and $virtuemart_manufacturer_id === false) { $categoryId = ShopFunctionsF::getLastVisitedCategoryId(); $catType = 'category'; $this->setCanonicalLink($tpl, $document, $categoryId, $catType); } else { if ($categoryId === false and $virtuemart_manufacturer_id) { $catType = 'manufacturer'; $this->setCanonicalLink($tpl, $document, $virtuemart_manufacturer_id, $catType); } else { $catType = 'category'; $this->setCanonicalLink($tpl, $document, $categoryId, $catType); } } if ($categoryId !== -1) { $vendorId = 1; $category = $categoryModel->getCategory($categoryId); } if (!empty($category)) { if (empty($category->category_layout) or $category->category_layout != 'category') { // Load the products in the given category $ids = $productModel->sortSearchListQuery(TRUE, $categoryId); $perRow = empty($category->products_per_row) ? VmConfig::get('products_per_row', 3) : $category->products_per_row; $this->assignRef('perRow', $perRow); $pagination = $productModel->getPagination($perRow); $this->assignRef('vmPagination', $pagination); $products = $productModel->getProducts($ids); //$products = $productModel->getProductsInCategory($categoryId); $productModel->addImages($products, 1); $this->assignRef('products', $products); if ($products) { $currency = CurrencyDisplay::getInstance(); $this->assignRef('currency', $currency); foreach ($products as $product) { $product->stock = $productModel->getStockIndicator($product); } } $ratingModel = VmModel::getModel('ratings'); $showRating = $ratingModel->showRating(); $this->assignRef('showRating', $showRating); $orderByList = $productModel->getOrderByList($categoryId); $this->assignRef('orderByList', $orderByList); // Add feed links if ($products && VmConfig::get('feed_cat_published', 0) == 1) { $link = '&format=feed&limitstart='; $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); $document->addHeadLink(JRoute::_($link . '&type=rss', FALSE), 'alternate', 'rel', $attribs); $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'); $document->addHeadLink(JRoute::_($link . '&type=atom', FALSE), 'alternate', 'rel', $attribs); } if (!class_exists('Permissions')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'permissions.php'; } $showBasePrice = Permissions::getInstance()->check('admin'); //todo add config settings $this->assignRef('showBasePrice', $showBasePrice); } //No redirect here, for category id = 0 means show ALL categories! note by Max Milbers if (!empty($categoryId) and $categoryId !== -1 and (empty($category->slug) or !$category->published)) { if (empty($category->slug)) { vmInfo(JText::_('COM_VIRTUEMART_CAT_NOT_FOUND')); } else { if ($category->virtuemart_id !== 0 and !$category->published) { vmInfo('COM_VIRTUEMART_CAT_NOT_PUBL', $category->category_name, $categoryId); } } //Fallback $categoryLink = ''; if ($category->category_parent_id) { $categoryLink = '&view=category&virtuemart_category_id=' . $category->category_parent_id; } else { $last_category_id = shopFunctionsF::getLastVisitedCategoryId(); if (!$last_category_id or $categoryId == $last_category_id) { $last_category_id = JRequest::getInt('virtuemart_category_id', false); } if ($last_category_id and $categoryId != $last_category_id) { $categoryLink = '&view=category&virtuemart_category_id=' . $last_category_id; } } $app->redirect(JRoute::_('index.php?option=com_virtuemart' . $categoryLink . '&error=404', FALSE)); return; } shopFunctionsF::setLastVisitedCategoryId($categoryId); shopFunctionsF::setLastVisitedManuId($virtuemart_manufacturer_id); // Add the category name to the pathway if ($category->parents) { foreach ($category->parents as $c) { $pathway->addItem(strip_tags($c->category_name), JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $c->virtuemart_category_id, FALSE)); } } $categoryModel->addImages($category, 1); $cache = JFactory::getCache('com_virtuemart', 'callback'); $category->children = $cache->call(array('VirtueMartModelCategory', 'getChildCategoryList'), $vendorId, $categoryId, $categoryModel->getDefaultOrdering(), $categoryModel->_selectedOrderingDir); $categoryModel->addImages($category->children, 1); if (VmConfig::get('enable_content_plugin', 0)) { shopFunctionsF::triggerContentPlugin($category, 'category', 'category_description'); } if ($category->metadesc) { $document->setDescription($category->metadesc); } if ($category->metakey) { $document->setMetaData('keywords', $category->metakey); } if ($category->metarobot) { $document->setMetaData('robots', $category->metarobot); } if ($app->getCfg('MetaAuthor') == '1') { $document->setMetaData('author', $category->metaauthor); } if (empty($category->category_template)) { $category->category_template = VmConfig::get('categorytemplate'); } shopFunctionsF::setVmTemplate($this, $category->category_template, 0, $category->category_layout); } else { //Backward compatibility if (!isset($category)) { $category = new stdClass(); $category->category_name = ''; $category->category_description = ''; $category->haschildren = false; } } $this->assignRef('category', $category); // Set the titles if (!empty($category->customtitle)) { $title = strip_tags($category->customtitle); } elseif (!empty($category->category_name)) { $title = strip_tags($category->category_name); } else { $title = $this->setTitleByJMenu($app); } if (JRequest::getInt('error')) { $title .= ' ' . JText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND'); } if (!empty($keyword)) { $title .= ' (' . $keyword . ')'; } if ($virtuemart_manufacturer_id and !empty($products[0])) { $title .= ' ' . $products[0]->mf_name; } $document->setTitle($title); // Override Category name when viewing manufacturers products !IMPORTANT AFTER page title. if (JRequest::getInt('virtuemart_manufacturer_id') and !empty($products[0]) and isset($category->category_name)) { $category->category_name = $products[0]->mf_name; } if ($app->getCfg('MetaTitle') == '1') { $document->setMetaData('title', $title); } parent::display($tpl); }
function get_store($config, $id) { // if the VM is available if (!class_exists('VmConfig')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php'; } VmConfig::loadConfig(); // Load the language file of com_virtuemart. JFactory::getLanguage()->load('com_virtuemart'); // load necessary classes if (!class_exists('calculationHelper')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'calculationh.php'; } if (!class_exists('CurrencyDisplay')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'currencydisplay.php'; } if (!class_exists('VirtueMartModelVendor')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'models' . DS . 'vendor.php'; } if (!class_exists('VmImage')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'image.php'; } if (!class_exists('shopFunctionsF')) { require JPATH_SITE . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'shopfunctionsf.php'; } if (!class_exists('calculationHelper')) { require JPATH_COMPONENT_SITE . DS . 'helpers' . DS . 'cart.php'; } if (!class_exists('VirtueMartModelProduct')) { JLoader::import('product', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'models'); } // load the base $mainframe = JFactory::getApplication(); $virtuemart_currency_id = $mainframe->getUserStateFromRequest("virtuemart_currency_id", 'virtuemart_currency_id', JRequest::getInt('virtuemart_currency_id', 0)); $currency = CurrencyDisplay::getInstance(); $productModel = new VirtueMartModelProduct(); $product = $productModel->getProduct($id, 100, true, true, true); //if($config['vm_add_to_cart'] == 1) { vmJsApi::jQuery(); vmJsApi::jPrice(); vmJsApi::cssSite(); //} $news_price = ''; $news_price .= $currency->createPriceDiv('basePriceWithTax', '', $product->prices); // calculate tax $taxAmount = $currency->createPriceDiv('taxAmount', 'MOD_NEWS_PRO_GK5_PRODUCT_TAX_AMOUNT', $product->prices); $taxAmount = strip_tags($taxAmount, '<div>'); $news_price .= $taxAmount; // 'Add to cart' button $news_cart = ''; //if($config['vm_add_to_cart'] == 1) { $code = '<form method="post" class="product" action="index.php">'; $code .= '<div class="addtocart-bar">'; $code .= '<span class="quantity-box" style="display: none"><input type="text" class="quantity-input" name="quantity[]" value="1" /></span>'; $button_lbl = JText::_('MOD_NEWS_PRO_GK5_COM_VIRTUEMART_CART_ADD_TO'); $button_cls = ''; $stockhandle = VmConfig::get('stockhandle', 'none'); $code .= '<span class="addtocart-button"><input type="submit" name="addtocart" class="addtocart-button" value="' . $button_lbl . '" title="' . $button_lbl . '" /></span>'; $code .= '</div> <input type="hidden" class="pname" value="' . $product->product_name . '"/> <input type="hidden" name="option" value="com_virtuemart" /> <input type="hidden" name="view" value="cart" /> <noscript><input type="hidden" name="task" value="add" /></noscript> <input type="hidden" name="virtuemart_product_id[]" value="' . $product->virtuemart_product_id . '" /> <input type="hidden" name="virtuemart_category_id[]" value="' . $product->virtuemart_category_id . '" /> </form>'; $news_cart .= $code; //} // restults return array("price" => $news_price, "cart" => $news_cart); }
public static function getAddToCartButton($orderable) { if ($orderable) { vmJsApi::jPrice(); $html = '<input type="submit" name="addtocart" class="addtocart-button" value="' . JText::_('COM_VIRTUEMART_CART_ADD_TO') . '" title="' . JText::_('COM_VIRTUEMART_CART_ADD_TO') . '" />'; } else { $html = '<input name="addtocart" class="addtocart-button-disabled" value="' . JText::_('COM_VIRTUEMART_ADDTOCART_CHOOSE_VARIANT') . '" title="' . JText::_('COM_VIRTUEMART_ADDTOCART_CHOOSE_VARIANT') . '" />'; } return $html; }
public static function addtocart($product) { if (!class_exists('VmConfig')) { require JPATH_ADMINISTRATOR . '/components/com_virtuemart/helpers/config.php'; } VmConfig::loadConfig(); vmJsApi::jPrice(); if (!VmConfig::get('use_as_catalog', 0)) { $add_to_cart = '<form method="post" class="product" action="index.php"> <span class="addtocart-button"> <input type="submit" name="addtocart" class="bt-addtocart addtocart-button" value="' . JText::_('Add cart') . '" title="' . sprintf(JText::_('ADD_PRODUCT_TO_CART'), $product->name) . '" /> </span> <input type="hidden" class="pname" value="' . $product->name . '"/> <input type="hidden" name="option" value="com_virtuemart" /> <input type="hidden" name="view" value="cart" /> <noscript><input type="hidden" name="task" value="add" /></noscript> <input type="hidden" class="quantity-input" name="quantity[]" value="1" /> <input type="hidden" name="virtuemart_product_id[]" value="' . $product->id . '" /> <input type="hidden" name="virtuemart_category_id[]" value="' . $product->category_id . '" /> </form>'; return $add_to_cart; } return false; }
/** * Collect all data to show on the template * * @author RolandD, Max Milbers */ function display($tpl = null) { $show_prices = VmConfig::get('show_prices',1); if($show_prices == '1'){ if(!class_exists('calculationHelper')) require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'calculationh.php'); } $this->assignRef('show_prices', $show_prices); $document = JFactory::getDocument(); /* add javascript for price and cart */ vmJsApi::jPrice(); $mainframe = JFactory::getApplication(); $pathway = $mainframe->getPathway(); $task = JRequest::getCmd('task'); /* Set the helper path */ $this->addHelperPath(JPATH_VM_ADMINISTRATOR.DS.'helpers'); //Load helpers $this->loadHelper('image'); $this->loadHelper('addtocart'); // Load the product $product_model = VmModel::getModel('product'); $virtuemart_product_idArray = JRequest::getInt('virtuemart_product_id',0); if(is_array($virtuemart_product_idArray)){ $virtuemart_product_id=(int)$virtuemart_product_idArray[0]; } else { $virtuemart_product_id=(int)$virtuemart_product_idArray; } if(empty($virtuemart_product_id)){ self::showLastCategory($tpl); return; } if(!class_exists('VirtueMartModelVendor')) require(JPATH_VM_ADMINISTRATOR.DS.'models'.DS.'vendor.php'); $product = $product_model->getProduct($virtuemart_product_id); /* Set Canonic link */ $format = JRequest::getWord('format', 'html'); if ($format == 'html') { $document->addHeadLink( $product->link , 'canonical', 'rel', '' ); } /* Set the titles */ $document->setTitle(JText::sprintf('COM_VIRTUEMART_PRODUCT_DETAILS_TITLE',$product->product_name.' - '.JText::_('COM_VIRTUEMART_PRODUCT_RECOMMEND'))); $uri = JURI::getInstance(); $this->assignRef('product', $product); if(empty($product)){ self::showLastCategory($tpl); return; } $product_model->addImages($product,1); /* Load the category */ $category_model = VmModel::getModel('category'); /* Get the category ID */ $virtuemart_category_id = JRequest::getInt('virtuemart_category_id'); if ($virtuemart_category_id == 0 && !empty($product)) { if (array_key_exists('0', $product->categories)) $virtuemart_category_id = $product->categories[0]; } shopFunctionsF::setLastVisitedCategoryId($virtuemart_category_id); if($category_model){ $category = $category_model->getCategory($virtuemart_category_id); $this->assignRef('category', $category); $pathway->addItem($category->category_name,JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='.$virtuemart_category_id)); } //$pathway->addItem(JText::_('COM_VIRTUEMART_PRODUCT_DETAILS'), $uri->toString(array('path', 'query', 'fragment'))); $pathway->addItem($product->product_name,JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id='.$virtuemart_category_id.'&virtuemart_product_id='.$product->virtuemart_product_id)); // for askquestion $pathway->addItem( JText::_('COM_VIRTUEMART_PRODUCT_ASK_QUESTION')); /* Check for editing access */ /** @todo build edit page */ /* Load the user details */ $this->assignRef('user', JFactory::getUser()); if ($product->metadesc) { $document->setDescription( $product->metadesc ); } if ($product->metakey) { $document->setMetaData('keywords', $product->metakey); } if ($product->metarobot) { $document->setMetaData('robots', $product->metarobot); } if ($mainframe->getCfg('MetaTitle') == '1') { $document->setMetaData('title', $product->product_s_desc); //Maybe better product_name } if ($mainframe->getCfg('MetaAuthor') == '1') { $document->setMetaData('author', $product->metaauthor); } parent::display($tpl); }
function get_store($config, $id) { // if the VM is available if (!class_exists('VmConfig')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php'; } VmConfig::loadConfig(); // Load the language file of com_virtuemart. JFactory::getLanguage()->load('com_virtuemart'); // load necessary classes if (!class_exists('calculationHelper')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'calculationh.php'; } if (!class_exists('CurrencyDisplay')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'currencydisplay.php'; } if (!class_exists('VirtueMartModelVendor')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'models' . DS . 'vendor.php'; } if (!class_exists('VmImage')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'image.php'; } if (!class_exists('shopFunctionsF')) { require JPATH_SITE . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'shopfunctionsf.php'; } if (!class_exists('calculationHelper')) { require JPATH_COMPONENT_SITE . DS . 'helpers' . DS . 'cart.php'; } if (!class_exists('VirtueMartModelProduct')) { JLoader::import('product', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'models'); } // load the base $mainframe = JFactory::getApplication(); $virtuemart_currency_id = $mainframe->getUserStateFromRequest("virtuemart_currency_id", 'virtuemart_currency_id', JRequest::getInt('virtuemart_currency_id', 0)); $currency = CurrencyDisplay::getInstance(); $cSymbol = $currency->getSymbol(); $cDecimals = $currency->getNbrDecimals(); $cDecSymbol = $currency->getDecimalSymbol(); // $productModel = new VirtueMartModelProduct(); $product = $productModel->getProduct($id, 100, true, true, true); $price = strip_tags($currency->createPriceDiv($config['vm_show_price_type'], '', $product->prices)); // remove currency $price = str_replace($cSymbol, '', $price); // prepare price - apply correct format and decimal separator $price = str_replace('.', $cDecSymbol, $price); if ($config['vm_currency_position'] == 'before') { $price = $cSymbol . ' ' . $price; } else { $price = $price . ' ' . $cSymbol; } // if ($config['vm_add_to_cart'] == 1) { vmJsApi::jQuery(); vmJsApi::jPrice(); } $news_price = '<div class="PricebasePriceWithTax">'; // if ($config['vm_show_price_type'] != 'none') { if ($config['vm_display_type'] == 'text_price') { $news_price .= '<span class="PricebasePriceWithTax">' . JText::_('MOD_NEWS_PRO_GK5_PRODUCT_PRICE') . ' ' . $price . '</span>'; } else { $news_price .= '<span class="PricebasePriceWithTax">' . $price . '</span>'; } } $news_price .= '</div>'; // display discount if ($config['vm_show_discount_amount'] == 1) { $news_price .= '<div class="PricetaxAmount">'; $disc_amount = str_replace('.', $cDecSymbol, number_format($product->prices['discountAmount'], $cDecimals)); if ($config['vm_currency_position'] == 'before') { $disc_amount = $cSymbol . ' ' . $disc_amount; } else { $disc_amount = $disc_amount . ' ' . $cSymbol; } $news_price .= JText::_('MOD_NEWS_PRO_GK5_PRODUCT_DISCOUNT_AMOUNT') . $disc_amount; $news_price .= '</div>'; } // display tax if ($config['vm_show_tax'] == 1) { $news_price .= '<div class="PricetaxAmount">'; $taxAmount = str_replace('.', $cDecSymbol, number_format($product->prices['taxAmount'], $cDecimals)); if ($config['vm_currency_position'] == 'before') { $taxAmount = $cSymbol . ' ' . $taxAmount; } else { $taxAmount = $taxAmount . ' ' . $cSymbol; } $news_price .= JText::_('MOD_NEWS_PRO_GK5_PRODUCT_TAX_AMOUNT') . $taxAmount; $news_price .= '</div>'; } // 'Add to cart' button $news_cart = ''; //if($config['vm_add_to_cart'] == 1) { $code = '<form method="post" class="product" action="index.php">'; $code .= '<div class="addtocart-bar">'; $code .= '<span class="quantity-box" style="display: none"><input type="text" class="quantity-input" name="quantity[]" value="1" /></span>'; $button_lbl = JText::_('MOD_NEWS_PRO_GK5_COM_VIRTUEMART_CART_ADD_TO'); $button_cls = ''; $stockhandle = VmConfig::get('stockhandle', 'none'); $code .= '<span class="addtocart-button"><input type="submit" name="addtocart" class="addtocart-button" value="' . $button_lbl . '" title="' . $button_lbl . '" /></span>'; $code .= '</div> <input type="hidden" class="pname" value="' . $product->product_name . '"/> <input type="hidden" name="option" value="com_virtuemart" /> <input type="hidden" name="view" value="cart" /> <noscript><input type="hidden" name="task" value="add" /></noscript> <input type="hidden" name="virtuemart_product_id[]" value="' . $product->virtuemart_product_id . '" /> <input type="hidden" name="virtuemart_category_id[]" value="' . $product->virtuemart_category_id . '" /> </form>'; $news_cart .= $code; //} // restults return array("price" => $news_price, "cart" => $news_cart); }
function loadHeadData() { if (isset($this->headData)) { return; } $mainframe = JFactory::getApplication(); $document = JFactory::getDocument(); $params = JComponentHelper::getParams('com_k2mart'); $uri = JURI::getInstance(); $query = $uri->getQuery(true); unset($query['k2martCategories']); unset($query['k2martManufacturers']); unset($query['k2martOrdering']); unset($query['k2martOrderingDir']); unset($query['start']); $uri->setQuery($query); $url = $uri->toString(); if (JString::strpos($url, '?') === false) { $url .= '?'; } else { $url .= '&'; } $menu = $mainframe->getMenu(); $frontPageFlag = $menu->getActive() == $menu->getDefault(); if ($document->getType() == 'html') { vmJsApi::jPrice(); $document->addStyleSheet(JURI::root(true) . '/administrator/components/com_k2mart/css/chosen.css'); $ajaxFlag = $params->get('ajax') ? 'true' : 'false'; $frontPageFlag = $frontPageFlag ? 'true' : 'false'; $document->addScriptDeclaration('var K2martURL = "' . $url . '"; var K2martNoResultsText = "' . JText::_('K2MART_NO_RESULTS_MATCH', true) . '"; var K2martAJAX = ' . $ajaxFlag . '; var K2martFrontPage = ' . $frontPageFlag . ';'); $document->addScript(JURI::root(true) . '/administrator/components/com_k2mart/js/chosen.jquery.min.js'); $document->addScript(JURI::root(true) . '/plugins/k2/k2mart/includes/js/site.k2mart.js'); $document->addCustomTag(' <!--[if lte IE 6]> <style type="text/css"> .k2martClearFix { height: 1%; } </style> <![endif]--> <!--[if IE 7]> <style type="text/css"> .k2martClearFix { display:inline-block; } </style> <![endif]--> '); $this->headData = true; } }
/** * Collect all data to show on the template * * @author RolandD, Max Milbers */ function display($tpl = null) { //TODO get plugins running // $dispatcher = JDispatcher::getInstance(); // $limitstart = JRequest::getVar('limitstart', 0, '', 'int'); $show_prices = VmConfig::get('show_prices', 1); if ($show_prices == '1') { if (!class_exists('calculationHelper')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php'; } } $this->assignRef('show_prices', $show_prices); $document = JFactory::getDocument(); /* add javascript for price and cart */ vmJsApi::jPrice(); $mainframe = JFactory::getApplication(); $pathway = $mainframe->getPathway(); $task = JRequest::getCmd('task'); /* Set the helper path */ $this->addHelperPath(JPATH_VM_ADMINISTRATOR . DS . 'helpers'); //Load helpers $this->loadHelper('image'); /* Load the product */ // $product = $this->get('product'); //Why it is sensefull to use this construction? Imho it makes it just harder $product_model = VmModel::getModel('product'); $this->assignRef('product_model', $product_model); $virtuemart_product_idArray = JRequest::getInt('virtuemart_product_id', 0); if (is_array($virtuemart_product_idArray)) { $virtuemart_product_id = $virtuemart_product_idArray[0]; } else { $virtuemart_product_id = $virtuemart_product_idArray; } $product = $product_model->getProduct($virtuemart_product_id); // vmSetStartTime('customs'); // for($k=0;$k<count($product->customfields);$k++){ // $custom = $product->customfields[$k]; if (!empty($product->customfields)) { foreach ($product->customfields as $k => $custom) { if (!empty($custom->layout_pos)) { $product->customfieldsSorted[$custom->layout_pos][] = $custom; unset($product->customfields[$k]); } } $product->customfieldsSorted['normal'] = $product->customfields; unset($product->customfields); } // vmTime('Customs','customs'); // vmdebug('my second $product->customfields',$product->customfields); $last_category_id = shopFunctionsF::getLastVisitedCategoryId(); if (empty($product->slug)) { //Todo this should be redesigned to fit better for SEO $mainframe->enqueueMessage(JText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND')); $categoryLink = ''; if (!$last_category_id) { $last_category_id = JRequest::getInt('virtuemart_category_id', false); } if ($last_category_id) { $categoryLink = '&virtuemart_category_id=' . $last_category_id; } $mainframe->redirect(JRoute::_('index.php?option=com_virtuemart&view=category' . $categoryLink . '&error=404')); return; } $product->event = new stdClass(); $product->event->afterDisplayTitle = ''; $product->event->beforeDisplayContent = ''; $product->event->afterDisplayContent = ''; if (VmConfig::get('enable_content_plugin', 0)) { // add content plugin // $dispatcher =& JDispatcher::getInstance(); JPluginHelper::importPlugin('content'); $product->text = $product->product_desc; jimport('joomla.html.parameter'); $params = new JParameter(''); if (JVM_VERSION === 2) { $results = $dispatcher->trigger('onContentPrepare', array('com_virtuemart.productdetails', &$product, &$params, 0)); // More events for 3rd party content plugins // This do not disturb actual plugins, because we don't modify $product->text $res = $dispatcher->trigger('onContentAfterTitle', array('com_virtuemart.productdetails', &$product, &$params, 0)); $product->event->afterDisplayTitle = trim(implode("\n", $res)); $res = $dispatcher->trigger('onContentBeforeDisplay', array('com_virtuemart.productdetails', &$product, &$params, 0)); $product->event->beforeDisplayContent = trim(implode("\n", $res)); $res = $dispatcher->trigger('onContentAfterDisplay', array('com_virtuemart.productdetails', &$product, &$params, 0)); $product->event->afterDisplayContent = trim(implode("\n", $res)); } else { $results = $dispatcher->trigger('onPrepareContent', array(&$product, &$params, 0)); } $product->product_desc = $product->text; } $product_model->addImages($product); $this->assignRef('product', $product); if (isset($product->min_order_level) && (int) $product->min_order_level > 0) { $min_order_level = $product->min_order_level; } else { $min_order_level = 1; } $this->assignRef('min_order_level', $min_order_level); // Load the neighbours $product->neighbours = $product_model->getNeighborProducts($product); // if(!empty($product->neighbours) && is_array($product->neighbours) && !empty($product->neighbours[0]))$product_model->addImages($product->neighbours); // $product->related = $product_model->getRelatedProducts($virtuemart_product_id); // if(!empty($product->related) && is_array($product->related) && !empty($product->related[0]))$product_model->addImages($product->related); // Load the category $category_model = VmModel::getModel('category'); // Get the category ID if (is_array($product->categories)) { if (in_array($last_category_id, $product->categories)) { $virtuemart_category_id = $last_category_id; } else { $virtuemart_category_id = JRequest::getInt('virtuemart_category_id', 0); } if ($virtuemart_category_id == 0) { if (array_key_exists('0', $product->categories)) { $virtuemart_category_id = $product->categories[0]; } } } else { $virtuemart_category_id = JRequest::getInt('virtuemart_category_id', 0); } $product->virtuemart_category_id = $virtuemart_category_id; shopFunctionsF::setLastVisitedCategoryId($virtuemart_category_id); if ($category_model) { $category = $category_model->getCategory($virtuemart_category_id); $category_model->addImages($category, 1); $this->assignRef('category', $category); if ($category->parents) { foreach ($category->parents as $c) { $pathway->addItem(strip_tags($c->category_name), JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $c->virtuemart_category_id)); } } $vendorId = 1; $category->children = $category_model->getChildCategoryList($vendorId, $virtuemart_category_id); $category_model->addImages($category->children, 1); } if (!empty($tpl)) { $format = $tpl; } else { $format = JRequest::getWord('format', 'html'); } if ($format == 'html') { // Set Canonic link $document->addHeadLink(JRoute::_($product->canonical, true, -1), 'canonical', 'rel', ''); } $uri = JURI::getInstance(); //$pathway->addItem(JText::_('COM_VIRTUEMART_PRODUCT_DETAILS'), $uri->toString(array('path', 'query', 'fragment'))); $pathway->addItem(strip_tags($product->product_name)); // Set the titles // $document->setTitle should be after the additem pathway if ($product->customtitle) { $document->setTitle(strip_tags($product->customtitle)); } else { $document->setTitle(strip_tags(($category->category_name ? $category->category_name . ' : ' : '') . $product->product_name)); } $ratingModel = VmModel::getModel('ratings'); $allowReview = $ratingModel->allowReview($product->virtuemart_product_id); $this->assignRef('allowReview', $allowReview); $showReview = $ratingModel->showReview($product->virtuemart_product_id); $this->assignRef('showReview', $showReview); if ($showReview) { $review = $ratingModel->getReviewByProduct($product->virtuemart_product_id); $this->assignRef('review', $review); $rating_reviews = $ratingModel->getReviews($product->virtuemart_product_id); $this->assignRef('rating_reviews', $rating_reviews); } $showRating = $ratingModel->showRating($product->virtuemart_product_id); $this->assignRef('showRating', $showRating); if ($showRating) { $vote = $ratingModel->getVoteByProduct($product->virtuemart_product_id); $this->assignRef('vote', $vote); $rating = $ratingModel->getRatingByProduct($product->virtuemart_product_id); $this->assignRef('rating', $rating); } $allowRating = $ratingModel->allowRating($product->virtuemart_product_id); $this->assignRef('allowRating', $allowRating); // Check for editing access // @todo build edit page if (!class_exists('Permissions')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'permissions.php'; } //if (Permissions::getInstance()->check("admin,storeadmin")) { $perm = Permissions::getInstance(); $admin = $perm->check("admin"); if (!$admin) { vmdebug('No admin'); } $storeadmin = $perm->check("admin,storeadmin"); if (!$storeadmin) { vmdebug('No $storeadmin'); } $superVendor = $perm->isSuperVendor(); if (!$superVendor) { vmdebug('No $superVendor'); } if ($admin or $perm->isSuperVendor() == $product->virtuemart_vendor_id and $storeadmin) { $edit_link = JURI::root() . 'index.php?option=com_virtuemart&tmpl=component&view=product&task=edit&virtuemart_product_id=' . $product->virtuemart_product_id; $edit_link = $this->linkIcon($edit_link, 'COM_VIRTUEMART_PRODUCT_FORM_EDIT_PRODUCT', 'edit', false, false); } else { $edit_link = ""; } $this->assignRef('edit_link', $edit_link); // todo: atm same form for "call for price" and "ask a question". Title of the form should be different $askquestion_url = JRoute::_('index.php?option=com_virtuemart&view=productdetails&task=askquestion&virtuemart_product_id=' . $product->virtuemart_product_id . '&virtuemart_category_id=' . $product->virtuemart_category_id . '&tmpl=component'); $this->assignRef('askquestion_url', $askquestion_url); // Load the user details $user = JFactory::getUser(); $this->assignRef('user', $user); // More reviews link $uri = JURI::getInstance(); $uri->setVar('showall', 1); $uristring = $uri->toString(); $this->assignRef('more_reviews', $uristring); if ($product->metarobot) { $document->setMetaData('robots', $product->metarobot); } if ($mainframe->getCfg('MetaTitle') == '1') { // $document->setMetaData('title', $product->product_name); //Maybe better product_name $document->setMetaData('title', $product->customtitle); //Utilizzato il titolo custom compilato in automatico durante l'import } if ($mainframe->getCfg('MetaAuthor') == '1') { $document->setMetaData('author', $product->metaauthor); } if ($product->metadesc) { $document->setDescription($product->metadesc); } if ($product->metakey) { $document->setMetaData('keywords', $product->metakey); } $showBasePrice = Permissions::getInstance()->check('admin'); //todo add config settings $this->assignRef('showBasePrice', $showBasePrice); $productDisplayShipments = array(); $productDisplayPayments = array(); if (!class_exists('vmPSPlugin')) { require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php'; } JPluginHelper::importPlugin('vmshipment'); JPluginHelper::importPlugin('vmpayment'); $dispatcher = JDispatcher::getInstance(); $returnValues = $dispatcher->trigger('plgVmOnProductDisplayShipment', array($product, &$productDisplayShipments)); $returnValues = $dispatcher->trigger('plgVmOnProductDisplayPayment', array($product, &$productDisplayPayments)); $this->assignRef('productDisplayPayments', $productDisplayPayments); $this->assignRef('productDisplayShipments', $productDisplayShipments); if (empty($category->category_template)) { $category->category_template = VmConfig::get('categorytemplate'); } shopFunctionsF::setVmTemplate($this, $category->category_template, $product->product_template, $category->category_layout, $product->layout); shopFunctionsF::addProductToRecent($virtuemart_product_id); $currency = CurrencyDisplay::getInstance(); $this->assignRef('currency', $currency); if (JRequest::getCmd('layout', 'default') == 'notify') { $this->setLayout('notify'); } //Added by Seyi Awofadeju to catch notify layout parent::display($tpl); }
public function display($tpl = null) { $show_prices = VmConfig::get('show_prices', 1); if ($show_prices == '1') { if (!class_exists('calculationHelper')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php'; } } $this->assignRef('show_prices', $show_prices); $document = JFactory::getDocument(); // add javascript for price and cart vmJsApi::jPrice(); $app = JFactory::getApplication(); $pathway = $app->getPathway(); /* Set the helper path */ $this->addHelperPath(JPATH_VM_ADMINISTRATOR . DS . 'helpers'); //Load helpers $this->loadHelper('image'); $categoryModel = VmModel::getModel('category'); $productModel = VmModel::getModel('product'); $categoryId = JRequest::getInt('virtuemart_category_id', false); $vendorId = 1; $category = $categoryModel->getCategory($categoryId); $categoryModel->addImages($category, 1); $perRow = empty($category->products_per_row) ? VmConfig::get('products_per_row', 3) : $category->products_per_row; // $categoryModel->setPerRow($perRow); $this->assignRef('perRow', $perRow); //No redirect here, category id = 0 means show ALL categories! note by Max Milbers /* if(empty($category->virtuemart_vendor_id) && $search == null ) { $app -> enqueueMessage(JText::_('COM_VIRTUEMART_CATEGORY_NOT_FOUND')); $app -> redirect( 'index.php'); }*/ // Add the category name to the pathway if ($category->parents) { foreach ($category->parents as $c) { $pathway->addItem(strip_tags($c->category_name), JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $c->virtuemart_category_id)); } } // static $counter = 0; // static $counter2 = 0; //if($category->children) $categoryModel->addImages($category->children); $categoryModel->addImages($category, 1); $cache = JFactory::getCache('com_virtuemart', 'callback'); $category->children = $cache->call(array('VirtueMartModelCategory', 'getChildCategoryList'), $vendorId, $categoryId); // self::$categoryTree = self::categoryListTreeLoop($selectedCategories, $cid, $level, $disabledFields); // vmTime('end loop categoryListTree '.$counter); $categoryModel->addImages($category->children, 1); if (VmConfig::get('enable_content_plugin', 0)) { // add content plugin // $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('content'); $category->text = $category->category_description; if (!class_exists('JParameter')) { require JPATH_LIBRARIES . DS . 'joomla' . DS . 'html' . DS . 'parameter.php'; } $params = new JParameter(''); if (JVM_VERSION === 2) { $results = $dispatcher->trigger('onContentPrepare', array('com_virtuemart.category', &$category, &$params, 0)); // More events for 3rd party content plugins // This do not disturb actual plugins, because we don't modify $product->text $res = $dispatcher->trigger('onContentAfterTitle', array('com_virtuemart.category', &$category, &$params, 0)); $category->event->afterDisplayTitle = trim(implode("\n", $res)); $res = $dispatcher->trigger('onContentBeforeDisplay', array('com_virtuemart.category', &$category, &$params, 0)); $category->event->beforeDisplayContent = trim(implode("\n", $res)); $res = $dispatcher->trigger('onContentAfterDisplay', array('com_virtuemart.category', &$category, &$params, 0)); $category->event->afterDisplayContent = trim(implode("\n", $res)); } else { $results = $dispatcher->trigger('onPrepareContent', array(&$category, &$params, 0)); } $category->category_description = $category->text; } $this->assignRef('category', $category); // Set Canonic link if (!empty($tpl)) { $format = $tpl; } else { $format = JRequest::getWord('format', 'html'); } if ($format == 'html') { $document->addHeadLink(JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $categoryId), 'canonical', 'rel', ''); } // Set the titles if ($category->customtitle) { $title = strip_tags($category->customtitle); } elseif ($category->category_name) { $title = strip_tags($category->category_name); } else { $menus = $app->getMenu(); $menu = $menus->getActive(); if ($menu) { $title = $menu->title; } // $title = $this->params->get('page_title', ''); // Check for empty title and add site name if param is set if (empty($title)) { $title = $app->getCfg('sitename'); } elseif ($app->getCfg('sitename_pagetitles', 0) == 1) { $title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title); } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) { $title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename')); } } if (JRequest::getInt('error')) { $title .= ' ' . JText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND'); } // set search and keyword if ($keyword = vmRequest::uword('keyword', '', ' ')) { $pathway->addItem($keyword); $title .= ' (' . $keyword . ')'; } $search = JRequest::getvar('keyword', null); if ($search !== null) { $searchcustom = $this->getSearchCustom(); } $this->assignRef('keyword', $keyword); $this->assignRef('search', $search); // Load the products in the given category $products = $productModel->getProductsInCategory($categoryId); $productModel->addImages($products, 1); $this->assignRef('products', $products); foreach ($products as $product) { $product->stock = $productModel->getStockIndicator($product); } $ratingModel = VmModel::getModel('ratings'); $showRating = $ratingModel->showRating(); $this->assignRef('showRating', $showRating); $virtuemart_manufacturer_id = JRequest::getInt('virtuemart_manufacturer_id', 0); if ($virtuemart_manufacturer_id and !empty($products[0])) { $title .= ' ' . $products[0]->mf_name; } $document->setTitle($title); // Override Category name when viewing manufacturers products !IMPORTANT AFTER page title. if (JRequest::getInt('virtuemart_manufacturer_id') and !empty($products[0])) { $category->category_name = $products[0]->mf_name; } $pagination = $productModel->getPagination($perRow); $this->assignRef('vmPagination', $pagination); $orderByList = $productModel->getOrderByList($categoryId); $this->assignRef('orderByList', $orderByList); // $productRelatedManufacturerList = $productModel->getProductRelatedManufacturerList($categoryId); // $this->assignRef('productRelatedManufacturerList', $productRelatedManufacturerList); //$sortOrderButton = $productModel->getsortOrderButton(); //$this->assignRef('sortOrder', $sortOrderButton); if ($category->metadesc) { $document->setDescription($category->metadesc); } if ($category->metakey) { $document->setMetaData('keywords', $category->metakey); } if ($category->metarobot) { $document->setMetaData('robots', $category->metarobot); } if ($app->getCfg('MetaTitle') == '1') { $document->setMetaData('title', $title); } if ($app->getCfg('MetaAuthor') == '1') { $document->setMetaData('author', $category->metaauthor); } if ($products) { $currency = CurrencyDisplay::getInstance(); $this->assignRef('currency', $currency); } if (!class_exists('Permissions')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'permissions.php'; } $showBasePrice = Permissions::getInstance()->check('admin'); //todo add config settings $this->assignRef('showBasePrice', $showBasePrice); //set this after the $categoryId definition $paginationAction = JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $categoryId); $this->assignRef('paginationAction', $paginationAction); shopFunctionsF::setLastVisitedCategoryId($categoryId); shopFunctionsF::setLastVisitedManuId($virtuemart_manufacturer_id); if (empty($category->category_template)) { $category->category_template = VmConfig::get('categorytemplate'); } shopFunctionsF::setVmTemplate($this, $category->category_template, 0, $category->category_layout); parent::display($tpl); }
public function display($tpl = null) { $show_prices = VmConfig::get('show_prices', 1); if ($show_prices == '1') { if (!class_exists('calculationHelper')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php'; } } $this->assignRef('show_prices', $show_prices); if (!class_exists('shopFunctionsF')) { require VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php'; } $document = JFactory::getDocument(); $app = JFactory::getApplication(); $pathway = $app->getPathway(); if (!class_exists('VmImage')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'image.php'; } // set search and keyword if ($keyword = vRequest::getString('keyword', false)) { //uword('keyword', false, ' ,-,+,.,_')) { $pathway->addItem($keyword); //$title .=' ('.$keyword.')'; } //$search = vRequest::uword('keyword', null); $this->searchcustom = ''; $this->searchCustomValues = ''; //if (!empty($keyword)) { $this->getSearchCustom(); $search = $keyword; /*} else { $keyword =''; $search = NULL; }*/ $this->assignRef('keyword', $keyword); $this->assignRef('search', $search); $menus = $app->getMenu(); $menu = $menus->getActive(); if (!empty($menu->id)) { ShopFunctionsF::setLastVisitedItemId($menu->id); } else { if ($itemId = vRequest::getInt('Itemid', false)) { ShopFunctionsF::setLastVisitedItemId($itemId); } } $virtuemart_manufacturer_id = vRequest::getInt('virtuemart_manufacturer_id', -1); if ($virtuemart_manufacturer_id === -1 and !empty($menu->query['virtuemart_manufacturer_id'])) { $virtuemart_manufacturer_id = $menu->query['virtuemart_manufacturer_id']; vRequest::setVar('virtuemart_manufacturer_id', $virtuemart_manufacturer_id); } $this->categoryId = vRequest::getInt('virtuemart_category_id', -1); if ($this->categoryId === -1 and !empty($menu->query['virtuemart_category_id'])) { $this->categoryId = $menu->query['virtuemart_category_id']; vRequest::setVar('virtuemart_category_id', $this->categoryId); } else { if ($this->categoryId === -1 and $virtuemart_manufacturer_id === -1) { $this->categoryId = ShopFunctionsF::getLastVisitedCategoryId(); } } $this->setCanonicalLink($tpl, $document, $this->categoryId, $virtuemart_manufacturer_id); if (($this->categoryId === -1 or $this->categoryId === 0) and $virtuemart_manufacturer_id) { $this->categoryId = 0; $catType = 'manufacturer'; $this->setCanonicalLink($tpl, $document, $virtuemart_manufacturer_id, $catType); } $categoryModel = VmModel::getModel('category'); $productModel = VmModel::getModel('product'); if ($this->categoryId === -1) { $this->categoryId = 0; } $vendorId = 1; $category = $categoryModel->getCategory($this->categoryId); if (!isset($menu->query['showproducts'])) { $menu->query['showproducts'] = 1; } $this->showproducts = vRequest::getInt('showproducts', $menu->query['showproducts']); if (!empty($category)) { $vendorId = $category->virtuemart_vendor_id; if ($this->showproducts) { //if(empty($category->category_layout) or $category->category_layout != 'categories') { // Load the products in the given category $ids = $productModel->sortSearchListQuery(TRUE, $this->categoryId); $this->perRow = empty($category->products_per_row) ? VmConfig::get('products_per_row', 3) : $category->products_per_row; $this->vmPagination = $productModel->getPagination($this->perRow); $ratingModel = VmModel::getModel('ratings'); $this->showRating = $ratingModel->showRating(); $productModel->withRating = $this->showRating; $this->orderByList = $productModel->getOrderByList($this->categoryId); $this->products = $productModel->getProducts($ids); //$products = $productModel->getProductsInCategory($this->categoryId); $imgAmount = VmConfig::get('prodimg_browse', 1); $productModel->addImages($this->products, $imgAmount); if ($this->products) { $currency = CurrencyDisplay::getInstance(); $this->assignRef('currency', $currency); $display_stock = VmConfig::get('display_stock', 1); $showCustoms = VmConfig::get('show_pcustoms', 1); if ($display_stock or $showCustoms) { if (!$showCustoms) { foreach ($this->products as $i => $productItem) { $productItem->stock = $productModel->getStockIndicator($productItem); } } else { shopFunctionsF::sortLoadProductCustomsStockInd($this->products, $productModel); } } // add javascript for price and cart, need even for quantity buttons, so we need it almost anywhere vmJsApi::jPrice(); } // Add feed links if ($this->showproducts and $this->products && VmConfig::get('feed_cat_published', 0) == 1) { $link = '&format=feed&limitstart='; $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); $document->addHeadLink(JRoute::_($link . '&type=rss', FALSE), 'alternate', 'rel', $attribs); $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'); $document->addHeadLink(JRoute::_($link . '&type=atom', FALSE), 'alternate', 'rel', $attribs); } $user = JFactory::getUser(); $this->showBasePrice = (vmAccess::manager() or vmAccess::isSuperVendor()); } //No redirect here, for category id = 0 means show ALL categories! note by Max Milbers if (!empty($this->categoryId) and $this->categoryId !== -1 and (empty($category->slug) or !$category->published)) { if (empty($category->slug)) { vmInfo(vmText::_('COM_VIRTUEMART_CAT_NOT_FOUND')); } else { if ($category->virtuemart_id !== 0 and !$category->published) { vmInfo('COM_VIRTUEMART_CAT_NOT_PUBL', $category->category_name, $this->categoryId); } } //Fallback $categoryLink = ''; if ($category->category_parent_id) { $categoryLink = '&view=category&virtuemart_category_id=' . $category->category_parent_id; } else { $last_category_id = shopFunctionsF::getLastVisitedCategoryId(); if (!$last_category_id or $this->categoryId == $last_category_id) { $last_category_id = vRequest::getInt('virtuemart_category_id', false); } if ($last_category_id and $this->categoryId != $last_category_id) { $categoryLink = '&view=category&virtuemart_category_id=' . $last_category_id; } } if (VmConfig::get('handle_404', 1)) { $app->redirect(JRoute::_('index.php?option=com_virtuemart' . $categoryLink . '&error=404', FALSE)); } else { JError::raise(E_ERROR, '404', 'Not found'); } return; } shopFunctionsF::setLastVisitedCategoryId($this->categoryId); shopFunctionsF::setLastVisitedManuId($virtuemart_manufacturer_id); // Add the category name to the pathway if ($category->parents) { foreach ($category->parents as $c) { $pathway->addItem(strip_tags(vmText::_($c->category_name)), JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $c->virtuemart_category_id, FALSE)); } } $catImgAmount = VmConfig::get('catimg_browse', 1); $categoryModel->addImages($category, $catImgAmount); if (!isset($menu->query['showcategory'])) { $menu->query['showcategory'] = 1; } $this->showcategory = vRequest::getInt('showcategory', $menu->query['showcategory']); //$this->showcategory = vRequest::getInt('showcategory',true); if ($this->showcategory) { //if($category->category_layout == 'categories' or ($this->categoryId >0 and $virtuemart_manufacturer_id <1)){ $category->children = $categoryModel->getChildCategoryList($vendorId, $this->categoryId, $categoryModel->getDefaultOrdering(), $categoryModel->_selectedOrderingDir); $categoryModel->addImages($category->children, $catImgAmount); } else { $category->children = false; } if (VmConfig::get('enable_content_plugin', 0)) { shopFunctionsF::triggerContentPlugin($category, 'category', 'category_description'); } $metadesc = ''; $metakey = ''; $metarobot = ''; if (isset($menu->params)) { $metadesc = $menu->params->get('menu-meta_description'); $metakey = $menu->params->get('menu-meta_keywords'); $metarobot = $menu->params->get('robots'); } if ($category->metadesc) { $metadesc = $category->metadesc; } if ($category->metakey) { $metakey = $category->metakey; } if ($category->metarobot) { $metarobot = $category->metarobot; } $document->setDescription($metadesc); $document->setMetaData('keywords', $metakey); $document->setMetaData('robots', $metarobot); if ($app->getCfg('MetaAuthor') == '1' and !empty($category->metaauthor)) { $document->setMetaData('author', $category->metaauthor); } if (empty($category->category_template)) { $category->category_template = VmConfig::get('categorytemplate'); } if (!empty($menu->query['categorylayout'])) { //if(!empty($menu->query['categorylayout']) and $menu->query['virtuemart_category_id']==$this->categoryId){ $category->category_layout = $menu->query['categorylayout']; } $productsLayout = VmConfig::get('productsublayout', 'products'); if (empty($productsLayout)) { $productsLayout = 'products'; } $this->productsLayout = empty($menu->query['productsublayout']) ? $productsLayout : $menu->query['productsublayout']; shopFunctionsF::setVmTemplate($this, $category->category_template, 0, $category->category_layout); } else { //Backward compatibility if (!isset($category)) { $category = new stdClass(); $category->category_name = ''; $category->category_description = ''; $category->haschildren = false; } } $this->assignRef('category', $category); // Set the titles if (!empty($category->customtitle)) { $title = strip_tags($category->customtitle); } elseif (!empty($category->category_name)) { $title = strip_tags($category->category_name); } else { $title = $this->setTitleByJMenu($app); } $title = vmText::_($title); if (vRequest::getInt('error')) { $title .= ' ' . vmText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND'); } if (!empty($keyword)) { $title .= ' (' . strip_tags(htmlspecialchars_decode($keyword)) . ')'; } if ($virtuemart_manufacturer_id > 0 and !empty($this->products[0])) { $title .= ' ' . $this->products[0]->mf_name; } $document->setTitle($title); // Override Category name when viewing manufacturers products !IMPORTANT AFTER page title. if ($virtuemart_manufacturer_id > 0 and !empty($this->products[0]) and isset($category->category_name)) { $category->category_name = $this->products[0]->mf_name; } if ($app->getCfg('MetaTitle') == '1') { $document->setMetaData('title', $title); } parent::display($tpl); }
/** * Collect all data to show on the template * * @author RolandD, Max Milbers */ function display($tpl = null) { $show_prices = VmConfig::get('show_prices', 1); $this->assignRef('show_prices', $show_prices); $document = JFactory::getDocument(); $app = JFactory::getApplication(); $menus = $app->getMenu(); $menu = $menus->getActive(); if (!empty($menu->id)) { ShopFunctionsF::setLastVisitedItemId($menu->id); } else { if ($itemId = vRequest::getInt('Itemid', false)) { ShopFunctionsF::setLastVisitedItemId($itemId); } } $pathway = $app->getPathway(); $task = vRequest::getCmd('task'); if (!class_exists('VmImage')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'image.php'; } // Load the product //$product = $this->get('product'); //Why it is sensefull to use this construction? Imho it makes it just harder $product_model = VmModel::getModel('product'); $this->assignRef('product_model', $product_model); $virtuemart_product_idArray = vRequest::getInt('virtuemart_product_id', 0); if (is_array($virtuemart_product_idArray) and count($virtuemart_product_idArray) > 0) { $virtuemart_product_id = (int) $virtuemart_product_idArray[0]; } else { $virtuemart_product_id = (int) $virtuemart_product_idArray; } $quantityArray = vRequest::getInt('quantity', array()); //is sanitized then $quantity = 1; if (!empty($quantityArray[0])) { $quantity = $quantityArray[0]; } $ratingModel = VmModel::getModel('ratings'); $product_model->withRating = $this->showRating = $ratingModel->showRating($virtuemart_product_id); $product = $product_model->getProduct($virtuemart_product_id, TRUE, TRUE, TRUE, $quantity); if (!class_exists('shopFunctionsF')) { require VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php'; } $last_category_id = shopFunctionsF::getLastVisitedCategoryId(); $customfieldsModel = VmModel::getModel('Customfields'); if ($product->customfields) { if (!class_exists('vmCustomPlugin')) { require JPATH_VM_PLUGINS . DS . 'vmcustomplugin.php'; } $customfieldsModel->displayProductCustomfieldFE($product, $product->customfields); } if (empty($product->slug)) { //Todo this should be redesigned to fit better for SEO $app->enqueueMessage(vmText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND')); $categoryLink = ''; if (!$last_category_id) { $last_category_id = vRequest::getInt('virtuemart_category_id', false); } if ($last_category_id) { $categoryLink = '&virtuemart_category_id=' . $last_category_id; } if (VmConfig::get('handle_404', 1)) { $app->redirect(JRoute::_('index.php?option=com_virtuemart&view=category' . $categoryLink . '&error=404', FALSE)); } else { JError::raise(E_ERROR, '404', 'Not found'); } return; } $isCustomVariant = false; if (!empty($product->customfields)) { foreach ($product->customfields as $k => $custom) { if ($custom->field_type == 'C' and $custom->virtuemart_product_id != $virtuemart_product_id) { $isCustomVariant = $custom; } if (!empty($custom->layout_pos)) { $product->customfieldsSorted[$custom->layout_pos][] = $custom; } else { $product->customfieldsSorted['normal'][] = $custom; } unset($product->customfields); } } $product->event = new stdClass(); $product->event->afterDisplayTitle = ''; $product->event->beforeDisplayContent = ''; $product->event->afterDisplayContent = ''; if (VmConfig::get('enable_content_plugin', 0)) { shopFunctionsF::triggerContentPlugin($product, 'productdetails', 'product_desc'); } $product_model->addImages($product); if (isset($product->min_order_level) && (int) $product->min_order_level > 0) { $this->min_order_level = $product->min_order_level; } else { $this->min_order_level = 1; } if (isset($product->step_order_level) && (int) $product->step_order_level > 0) { $this->step_order_level = $product->step_order_level; } else { $this->step_order_level = 1; } // Load the neighbours if (VmConfig::get('product_navigation', 1)) { $product->neighbours = $product_model->getNeighborProducts($product); } $this->assignRef('product', $product); if (VmConfig::get('show_manufacturers', 1) && !empty($this->product->virtuemart_manufacturer_id)) { $manModel = VmModel::getModel('manufacturer'); $mans = array(); // Gebe die Hersteller aus foreach ($this->product->virtuemart_manufacturer_id as $manufacturer_id) { $manufacturer = $manModel->getManufacturer($manufacturer_id); $manModel->addImages($manufacturer, 1); $mans[] = $manufacturer; } $this->product->manufacturers = $mans; } // Load the category $category_model = VmModel::getModel('category'); shopFunctionsF::setLastVisitedCategoryId($product->virtuemart_category_id); if ($category_model) { $category = $category_model->getCategory($product->virtuemart_category_id); $category_model->addImages($category, 1); $this->assignRef('category', $category); //Seems we dont need this anylonger, destroyed the breadcrumb if ($category->parents) { foreach ($category->parents as $c) { if (is_object($c) and isset($c->category_name)) { $pathway->addItem(strip_tags(vmText::_($c->category_name)), JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $c->virtuemart_category_id, FALSE)); } else { vmdebug('Error, parent category has no name, breadcrumb maybe broken, category', $c); } } } $category->children = $category_model->getChildCategoryList($product->virtuemart_vendor_id, $product->virtuemart_category_id); $category_model->addImages($category->children, 1); } $pathway->addItem(strip_tags(html_entity_decode($product->product_name, ENT_QUOTES))); if (!empty($tpl)) { $format = $tpl; } else { $format = vRequest::getCmd('format', 'html'); } if ($format == 'html') { // remove joomla canonical before adding it foreach ($document->_links as $k => $array) { if ($array['relation'] == 'canonical') { unset($document->_links[$k]); break; } } // Set Canonic link if ($isCustomVariant !== false and !empty($isCustomVariant->usecanonical) and !empty($product->product_parent_id)) { $parent = $product_model->getProduct($product->product_parent_id); $document->addHeadLink($parent->canonical, 'canonical', 'rel', ''); } else { $document->addHeadLink($product->canonical, 'canonical', 'rel', ''); } } else { if ($format == 'pdf') { defined('K_PATH_IMAGES') or define('K_PATH_IMAGES', VMPATH_ROOT); } } // Set the titles // $document->setTitle should be after the additem pathway if ($product->customtitle) { $document->setTitle(strip_tags(html_entity_decode($product->customtitle, ENT_QUOTES))); } else { $document->setTitle(strip_tags(html_entity_decode(($category->category_name ? vmText::_($category->category_name) . ' : ' : '') . $product->product_name, ENT_QUOTES))); } $this->allowReview = $ratingModel->allowReview($product->virtuemart_product_id); $this->showReview = $ratingModel->showReview($product->virtuemart_product_id); $this->rating_reviews = ''; if ($this->showReview) { $this->review = $ratingModel->getReviewByProduct($product->virtuemart_product_id); $this->rating_reviews = $ratingModel->getReviews($product->virtuemart_product_id); } if ($this->showRating) { $this->vote = $ratingModel->getVoteByProduct($product->virtuemart_product_id); } $this->allowRating = $ratingModel->allowRating($product->virtuemart_product_id); $superVendor = vmAccess::isSuperVendor(); if ($superVendor == 1 or $superVendor == $product->virtuemart_vendor_id or $superVendor) { $edit_link = JURI::root() . 'index.php?option=com_virtuemart&tmpl=component&manage=1&view=product&task=edit&virtuemart_product_id=' . $product->virtuemart_product_id; $this->edit_link = $this->linkIcon($edit_link, 'COM_VIRTUEMART_PRODUCT_FORM_EDIT_PRODUCT', 'edit', false, false); } else { $this->edit_link = ""; } // Load the user details $this->user = JFactory::getUser(); // More reviews link $uri = JURI::getInstance(); $uri->setVar('showall', 1); $uristring = vmURI::getCleanUrl(); $this->assignRef('more_reviews', $uristring); if ($product->metadesc) { $document->setDescription(strip_tags(html_entity_decode($product->metadesc, ENT_QUOTES))); } else { $document->setDescription(strip_tags(html_entity_decode($product->product_name, ENT_QUOTES)) . " " . $category->category_name . " " . strip_tags(html_entity_decode($product->product_s_desc, ENT_QUOTES))); } if ($product->metakey) { $document->setMetaData('keywords', $product->metakey); } if ($product->metarobot) { $document->setMetaData('robots', $product->metarobot); } if ($app->getCfg('MetaTitle') == '1') { $document->setMetaData('title', $product->product_name); //Maybe better product_name } if ($app->getCfg('MetaAuthor') == '1') { $document->setMetaData('author', $product->metaauthor); } $user = JFactory::getUser(); $showBasePrice = (vmAccess::manager() or vmAccess::isSuperVendor()); $this->assignRef('showBasePrice', $showBasePrice); $productDisplayShipments = array(); $productDisplayPayments = array(); if (!class_exists('vmPSPlugin')) { require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php'; } JPluginHelper::importPlugin('vmshipment'); JPluginHelper::importPlugin('vmpayment'); $dispatcher = JDispatcher::getInstance(); $returnValues = $dispatcher->trigger('plgVmOnProductDisplayShipment', array($product, &$productDisplayShipments)); $returnValues = $dispatcher->trigger('plgVmOnProductDisplayPayment', array($product, &$productDisplayPayments)); $this->assignRef('productDisplayPayments', $productDisplayPayments); $this->assignRef('productDisplayShipments', $productDisplayShipments); if (empty($category->category_template)) { $category->category_template = VmConfig::get('categorytemplate'); } shopFunctionsF::setVmTemplate($this, $category->category_template, $product->product_template, $category->category_product_layout, $product->layout); shopFunctionsF::addProductToRecent($virtuemart_product_id); $currency = CurrencyDisplay::getInstance(); $this->assignRef('currency', $currency); if (vRequest::getCmd('layout', 'default') == 'notify') { $this->setLayout('notify'); } //Added by Seyi Awofadeju to catch notify layout VmConfig::loadJLang('com_virtuemart'); vmJsApi::chosenDropDowns(); //This must be loaded after the customfields are rendered (they may need to overwrite the handlers) if (VmConfig::get('jdynupdate', TRUE) or $app->isAdmin()) { vmJsApi::jDynUpdate(); } if ($show_prices == '1') { if (!class_exists('calculationHelper')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php'; } vmJsApi::jPrice(); } parent::display($tpl); }
/** * @param $snippet * @param $message * @return string */ function displayJSSnippet($hide_BTST) { // DESKTOP: Width of containing block shall be at least 750px // MOBILE: Width of containing block shall be 100% of browser window (No // padding or margin) vmJsApi::addJScript('/plugins/vmpayment/klarnacheckout/assets/js/klarnacheckout.js', false, false); vmJsApi::jPrice(); $updateCartScript = ' jQuery(document).ready(function($) { window._klarnaCheckout(function(api) { api.on({ "change": function(data) { console.log("window._klarnaCheckout calls klarnaCheckoutPayment.updateCart "); klarnaCheckoutPayment.updateCart(data,"' . $this->_currentMethod->virtuemart_paymentmethod_id . '"); } }); }); }); '; $updateSnippetScript = ' jQuery(document).ready(function($) { klarnaCheckoutPayment.updateSnippet(); }); '; $initPaymentScript = ' jQuery(document).ready(function($) { klarnaCheckoutPayment.initPayment(' . $hide_BTST . '); }); '; vmJsApi::jDynUpdate(); vmJsApi::addJScript('vm.kco_updatecart', $updateCartScript); vmJsApi::addJScript('vm.kco_initpayment', $initPaymentScript); //vmJsApi::addJScript('vm.kco_updatesnippet', $updateSnippetScript); $hide_BTST = false; return; }
public function display($tpl = null) { $show_prices = VmConfig::get('show_prices', 1); if ($show_prices == '1') { JLoader::register('calculationHelper', JPATH_VM_ADMINISTRATOR . '/helpers/calculationh.php'); } $this->assignRef('show_prices', $show_prices); // add javascript for price and cart, need even for quantity buttons, so we need it almost anywhere vmJsApi::jPrice(); $document = JFactory::getDocument(); $app = JFactory::getApplication(); $pathway = $app->getPathway(); JLoader::register('VmImage', JPATH_VM_ADMINISTRATOR . '/helpers/image.php'); $categoryModel = VmModel::getModel('category'); $productModel = VmModel::getModel('product'); $search = JRequest::getvar('keyword', null); if ($search !== null) { $searchcustom = $this->getSearchCustom(); } $this->assignRef('keyword', $keyword); $this->assignRef('search', $search); $categoryId = JRequest::getInt('virtuemart_category_id', ShopFunctionsF::getLastVisitedCategoryId()); $virtuemart_manufacturer_id = JRequest::getInt('virtuemart_manufacturer_id', 0); $this->setCanonicalLink($tpl, $document, $categoryId); // $vendorId = JRequest::getInt('virtuemart_vendor_id', 1); $vendorId = JRequest::getInt('virtuemart_vendor_id', null); // Load the products in the given category $products = $productModel->getProductsInCategory($categoryId, $vendorId); $productModel->addImages($products, 1); $this->assignRef('products', $products); if ($products) { $currency = CurrencyDisplay::getInstance(); $this->assignRef('currency', $currency); foreach ($products as $product) { $product->stock = $productModel->getStockIndicator($product); } } $ratingModel = VmModel::getModel('ratings'); $showRating = $ratingModel->showRating(); $this->assignRef('showRating', $showRating); $orderByList = $productModel->getOrderByList($categoryId); $this->assignRef('orderByList', $orderByList); // Add feed links if ($products && VmConfig::get('feed_cat_published', 0) == 1) { $link = '&format=feed&limitstart='; $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); $document->addHeadLink(JRoute::_($link . '&type=rss', FALSE), 'alternate', 'rel', $attribs); $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'); $document->addHeadLink(JRoute::_($link . '&type=atom', FALSE), 'alternate', 'rel', $attribs); } JLoader::register('Permissions', JPATH_VM_ADMINISTRATOR . '/helpers/permissions.php'); $showBasePrice = Permissions::getInstance()->check('admin'); //todo add config settings $this->assignRef('showBasePrice', $showBasePrice); //set this after the $categoryId definition $paginationAction = JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $categoryId, FALSE); $this->assignRef('paginationAction', $paginationAction); shopFunctionsF::setLastVisitedCategoryId($categoryId); shopFunctionsF::setLastVisitedManuId($virtuemart_manufacturer_id); if ($categoryId !== -1) { $vendorId = JRequest::getInt('virtuemart_vendor_id', 1); $category = $categoryModel->getCategory($categoryId); } $perRow = empty($category->products_per_row) ? VmConfig::get('products_per_row', 3) : $category->products_per_row; $this->assignRef('perRow', $perRow); $pagination = $productModel->getPagination($perRow); $this->assignRef('vmPagination', $pagination); if (!empty($category)) { if (!empty($categoryId) and $categoryId !== -1 and (empty($category->slug) or !$category->published)) { if (empty($category->slug)) { vmInfo(JText::_('COM_VIRTUEMART_CAT_NOT_FOUND')); } else { if ($category->virtuemart_id !== 0 and !$category->published) { vmInfo('COM_VIRTUEMART_CAT_NOT_PUBL', $category->category_name, $categoryId); //return false; } } $categoryLink = ''; if ($category->category_parent_id) { $categoryLink = '&view=category&virtuemart_category_id=' . $category->category_parent_id; } else { $last_category_id = shopFunctionsF::getLastVisitedCategoryId(); if (!$last_category_id or $categoryId == $last_category_id) { $last_category_id = JRequest::getInt('virtuemart_category_id', false); } if ($last_category_id and $categoryId != $last_category_id) { $categoryLink = '&view=category&virtuemart_category_id=' . $last_category_id; } } $app->redirect(JRoute::_('index.php?option=com_virtuemart' . $categoryLink . '&error=404', FALSE)); return; } //No redirect here, category id = 0 means show ALL categories! note by Max Milbers /* if(empty($category->virtuemart_vendor_id) && $search == null ) { $app -> enqueueMessage(JText::_('COM_VIRTUEMART_CATEGORY_NOT_FOUND')); $app -> redirect( 'index.php'); }*/ // Add the category name to the pathway if ($category->parents) { foreach ($category->parents as $c) { $pathway->addItem(strip_tags($c->category_name), JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $c->virtuemart_category_id, FALSE)); } } $categoryModel->addImages($category, 1); $cache = JFactory::getCache('com_virtuemart', 'callback'); $category->children = $cache->call(array('VirtueMartModelCategory', 'getChildCategoryList'), $vendorId, $categoryId); $categoryModel->addImages($category->children, 1); if (VmConfig::get('enable_content_plugin', 0)) { // add content plugin // $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('content'); $params = new JRegistry(); $category->event = new stdClass(); $category->catid = $category->virtuemart_category_id; $category->id = null; $category->title = $category->category_name; $category->text = $category->category_description; $results = $dispatcher->trigger('onContentPrepare', array('com_virtuemart.category', &$category, &$params, 0)); // More events for 3rd party content plugins // This do not disturb actual plugins, because we don't modify $product->text $res = $dispatcher->trigger('onContentAfterTitle', array('com_virtuemart.category', &$category, &$params, 0)); $category->event->afterDisplayTitle = trim(implode("\n", $res)); $res = $dispatcher->trigger('onContentBeforeDisplay', array('com_virtuemart.category', &$category, &$params, 0)); $category->event->beforeDisplayContent = trim(implode("\n", $res)); $res = $dispatcher->trigger('onContentAfterDisplay', array('com_virtuemart.category', &$category, &$params, 0)); $category->event->afterDisplayContent = trim(implode("\n", $res)); $category->category_description = $category->text; $category->category_name = $category->title; } if ($category->metadesc) { $document->setDescription($category->metadesc); } if ($category->metakey) { $document->setMetaData('keywords', $category->metakey); } if ($category->metarobot) { $document->setMetaData('robots', $category->metarobot); } if ($app->getCfg('MetaAuthor') == '1') { $document->setMetaData('author', $category->metaauthor); } if (empty($category->category_template)) { $category->category_template = VmConfig::get('categorytemplate'); } shopFunctionsF::setVmTemplate($this, $category->category_template, 0, $category->category_layout); } else { //Backward compatibility if (!isset($category)) { $category = new stdClass(); $category->category_name = ''; $category->category_description = ''; $category->haschildren = false; } } $this->assignRef('category', $category); // Set the titles if (!empty($category->customtitle)) { $title = strip_tags($category->customtitle); } elseif (!empty($category->category_name)) { $title = strip_tags($category->category_name); } else { $title = $this->setTitleByJMenu($app); } if (JRequest::getInt('error')) { $title .= ' ' . JText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND'); } if (!empty($keyword)) { $title .= ' (' . $keyword . ')'; } if ($virtuemart_manufacturer_id and !empty($products[0])) { $title .= ' ' . $products[0]->mf_name; } $document->setTitle($title); // Override Category name when viewing manufacturers products !IMPORTANT AFTER page title. if (JRequest::getInt('virtuemart_manufacturer_id') and !empty($products[0]) and isset($category->category_name)) { $category->category_name = $products[0]->mf_name; } if ($app->getCfg('MetaTitle') == '1') { $document->setMetaData('title', $title); } // set search and keyword if ($keyword = vmRequest::uword('keyword', '0', ' ,-,+,.,_')) { $pathway->addItem($keyword); //$title .=' ('.$keyword.')'; } parent::display($tpl); }