/** * @param XmapDisplayerInterface $xmap * @param stdCLass $parent * @param array $params * @param int $catid */ public static function getCategoryTree($xmap, stdClass $parent, array &$params, $catid = 0) { // TODO refactor if (!isset($urlBase)) { $urlBase = JURI::base(); } $vendorId = 1; $children = VmModel::getModel('category')->getChildCategoryList($vendorId, $catid); $xmap->changeLevel(1); foreach ($children as $row) { $node = new stdclass(); $node->id = $parent->id; $node->uid = $parent->uid . 'c' . $row->virtuemart_category_id; $node->browserNav = $parent->browserNav; $node->name = stripslashes($row->category_name); $node->priority = $params['cat_priority']; $node->changefreq = $params['cat_changefreq']; $node->expandible = true; $node->link = 'index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $row->virtuemart_category_id . '&Itemid=' . $parent->id; if ($xmap->printNode($node) !== false) { self::getCategoryTree($xmap, $parent, $params, $row->virtuemart_category_id); } } $xmap->changeLevel(-1); if ($params['include_products'] && $catid != 0) { $products = self::$productModel->getProductsInCategory($catid); if ($params['include_product_images']) { self::$categoryModel->addImages($products, 1); } $xmap->changeLevel(1); foreach ($products as $row) { $node = new stdclass(); $node->id = $parent->id; $node->uid = $parent->uid . 'c' . $row->virtuemart_category_id . 'p' . $row->virtuemart_product_id; $node->browserNav = $parent->browserNav; $node->priority = $params['prod_priority']; $node->changefreq = $params['prod_changefreq']; $node->name = $row->product_name; $node->modified = strtotime($row->modified_on); $node->expandible = false; $node->link = 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $row->virtuemart_product_id . '&virtuemart_category_id=' . $row->virtuemart_category_id . '&Itemid=' . $parent->id; if ($params['include_product_images']) { foreach ($row->images as $image) { if (isset($image->file_url)) { $imagenode = new stdClass(); $imagenode->src = $urlBase . $image->file_url_thumb; $imagenode->title = $row->product_name; $imagenode->license = $params['product_image_license_url']; $node->images[] = $imagenode; } } } $xmap->printNode($node); } $xmap->changeLevel(-1); } }
} if ($v['tag'] == "ORIGCURRENCY") { $origcurrency = $v['value']; } } $origcurrency = $origcurrency != "" ? $origcurrency : "EUR"; $RATES[$origcurrency] = 1; } // ALCON permette la definizione di feed in lingue differenti $p_lang = @$_GET['lang'] != "" ? @$_GET['lang'] : "it-IT"; $lang =& JFactory::getLanguage(); $lang->setLanguage($p_lang); $lang->load(); $tagging_params = @$_GET['tagging_params'] != "" ? urldecode($_GET['tagging_params']) : "utm_source=tradetracker-" . substr($p_lang, 0, 2) . "&utm_medium=pxp"; $cat = new VirtuemartModelCategory(); $product = new VirtueMartModelProduct(); $image = new VirtueMartModelMedia(); $currency = new VirtueMartModelCurrency(); // Pagination and limit settings $pagination = "off"; if (isset($_GET['pg']) && @$_GET['pg'] > 0) { $_step = $limit > 0 ? $limit : 1; $_start = ($_GET['pg'] - 1) * $_step; $_start = $_start >= 0 ? $_start : 0; $_end = $_start + $_step - 1; $pagination = "on"; } if ($limit > 0 && $pagination == "on") { $product->_noLimit = true; $nbrReturnProducts = false; } elseif ($limit > 0) {
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 getParentProductcategory($id) { static $parProdCat = array(); if (!isset($parProdCat[$id])) { VmModel::getModel('product'); $parent_id = VirtueMartModelProduct::getProductParentId($id); //If product is child then get parent category ID if ($parent_id and $parent_id != $id) { $db = JFactory::getDbo(); $query = 'SELECT `virtuemart_category_id` FROM `#__virtuemart_product_categories` ' . ' WHERE `virtuemart_product_id` = ' . $parent_id; $db->setQuery($query); //When the child and parent id is the same, this creates a deadlock //add $counter, dont allow more then 10 levels if (!($parProdCat[$id] = $db->loadResult())) { $this->counter++; if ($this->counter < 10) { $this->getParentProductcategory($parent_id); } } } else { $parProdCat[$id] = false; } $this->counter = 0; } return $parProdCat[$id]; }
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>' : ''; }
?> </th> <th class="od-arttot" align="right" width="10%"><?php echo JText::_('COM_VIRTUEMART_ORDER_PRINT_TOTAL'); ?> </th> </tr> <?php foreach ($this->orderdetails['items'] as $item) { $qtt = $item->product_quantity; $_link = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id=' . $item->virtuemart_category_id . '&virtuemart_product_id=' . $item->virtuemart_product_id); if (!class_exists('VirtueMartModelProduct')) { require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'product.php'; } $mf_name = VirtueMartModelProduct::get_mf_name($item->virtuemart_product_id); ?> <tr valign="top" class="od-artrow"> <td align="left" class="od-artname"> <?php echo "<p>" . $mf_name . "</p>"; ?> <a href="<?php echo $_link; ?> "><?php echo ucfirst($item->order_item_name); ?> </a> <?php // vmdebug('tmpl details_item $item',$item);
* * @package VirtueMart * @subpackage * @author Max Milbers, Valerie Isaksen * @link http://www.virtuemart.net * @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php * VirtueMart is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * @version $Id: default_relatedproducts.php 5406 2012-02-09 12:22:33Z alatak $ */ // Check to ensure this file is included in Joomla! defined('_JEXEC') or die('Restricted access'); $model = new VirtueMartModelProduct(); $calculator = calculationHelper::getInstance(); $currency = CurrencyDisplay::getInstance(); if (count($this->product->customfieldsRelatedProducts) > 0) { ?> <p class="det_ttl">C этим товаром так же покупают</p> <ul class="prod_list"> <?php foreach ($this->product->customfieldsRelatedProducts as $field) { $rel_product = $model->getProductSingle($field->custom_value, true); //print_r($rel_product); ?> <li> <a href="<?php echo $field->display->url; ?>
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); }
<?php defined('_JEXEC') or die('Restricted access'); $countlimit = 2; $imgResizeConfig = array('background' => '#ffffff', 'thumbnail_mode' => 'stretch'); $model = new VirtueMartModelProduct(); $calculator = calculationHelper::getInstance(); $currency = CurrencyDisplay::getInstance(); YTTemplateUtils::getImageResizerHelper($imgResizeConfig); $app =& JFactory::getApplication(); $templateDir = JURI::base() . 'templates/' . $app->getTemplate(); ?> <div class="product-related-products"> <h3 class="item-title"><?php echo JText::_('COM_VIRTUEMART_RELATED_PRODUCTS'); ?> </h3> <div id="yt_relate" class="pro_relate"> <div class="caroufredsel"> <ul id="yt_caroufredsel"> <?php foreach ($this->product->customfieldsRelatedProducts as $field) { if (!empty($field->display)) { ?> <li class="item"> <div class="spacer"> <div class="product-header"> <h3 class="title pull-left">
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>' : ''; }
function getData($number) { nextendimport('nextend.database.database'); $db = NextendDatabase::getInstance(); require_once JPATH_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_virtuemart' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'config.php'; VmConfig::loadConfig(); $language = $this->_data->get('virtuemartproductssourcelanguage', 'en_gb'); if (!$language) { $language = VMLANG; } $data = array(); $category = array_map('intval', explode('||', $this->_data->get('virtuemartproductssourcecategory', ''))); $query = 'SELECT '; $query .= 'prod.virtuemart_product_id AS id, '; $query .= 'prod.product_sku AS sku, '; $query .= 'prod_ext.product_name AS name, '; $query .= 'prod_ext.product_s_desc AS short_description, '; $query .= 'prod_ext.product_desc AS description, '; $query .= 'prod_ext.slug AS slug, '; $query .= 'cat.virtuemart_category_id AS category_id, '; $query .= 'cat.category_name, '; $query .= 'cat.category_description, '; $query .= 'cat.slug AS category_slug, '; $query .= 'man.virtuemart_manufacturer_id AS manufacturer_id, '; $query .= 'man.mf_name AS manufacturer_name, '; $query .= 'man.mf_email AS manufacturer_email, '; $query .= 'man.mf_desc AS manufacturer_description, '; $query .= 'man.mf_url AS manufacturer_url, '; $query .= 'man.slug AS manufacturer_slug, '; $query .= 'med.file_url AS image, '; $query .= 'med.file_url_thumb AS thumbnail, '; $query .= 'prod.hits '; $query .= 'FROM #__virtuemart_products AS prod '; $query .= 'LEFT JOIN #__virtuemart_products_' . $language . ' AS prod_ext ON prod.virtuemart_product_id = prod_ext.virtuemart_product_id '; $query .= 'LEFT JOIN #__virtuemart_product_categories AS cat_x ON cat_x.virtuemart_product_id = prod.virtuemart_product_id '; $query .= 'LEFT JOIN #__virtuemart_categories_' . $language . ' AS cat ON cat_x.virtuemart_category_id = cat.virtuemart_category_id '; $query .= 'LEFT JOIN #__virtuemart_product_manufacturers AS man_x ON man_x.virtuemart_product_id = prod.virtuemart_product_id '; $query .= 'LEFT JOIN #__virtuemart_manufacturers_' . $language . ' AS man ON man_x.virtuemart_manufacturer_id = man.virtuemart_manufacturer_id '; $query .= 'LEFT JOIN #__virtuemart_product_medias AS med_x ON med_x.virtuemart_product_id = prod.virtuemart_product_id '; $query .= 'LEFT JOIN #__virtuemart_medias AS med ON med_x.virtuemart_media_id = med.virtuemart_media_id '; $where = array(); if (!in_array(0, $category) && count($category) > 0) { $where[] = 'cat_x.virtuemart_category_id IN (' . implode(',', $category) . ') '; } if ($this->_data->get('virtuemartproductssourcepublished', 1)) { $where[] = ' prod.published = 1 '; } if ($this->_data->get('virtuemartproductssourcespecial', 0)) { $where[] = ' prod.product_special = 1 '; } if ($this->_data->get('virtuemartproductssourceinstock', 0)) { $where[] = ' prod.product_in_stock > 0 '; } $where[] = ' med.file_is_downloadable = 0 '; $where[] = ' med.file_is_forSale = 0 '; if (count($where) > 0) { $query .= 'WHERE ' . implode(' AND ', $where) . ' '; } $order = NextendParse::parse($this->_data->get('virtuemartproductsorder1', 'prod_ext.product_name|*|asc')); if ($order[0]) { $query .= 'ORDER BY ' . $order[0] . ' ' . $order[1] . ' '; $order = NextendParse::parse($this->_data->get('virtuemartproductsorder2', 'prod_ext.product_name|*|asc')); if ($order[0]) { $query .= ', ' . $order[0] . ' ' . $order[1] . ' '; } } $query .= 'LIMIT 0, ' . $number . ' '; $db->setQuery($query); $result = $db->loadAssocList(); require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'currencydisplay.php'; require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'models' . DS . 'product.php'; $currency = CurrencyDisplay::getInstance(); for ($i = 0; $i < count($result); $i++) { $result[$i]['title'] = $result[$i]['name']; $productModel = new VirtueMartModelProduct(); $p = $productModel->getProduct($result[$i]['id'], TRUE, TRUE, TRUE, 1, false); $result[$i]['price'] = $result[$i]['cost_price'] = $currency->createPriceDiv('costPrice', '', $p->prices, true); $result[$i]['base_price'] = $currency->createPriceDiv('basePrice', '', $p->prices, true); $result[$i]['base_price_variant'] = $currency->createPriceDiv('basePriceVariant', '', $p->prices, true); $result[$i]['base_price_with_tax'] = $currency->createPriceDiv('basePriceWithTax', '', $p->prices, true); $result[$i]['discounted_price_without_tax'] = $currency->createPriceDiv('discountedPriceWithoutTax', '', $p->prices, true); $result[$i]['price_before_tax'] = $currency->createPriceDiv('priceBeforeTax', '', $p->prices, true); $result[$i]['sales_price'] = $currency->createPriceDiv('salesPrice', '', $p->prices, true); $result[$i]['tax_amount'] = $currency->createPriceDiv('taxAmount', '', $p->prices, true); $result[$i]['sales_price_with_discount'] = $currency->createPriceDiv('salesPriceWithDiscount', '', $p->prices, true); $result[$i]['sales_price_temp'] = $currency->createPriceDiv('salesPriceTemp', '', $p->prices, true); $result[$i]['unit_price'] = $currency->createPriceDiv('unitPrice', '', $p->prices, true); $result[$i]['price_without_tax'] = $currency->createPriceDiv('priceWithoutTax', '', $p->prices, true); $result[$i]['discount_amount'] = $currency->createPriceDiv('discountAmount', '', $p->prices, true); $result[$i]['variant_modification'] = $currency->createPriceDiv('variantModification', '', $p->prices, true); $result[$i]['addtocart'] = $result[$i]['url'] = 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $result[$i]['id'] . '&virtuemart_category_id=' . $result[$i]['category_id']; $result[$i]['addtocart_label'] = 'View product'; $result[$i]['category_url'] = 'index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $result[$i]['category_id']; $result[$i]['image'] = JURI::root(false) . '/' . $result[$i]['image']; $result[$i]['thumbnail'] = JURI::root(false) . '/' . $result[$i]['thumbnail']; } return $result; }
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 function getPrice($product, $customVariant, $quantity) { $this->_db = JFactory::getDBO(); // vmdebug('strange',$product); // Loads the product price details if (!class_exists('calculationHelper')) { require JPATH_VM_ADMINISTRATOR . '/helpers/calculationh.php'; } $model = new VirtueMartModelProduct(); $model->getRawProductPrices($product, 1, array(), true); $calculator = calculationHelper::getInstance(); // Calculate the modificator $prices = $calculator->getProductPrices($product); $currency = CurrencyDisplay::getInstance(); $oldPrice = 'basePrice'; if ($prices['taxAmount']) { $oldPrice = 'basePriceWithTax'; } $product->old_price = $currency->createPriceDiv($oldPrice, '', $prices, true, true); $product->sales_price = $currency->createPriceDiv('salesPrice', '', $prices, true, true); return $product; }
/** * This function creates a product with the attributes of the parent. * * @param int $virtuemart_product_id * @param boolean $front for frontend use * @param boolean $withCalc calculate prices? * @param boolean published * @param int quantity * @param boolean load customfields */ public static function getProduct(&$productModel, $shg, $langs, $virtuemart_product_id = NULL, $front = TRUE, $withCalc = TRUE, $onlyPublished = TRUE, $quantity = 1, $customfields = TRUE, $virtuemart_shoppergroup_ids = 0) { $productModel = new VirtueMartModelProduct(); $productModel->starttime = microtime(TRUE); if (isset($virtuemart_product_id)) { $virtuemart_product_id = $productModel->setId($virtuemart_product_id); $parent_id = $virtuemart_product_id; } else { return false; } if ($virtuemart_shoppergroup_ids != 0 and is_array($virtuemart_shoppergroup_ids)) { $virtuemart_shoppergroup_idsString = implode('', $virtuemart_shoppergroup_ids); } else { $virtuemart_shoppergroup_idsString = $virtuemart_shoppergroup_ids; } $front = $front ? TRUE : 0; $withCalc = $withCalc ? TRUE : 0; $onlyPublished = $onlyPublished ? TRUE : 0; $customfields = $customfields ? TRUE : 0; $productModel->withRating = false; if ($productModel->memory_limit < ($mem = round(memory_get_usage(FALSE) / (1024 * 1024), 2))) { $m = round(memory_get_usage(FALSE) / (1024 * 1024), 2); echo 'low memory.. ' . $m . 'Mb'; return false; } $child = self::getProductSingle($productModel, $shg, $langs, $parent_id, $virtuemart_product_id, $front, $quantity, $customfields, $virtuemart_shoppergroup_ids); if (!isset($child->virtuemart_product_id)) { return false; } if (!isset($child->orderable)) { $child->orderable = TRUE; } //store the original parent id $pId = $child->virtuemart_product_id; $ppId = $child->product_parent_id; $published = $child->published; $i = 0; $count = 0; //Check for all attributes to inherited by parent products while (!empty($child->product_parent_id)) { $count++; if ($count > 100) { return false; } $parentProduct = self::getProductSingle($productModel, $shg, $langs, $parent_id, $child->product_parent_id, $front, $quantity, $customfields, $virtuemart_shoppergroup_ids); if ($child->product_parent_id === $parentProduct->product_parent_id) { vmError('Error, parent product with virtuemart_product_id = ' . $parentProduct->virtuemart_product_id . ' has same parent id like the child with virtuemart_product_id ' . $child->virtuemart_product_id); break; } $attribs = get_object_vars($parentProduct); foreach ($attribs as $k => $v) { if ('product_in_stock' != $k and 'product_ordered' != $k) { // Do not copy parent stock into child if (strpos($k, '_') !== 0 and empty($child->{$k})) { $child->{$k} = $v; // vmdebug($child->product_parent_id.' $child->$k',$child->$k); } } } $i++; if ($child->product_parent_id != $parentProduct->product_parent_id) { $child->product_parent_id = $parentProduct->product_parent_id; } else { $child->product_parent_id = 0; } } //vmdebug('getProduct Time: '.$runtime); $child->published = $published; $child->virtuemart_product_id = $pId; $child->product_parent_id = $ppId; if ($withCalc) { //$child->prices = $productModel->getPrice ($child, array(), 1); if (!class_exists('calculationHelper')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php'; } $session = JFactory::getSession(); $saveda = $session->get('vm_shoppergroups_add', array(), 'vm'); $savedr = $session->get('vm_shoppergroups_remove', array(), 'vm'); foreach ($shg as $sh) { // reset calculator: $calculator = calculationHelper::getInstance(); $calculator::$_instance = null; $session->set('vm_shoppergroups_add', array($sh), 'vm'); $session->set('vm_shoppergroups_remove', null, 'vm'); $calculator = calculationHelper::getInstance(); // Calculate the modificator //$variantPriceModification = $calculator->calculateModificators ($product, $customVariant); self::getProductPrices($child, $quantity, array($sh), true, $productModel, $calculator); $child->priceshg[$sh] = $child->prices; $child->prices = $child->priceshg[$sh]; $prices = $calculator->getProductPrices($child, 0.0, $quantity); $child->pricesCalc[$sh] = $prices; } unset($child->prices); $session->set('vm_shoppergroups_add', $saveda, 'vm'); $session->set('vm_shoppergroups_remove', $savedr, 'vm'); } if (empty($child->product_template)) { //$child->product_template = VmConfig::get ('producttemplate'); } if (!empty($child->canonCatLink)) { // Add the product link for canonical $child->canonical = 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $virtuemart_product_id . '&virtuemart_category_id=' . $child->canonCatLink; } else { $child->canonical = 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $virtuemart_product_id; } $child->canonical = JRoute::_($child->canonical, FALSE); if (!empty($child->virtuemart_category_id)) { $child->link = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $virtuemart_product_id . '&virtuemart_category_id=' . $child->virtuemart_category_id, FALSE); } else { $child->link = $child->canonical; } $child->quantity = $quantity; return $child; }
/** * The class constructor * @since 1.0 * @author Sakis Terz */ function __construct() { parent::__construct(); }