* 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. * See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details. * * http://virtuemart.net */ defined('_JEXEC') or die; $ccData = $viewData['ccData']; JHTML::_('behavior.tooltip'); JHTML::script('vmcreditcard.js', 'components/com_virtuemart/assets/js/', false); VmConfig::loadJLang('com_virtuemart', true); vmJsApi::jCreditCard(); vmJsApi::jQuery(); vmJsApi::chosenDropDowns(); $doc = JFactory::getDocument(); $doc->addScript(JURI::root(true) . '/plugins/vmpayment/realex_hpp_api/realex_hpp_api/assets/js/site.js'); $doc->addStyleSheet(JURI::root(true) . '/plugins/vmpayment/realex_hpp_api/realex_hpp_api/assets/css/realex.css'); $attribute = ''; if ($viewData['dccinfo']) { $attribute = ' readonly '; } ?> <div class="realex remote_cc_form" id="remote_cc_form"> <h3 class="order_amount"><?php echo $viewData['order_amount']; ?> </h3>
/** * Render a simple country list * * @author jseros, Max Milbers, Valérie Isaksen * * @param int $countryId Selected country id * @param boolean $multiple True if multiple selections are allowed (default: false) * @param mixed $_attrib string or array with additional attributes, * e.g. 'onchange=somefunction()' or array('onchange'=>'somefunction()') * @param string $_prefix Optional prefix for the formtag name attribute * @return string HTML containing the <select /> */ public static function renderCountryList($countryId = 0, $multiple = FALSE, $_attrib = array(), $_prefix = '', $required = 0) { $countryModel = VmModel::getModel('country'); $countries = $countryModel->getCountries(TRUE, TRUE, FALSE); $attrs = array(); $name = 'country_name'; $id = 'virtuemart_country_id'; $idA = $_prefix . 'virtuemart_country_id'; $attrs['class'] = 'virtuemart_country_id'; $attrs['class'] = 'vm-chzn-select'; // Load helpers and languages files if (!class_exists('VmConfig')) { require JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers' . DS . 'config.php'; } VmConfig::loadConfig(); VmConfig::loadJLang('com_virtuemart_countries'); vmJsApi::chosenDropDowns(); $sorted_countries = array(); $lang = JFactory::getLanguage(); $prefix = "COM_VIRTUEMART_COUNTRY_"; foreach ($countries as $country) { $country_string = $lang->hasKey($prefix . $country->country_3_code) ? JText::_($prefix . $country->country_3_code) : $country->country_name; $sorted_countries[$country->virtuemart_country_id] = $country_string; } asort($sorted_countries); $countries_list = array(); $i = 0; foreach ($sorted_countries as $key => $value) { $countries_list[$i] = new stdClass(); $countries_list[$i]->{$id} = $key; $countries_list[$i]->{$name} = $value; $i++; } if ($required != 0) { $attrs['class'] .= ' required'; } if ($multiple) { $attrs['multiple'] = 'multiple'; $idA .= '[]'; } else { $emptyOption = JHTML::_('select.option', '', JText::_('COM_VIRTUEMART_LIST_EMPTY_OPTION'), $id, $name); array_unshift($countries_list, $emptyOption); } if (is_array($_attrib)) { $attrs = array_merge($attrs, $_attrib); } else { $_a = explode('=', $_attrib, 2); $attrs[$_a[0]] = $_a[1]; } //Todo remove inline style //$attrs['style'] = 'width:270px;'; return JHTML::_('select.genericlist', $countries_list, $idA, $attrs, $id, $name, $countryId); }
/** * Formating front display by roles * for product only ! */ public function displayProductCustomfieldFE(&$product, $customfield, $row = '') { $virtuemart_custom_id = isset($customfield->virtuemart_custom_id) ? $customfield->virtuemart_custom_id : 0; $value = $customfield->custom_value; $type = $customfield->field_type; $is_list = isset($customfield->is_list) ? $customfield->is_list : 0; $price = isset($customfield->custom_price) ? $customfield->custom_price : 0; $is_cart = isset($customfield->is_cart) ? $customfield->is_cart : 0; //vmdebug('displayProductCustomfieldFE and here is something wrong ',$customfield); if (!class_exists('CurrencyDisplay')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php'; } $currency = CurrencyDisplay::getInstance(); if ($is_list > 0) { $values = explode(';', $value); if ($is_cart != 0) { $options = array(); foreach ($values as $key => $val) { $options[] = array('value' => $val, 'text' => $val); } vmJsApi::chosenDropDowns(); return JHTML::_('select.genericlist', $options, 'field[' . $row . '][custom_value]', NULL, 'value', 'text', FALSE, TRUE); } else { $html = ''; $html .= '<div id="custom_' . $virtuemart_custom_id . '_' . $value . '" >' . $value . '</div>'; return $html; } } else { if ($price > 0) { $price = $currency->priceDisplay((double) $price); } switch ($type) { case 'A': $options = array(); $session = JFactory::getSession(); $virtuemart_category_id = $session->get('vmlastvisitedcategoryid', 0, 'vm'); $productModel = VmModel::getModel('product'); //Note by Jeremy Magne (Daycounts) 2013-08-31 //Previously the the product model is loaded but we need to ensure the correct product id is set because the getUncategorizedChildren does not get the product id as parameter. //In case the product model was previously loaded, by a related product for example, this would generate wrong uncategorized children list $productModel->setId($product->virtuemart_product_id); //parseCustomParams VirtueMartModelCustomfields::bindParameterableByFieldType($customfield); //Todo preselection as dropdown of children //Note by Max Milbers: This is not necessary, in this case it is better to unpublish the parent and to give the child which should be preselected a category //Or it is withParent, in that case there exists the case, that a parent should be used as a kind of mini category and not be orderable. //There exists already other customs and in special plugins which wanna disable or change the add to cart button. //I suggest that we manipulate the button with a message "choose a variant first" //if(!isset($customfield->pre_selected)) $customfield->pre_selected = 0; $selected = JRequest::getVar('virtuemart_product_id', 0); if (is_array($selected)) { $selected = $selected[0]; } $selected = (int) $selected; $html = ''; $uncatChildren = $productModel->getUncategorizedChildren($customfield->withParent); if (empty($uncatChildren)) { return $html; break; } if (!$customfield->withParent or $customfield->withParent and $customfield->parentOrderable) { $options[0] = array('value' => JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id=' . $virtuemart_category_id . '&virtuemart_product_id=' . $customfield->virtuemart_product_id, FALSE), 'text' => vmText::_('COM_VIRTUEMART_ADDTOCART_CHOOSE_VARIANT')); } foreach ($uncatChildren as $child) { $options[] = array('value' => JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id=' . $virtuemart_category_id . '&virtuemart_product_id=' . $child['virtuemart_product_id'], FALSE), 'text' => $child['product_name']); } //vmJsApi::chosenDropDowns(); would need class="inputbox vm-chzn-select", but it does not work, in case people have two times the same product, //because both dropdowns have then the same id and the js does not work. $html .= JHTML::_('select.genericlist', $options, 'field[' . $row . '][custom_value]', 'onchange="window.top.location.href=this.options[this.selectedIndex].value" size="1" class="inputbox"', "value", "text", JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id=' . $virtuemart_category_id . '&virtuemart_product_id=' . $selected, FALSE)); //vmdebug('$customfield',$customfield); if ($customfield->parentOrderable == 0 and $product->product_parent_id == 0) { $product->orderable = FALSE; } return $html; break; /* variants*/ /* variants*/ case 'V': if ($price == 0) { $price = vmText::_('COM_VIRTUEMART_CART_PRICE_FREE'); } /* Loads the product price details */ return '<input type="text" value="' . vmText::_($value) . '" name="field[' . $row . '][custom_value]" /> ' . vmText::_('COM_VIRTUEMART_CART_PRICE') . $price . ' '; break; /*Date variant*/ /*Date variant*/ case 'D': return '<span class="product_custom_date">' . vmJsApi::date($value, 'LC1', TRUE) . '</span>'; //vmJsApi::jDate($field->custom_value, 'field['.$row.'][custom_value]','field_'.$row.'_customvalue').$priceInput; break; /* text area or editor No vmText, only displayed in BE */ /* text area or editor No vmText, only displayed in BE */ case 'X': case 'Y': return $value; break; /* string or integer */ /* string or integer */ case 'S': case 'I': return vmText::_($value); break; /* bool */ /* bool */ case 'B': if ($value == 0) { return vmText::_('COM_VIRTUEMART_NO'); } return vmText::_('COM_VIRTUEMART_YES'); break; /* parent */ /* parent */ case 'P': return '<span class="product_custom_parent">' . vmText::_($value) . '</span>'; break; /* related */ /* related */ case 'R': $pModel = VmModel::getModel('product'); $related = $pModel->getProduct((int) $value, TRUE, TRUE, TRUE, 1, FALSE); if (!$related) { vmError('related product is missing, maybe unpublished ' . $product->product_name . ' id: ' . $product->virtuemart_product_id); return false; } $thumb = ''; if (!empty($related->virtuemart_media_id[0])) { $thumb = $this->displayCustomMedia($related->virtuemart_media_id[0]) . ' '; } else { $thumb = $this->displayCustomMedia(0) . ' '; } return JHTML::link(JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $related->virtuemart_product_id . '&virtuemart_category_id=' . $related->virtuemart_category_id, FALSE), $thumb . $related->product_name, array('title' => $related->product_name)); break; /* image */ /* image */ case 'M': return $this->displayCustomMedia($value); break; /* categorie */ /* categorie */ case 'Z': $q = 'SELECT * FROM `#__virtuemart_categories_' . VMLANG . '` as l JOIN `#__virtuemart_categories` AS c using (`virtuemart_category_id`) WHERE `published`=1 AND l.`virtuemart_category_id`= "' . (int) $value . '" '; $this->_db->setQuery($q); if ($category = $this->_db->loadObject()) { $q = 'SELECT `virtuemart_media_id` FROM `#__virtuemart_category_medias`WHERE `virtuemart_category_id`= "' . $category->virtuemart_category_id . '" '; $this->_db->setQuery($q); $thumb = ''; if ($media_id = $this->_db->loadResult()) { $thumb = $this->displayCustomMedia($media_id, 'category'); } return JHTML::link(JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $category->virtuemart_category_id, FALSE), $thumb . ' ' . $category->category_name, array('title' => $category->category_name)); } else { return ''; } /* Child Group list * this have no direct display , used for stockable product */ /* Child Group list * this have no direct display , used for stockable product */ case 'G': return ''; //'<input type="text" value="'.vmText::_($value).'" name="field['.$row.'][custom_value]" /> '.vmText::_('COM_VIRTUEMART_CART_PRICE').' : '.$price .' '; break; break; } } }
/** * @author Max Milbers * @param $product * @param $customfield */ public function displayProductCustomfieldFE(&$product, &$customfields) { if (!class_exists('calculationHelper')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php'; } $calculator = calculationHelper::getInstance(); $selectList = array(); $dynChilds = 1; //= array(); $session = JFactory::getSession(); $virtuemart_category_id = $session->get('vmlastvisitedcategoryid', 0, 'vm'); foreach ($customfields as $k => &$customfield) { if (!isset($customfield->display)) { $customfield->display = ''; } $calculator->_product = $product; if (!class_exists('vmCustomPlugin')) { require VMPATH_PLUGINLIBS . DS . 'vmcustomplugin.php'; } if ($customfield->field_type == "E") { JPluginHelper::importPlugin('vmcustom'); $dispatcher = JDispatcher::getInstance(); $ret = $dispatcher->trigger('plgVmOnDisplayProductFEVM3', array(&$product, &$customfield)); continue; } $fieldname = 'field[' . $product->virtuemart_product_id . '][' . $customfield->virtuemart_customfield_id . '][customfield_value]'; $customProductDataName = 'customProductData[' . $product->virtuemart_product_id . '][' . $customfield->virtuemart_custom_id . ']'; //This is a kind of fallback, setting default of custom if there is no value of the productcustom $customfield->customfield_value = empty($customfield->customfield_value) ? $customfield->custom_value : $customfield->customfield_value; $type = $customfield->field_type; $idTag = (int) $product->virtuemart_product_id . '-' . $customfield->virtuemart_customfield_id; $idTag = $idTag . 'customProductData'; $idTag = VmHtml::ensureUniqueId($idTag); if (!class_exists('CurrencyDisplay')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php'; } $currency = CurrencyDisplay::getInstance(); switch ($type) { case 'C': $html = ''; $dropdowns = array(); if (isset($customfield->options->{$product->virtuemart_product_id})) { $productSelection = $customfield->options->{$product->virtuemart_product_id}; } else { $productSelection = false; } $ignore = array(); foreach ($customfield->options as $product_id => $variants) { foreach ($variants as $k => $variant) { //if(in_array($variant,$ignore)){ vmdebug('Product to ignore, continue',$product_id,$k,$variant);continue;} if (!isset($dropdowns[$k]) or !is_array($dropdowns[$k])) { $dropdowns[$k] = array(); } if (!in_array($variant, $dropdowns[$k])) { if ($k == 0 or !$productSelection) { $dropdowns[$k][] = $variant; } else { if ($k > 0 and $productSelection[$k - 1] == $variants[$k - 1]) { $break = false; for ($h = 1; $h <= $k; $h++) { if ($productSelection[$h - 1] != $variants[$h - 1]) { //$ignore[] = $variant; $break = true; } } if (!$break) { $dropdowns[$k][] = $variant; } } else { // break; } } } } } $tags = array(); foreach ($customfield->selectoptions as $k => $soption) { $options = array(); $selected = false; foreach ($dropdowns[$k] as $i => $elem) { $elem = trim((string) $elem); $text = $elem; if ($soption->clabel != '' and in_array($soption->voption, self::$dimensions)) { $rd = $soption->clabel; if (is_numeric($rd) and is_numeric($elem)) { $text = number_format(round((double) $elem, (int) $rd), $rd); } //vmdebug('($dropdowns[$k] in DIMENSION value = '.$elem.' r='.$rd.' '.$text); } else { if ($soption->voption === 'clabels' and $soption->clabel != '') { $text = vmText::_($elem); } } if ($elem == '0') { $text = vmText::_('COM_VIRTUEMART_LIST_EMPTY_OPTION'); } $options[] = array('value' => $elem, 'text' => $text); if ($productSelection and $productSelection[$k] == $elem) { $selected = $elem; } } if (empty($selected)) { $product->orderable = false; } $idTagK = $idTag . 'cvard' . $k; if ($customfield->showlabels) { if (in_array($soption->voption, self::$dimensions)) { $soption->slabel = vmText::_('COM_VIRTUEMART_' . strtoupper($soption->voption)); } else { if (!empty($soption->clabel) and !in_array($soption->voption, self::$dimensions)) { $soption->slabel = vmText::_($soption->clabel); } } if (isset($soption->slabel)) { $html .= '<span class="vm-cmv-label" >' . $soption->slabel . '</span>'; } } $attribs = array('class' => 'vm-chzn-select cvselection no-vm-bind', 'data-dynamic-update' => '1'); if ('productdetails' != vRequest::getCmd('view')) { $attribs['reload'] = '1'; } $html .= JHtml::_('select.genericlist', $options, $fieldname, $attribs, "value", "text", $selected, $idTagK); $tags[] = $idTagK; } $Itemid = vRequest::getInt('Itemid', ''); // '&Itemid=127'; if (!empty($Itemid)) { $Itemid = '&Itemid=' . $Itemid; } //create array for js $jsArray = array(); $url = ''; foreach ($customfield->options as $product_id => $variants) { $url = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id=' . $virtuemart_category_id . '&virtuemart_product_id=' . $product_id . $Itemid); $jsArray[] = '["' . $url . '","' . implode('","', $variants) . '"]'; } vmJsApi::addJScript('cvfind', false, false); $jsVariants = implode(',', $jsArray); $j = "\n\t\t\t\t\t\tjQuery('#" . implode(',#', $tags) . "').off('change',Virtuemart.cvFind);\n\t\t\t\t\t\tjQuery('#" . implode(',#', $tags) . "').on('change', { variants:[" . $jsVariants . "] },Virtuemart.cvFind);\n\t\t\t\t\t"; $hash = md5(implode('', $tags)); vmJsApi::addJScript('cvselvars' . $hash, $j, false); //Now we need just the JS to reload the correct product $customfield->display = $html; break; case 'A': $html = ''; //if($selectedFound) continue; $options = array(); $productModel = VmModel::getModel('product'); //Note by Jeremy Magne (Daycounts) 2013-08-31 //Previously the the product model is loaded but we need to ensure the correct product id is set because the getUncategorizedChildren does not get the product id as parameter. //In case the product model was previously loaded, by a related product for example, this would generate wrong uncategorized children list $productModel->setId($customfield->virtuemart_product_id); $uncatChildren = $productModel->getUncategorizedChildren($customfield->withParent); if (!$customfield->withParent or $customfield->withParent and $customfield->parentOrderable) { $options[0] = array('value' => JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id=' . $virtuemart_category_id . '&virtuemart_product_id=' . $customfield->virtuemart_product_id, FALSE), 'text' => vmText::_('COM_VIRTUEMART_ADDTOCART_CHOOSE_VARIANT')); } $selected = vRequest::getInt('virtuemart_product_id', 0); $selectedFound = false; if (empty($calculator) and $customfield->wPrice) { if (!class_exists('calculationHelper')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php'; } $calculator = calculationHelper::getInstance(); } $parentStock = 0; foreach ($uncatChildren as $k => $child) { if (!isset($child[$customfield->customfield_value])) { vmdebug('The child has no value at index ' . $customfield->customfield_value, $customfield, $child); } else { $productChild = $productModel->getProduct((int) $child['virtuemart_product_id'], false); if (!$productChild) { continue; } $available = $productChild->product_in_stock - $productChild->product_ordered; if (VmConfig::get('stockhandle', 'none') == 'disableit_children' and $available <= 0) { continue; } $parentStock += $available; $priceStr = ''; if ($customfield->wPrice) { //$product = $productModel->getProductSingle((int)$child['virtuemart_product_id'],false); $productPrices = $calculator->getProductPrices($productChild); $priceStr = ' (' . $currency->priceDisplay($productPrices['salesPrice']) . ')'; } $options[] = array('value' => JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id=' . $virtuemart_category_id . '&virtuemart_product_id=' . $child['virtuemart_product_id']), 'text' => $child[$customfield->customfield_value] . $priceStr); if ($selected == $child['virtuemart_product_id']) { $selectedFound = true; vmdebug($customfield->virtuemart_product_id . ' $selectedFound by vRequest ' . $selected); } //vmdebug('$child productId ',$child['virtuemart_product_id'],$customfield->customfield_value,$child); } } if (!$selectedFound) { $pos = array_search($customfield->virtuemart_product_id, $product->allIds); if (isset($product->allIds[$pos - 1])) { $selected = $product->allIds[$pos - 1]; //vmdebug($customfield->virtuemart_product_id.' Set selected to - 1 allIds['.($pos-1).'] = '.$selected.' and count '.$dynChilds); //break; } elseif (isset($product->allIds[$pos])) { $selected = $product->allIds[$pos]; //vmdebug($customfield->virtuemart_product_id.' Set selected to allIds['.$pos.'] = '.$selected.' and count '.$dynChilds); } else { $selected = $customfield->virtuemart_product_id; //vmdebug($customfield->virtuemart_product_id.' Set selected to $customfield->virtuemart_product_id ',$selected,$product->allIds); } } $url = 'index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id=' . $virtuemart_category_id . '&virtuemart_product_id=' . $selected; $html .= JHtml::_('select.genericlist', $options, $fieldname, 'onchange="window.top.location.href=this.options[this.selectedIndex].value" size="1" class="vm-chzn-select no-vm-bind" data-dynamic-update="1" ', "value", "text", JRoute::_($url, false), $idTag); vmJsApi::chosenDropDowns(); if ($customfield->parentOrderable == 0) { if ($product->product_parent_id == 0) { $product->orderable = FALSE; } else { $product->product_in_stock = $parentStock; } } else { } $dynChilds++; $customfield->display = $html; break; /*Date variant*/ /*Date variant*/ case 'D': if (empty($customfield->custom_value)) { $customfield->custom_value = 'LC2'; } //Customer selects date if ($customfield->is_input) { $customfield->display = '<span class="product_custom_date">' . vmJsApi::jDate($customfield->customfield_value, $customProductDataName) . '</span>'; //vmJsApi::jDate($field->custom_value, 'field['.$row.'][custom_value]','field_'.$row.'_customvalue').$priceInput; } else { $customfield->display = '<span class="product_custom_date">' . vmJsApi::date($customfield->customfield_value, $customfield->custom_value, TRUE) . '</span>'; } break; /* text area or editor No vmText, only displayed in BE */ /* text area or editor No vmText, only displayed in BE */ case 'X': case 'Y': $customfield->display = $customfield->customfield_value; break; /* string or integer */ /* string or integer */ case 'B': case 'S': case 'M': if ($type == 'M') { $selectType = 'select.radiolist'; $class = ''; } else { $selectType = 'select.genericlist'; if (!empty($customfield->is_input)) { vmJsApi::chosenDropDowns(); $class = 'class="vm-chzn-select"'; } } if ($customfield->is_list and $customfield->is_list != 2) { if (!empty($customfield->is_input)) { $options = array(); $values = explode(';', $customfield->custom_value); foreach ($values as $key => $val) { if ($type == 'M') { $tmp = array('value' => $val, 'text' => $this->displayCustomMedia($val, 'product', $customfield->width, $customfield->height)); $options[] = (object) $tmp; } else { $options[] = array('value' => $val, 'text' => vmText::_($val)); } } $currentValue = $customfield->customfield_value; $customfield->display = JHtml::_($selectType, $options, $customProductDataName . '[' . $customfield->virtuemart_customfield_id . ']', $class, 'value', 'text', $currentValue, $idTag); } else { if ($type == 'M') { $customfield->display = $this->displayCustomMedia($customfield->customfield_value, 'product', $customfield->width, $customfield->height); } else { $customfield->display = vmText::_($customfield->customfield_value); } } } else { if (!empty($customfield->is_input)) { if (!isset($selectList[$customfield->virtuemart_custom_id])) { $tmpField = clone $customfield; $tmpField->options = null; $customfield->options[$customfield->virtuemart_customfield_id] = $tmpField; $selectList[$customfield->virtuemart_custom_id] = $k; $customfield->customProductDataName = $customProductDataName; } else { $customfields[$selectList[$customfield->virtuemart_custom_id]]->options[$customfield->virtuemart_customfield_id] = $customfield; unset($customfields[$k]); //$customfield->options[$customfield->virtuemart_customfield_id] = $customfield; } $default = reset($customfields[$selectList[$customfield->virtuemart_custom_id]]->options); foreach ($customfields[$selectList[$customfield->virtuemart_custom_id]]->options as &$productCustom) { $price = self::_getCustomPrice($productCustom->customfield_price, $currency, $calculator); if ($type == 'M') { $productCustom->text = $this->displayCustomMedia($productCustom->customfield_value, 'product', $customfield->width, $customfield->height) . ' ' . $price; } else { $trValue = vmText::_($productCustom->customfield_value); if ($productCustom->customfield_value != $trValue and strpos($trValue, '%1') !== false) { $productCustom->text = vmText::sprintf($productCustom->customfield_value, $price); } else { $productCustom->text = $trValue . ' ' . $price; } } } $customfields[$selectList[$customfield->virtuemart_custom_id]]->display = JHtml::_($selectType, $customfields[$selectList[$customfield->virtuemart_custom_id]]->options, $customfields[$selectList[$customfield->virtuemart_custom_id]]->customProductDataName, $class, 'virtuemart_customfield_id', 'text', $default->customfield_value, $idTag); //*/ } else { if ($type == 'M') { $customfield->display = $this->displayCustomMedia($customfield->customfield_value, 'product', $customfield->width, $customfield->height); } else { $customfield->display = vmText::_($customfield->customfield_value); } } } break; case 'Z': if (empty($customfield->customfield_value)) { break; } $html = ''; $q = 'SELECT * FROM `#__virtuemart_categories_' . VmConfig::$vmlang . '` as l INNER JOIN `#__virtuemart_categories` AS c using (`virtuemart_category_id`) WHERE `published`=1 AND l.`virtuemart_category_id`= "' . (int) $customfield->customfield_value . '" '; $db = JFactory::getDBO(); $db->setQuery($q); if ($category = $db->loadObject()) { if (empty($category->virtuemart_category_id)) { break; } $q = 'SELECT `virtuemart_media_id` FROM `#__virtuemart_category_medias`WHERE `virtuemart_category_id`= "' . $category->virtuemart_category_id . '" '; $db->setQuery($q); $thumb = ''; if ($media_id = $db->loadResult()) { $thumb = $this->displayCustomMedia($media_id, 'category', $customfield->width, $customfield->height); } $customfield->display = JHtml::link(JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $category->virtuemart_category_id), $thumb . ' ' . $category->category_name, array('title' => $category->category_name, 'target' => '_blank')); } break; case 'R': if (empty($customfield->customfield_value)) { $customfield->display = 'customfield related product has no value'; break; } $pModel = VmModel::getModel('product'); $related = $pModel->getProduct((int) $customfield->customfield_value, TRUE, $customfield->wPrice, TRUE, 1); if (!$related) { break; } $thumb = ''; if ($customfield->wImage) { if (!empty($related->virtuemart_media_id[0])) { $thumb = $this->displayCustomMedia($related->virtuemart_media_id[0], 'product', $customfield->width, $customfield->height) . ' '; } else { $thumb = $this->displayCustomMedia(0, 'product', $customfield->width, $customfield->height) . ' '; } } $customfield->display = shopFunctionsF::renderVmSubLayout('related', array('customfield' => $customfield, 'related' => $related, 'thumb' => $thumb)); break; } } }
public function getSearchCustom() { $emptyOption = array('virtuemart_custom_id' => 0, 'custom_title' => vmText::_('COM_VIRTUEMART_LIST_EMPTY_OPTION')); $this->_db = JFactory::getDBO(); $this->_db->setQuery('SELECT `virtuemart_custom_id`, `custom_title` FROM `#__virtuemart_customs` WHERE `field_type` ="P"'); $this->options = $this->_db->loadAssocList(); $this->custom_parent_id = 0; if ($this->custom_parent_id = vRequest::getInt('custom_parent_id', 0)) { $this->_db->setQuery('SELECT `virtuemart_custom_id`, `custom_title` FROM `#__virtuemart_customs` WHERE custom_parent_id=' . $this->custom_parent_id); $this->selected = $this->_db->loadObjectList(); $this->searchCustomValues = ''; foreach ($this->selected as $selected) { $this->_db->setQuery('SELECT `custom_value` as virtuemart_custom_id,`custom_value` as custom_title FROM `#__virtuemart_product_customfields` WHERE virtuemart_custom_id=' . $selected->virtuemart_custom_id); $valueOptions = $this->_db->loadAssocList(); $valueOptions = array_merge(array($emptyOption), $valueOptions); $this->searchCustomValues .= vmText::_($selected->custom_title) . ' ' . JHtml::_('select.genericlist', $valueOptions, 'customfields[' . $selected->virtuemart_custom_id . ']', 'class="inputbox"', 'virtuemart_custom_id', 'custom_title', 0); } } // add search for declared plugins JPluginHelper::importPlugin('vmcustom'); $dispatcher = JDispatcher::getInstance(); $plgDisplay = $dispatcher->trigger('plgVmSelectSearchableCustom', array(&$this->options, &$this->searchCustomValues, $this->custom_parent_id)); if (!empty($this->options)) { $this->options = array_merge(array($emptyOption), $this->options); // render List of available groups vmJsApi::chosenDropDowns(); $this->searchCustomList = vmText::_('COM_VIRTUEMART_SET_PRODUCT_TYPE') . ' ' . JHtml::_('select.genericlist', $this->options, 'custom_parent_id', 'class="inputbox vm-chzn-select"', 'virtuemart_custom_id', 'custom_title', $this->custom_parent_id); } else { $this->searchCustomList = ''; } }
/** * * @author Patrick Kohl * @param array $options( value & text) * @param string $name option name * @param string $defaut defaut value * @param string $key option value * @param string $text option text * @param boolean $zero add a '0' value in the option * return a select list */ public static function select($name, $options, $default = '0', $attrib = "onchange='submit();'", $key = 'value', $text = 'text', $zero = true, $chosenDropDowns = true, $tranlsate = true) { if ($zero == true) { $option = array($key => "0", $text => vmText::_('COM_VIRTUEMART_LIST_EMPTY_OPTION')); $options = array_merge(array($option), $options); } if ($chosenDropDowns) { vmJsApi::chosenDropDowns(); $attrib .= ' class="vm-chzn-select"'; } return VmHtml::genericlist($options, $name, $attrib, $key, $text, $default, false, $tranlsate); }
function lVendor() { // If the current user is a vendor, load the store data if ($this->userDetails->user_is_vendor) { vmJsApi::addJScript('/administrator/components/com_virtuemart/assets/js/vm2admin.js', false, false); vmJsApi::addJScript('fancybox/jquery.mousewheel-3.0.4.pack'); vmJsApi::addJScript('fancybox/jquery.easing-1.3.pack'); vmJsApi::addJScript('fancybox/jquery.fancybox-1.3.4.pack'); vmJsApi::addJScript('jquery.ui.autocomplete.html'); vmJsApi::chosenDropDowns(); vmJsApi::jQueryUi(); $currencymodel = tmsModel::getModel('currency', 'VirtuemartModel'); $currencies = $currencymodel->getCurrencies(); $this->assignRef('currencies', $currencies); if (!$this->_orderList) { $this->lOrderlist(); } $vendorModel = tmsModel::getModel('vendor'); $vendorModel->setId($this->userDetails->virtuemart_vendor_id); $this->vendor = $vendorModel->getVendor(); $vendorModel->addImages($this->vendor); } }
/** * 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); }
/** * Collect all data to show on the template * * @author RolandD, Max Milbers */ function display($tpl = null) { //TODO get plugins running // $dispatcher = JDispatcher::getInstance(); // $limitstart = vRequest::getVar('limitstart', 0, '', 'int'); $show_prices = VmConfig::get('show_prices', 1); if ($show_prices == '1') { if (!class_exists('calculationHelper')) require(VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php'); vmJsApi::jPrice(); } $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 $mainframe = JFactory::getApplication(); $pathway = $mainframe->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'); //$product->customfields = $customfieldsModel->getCustomEmbeddedProductCustomFields ($product->allIds); 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 $mainframe->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)) { $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 = vRequest::getCmd('format', 'html'); } if ($format == 'html') { // Set Canonic link $document->addHeadLink($product->canonical, 'canonical', 'rel', ''); } else if($format == 'pdf'){ defined('K_PATH_IMAGES') or define ('K_PATH_IMAGES', VMPATH_ROOT); } $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)); } $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); } if ($this->showRating) { $vote = $ratingModel->getVoteByProduct($product->virtuemart_product_id); $this->assignRef('vote', $vote); //$rating = $ratingModel->getRatingByProduct($product->virtuemart_product_id); //$this->assignRef('rating', $rating); //vmdebug('Should show rating vote and rating',$vote,$rating); } $allowRating = $ratingModel->allowRating($product->virtuemart_product_id); $this->assignRef('allowRating', $allowRating); // Check for editing access // @todo build edit page $user = JFactory::getUser(); $superVendor = VmConfig::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; $edit_link = $this->linkIcon($edit_link, 'COM_VIRTUEMART_PRODUCT_FORM_EDIT_PRODUCT', 'edit', false, false); } else { $edit_link = ""; } $this->assignRef('edit_link', $edit_link); // 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); } else { $document->setDescription( $product->product_name . " " . $category->category_name . " " . $product->product_s_desc ); } 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); } $user = JFactory::getUser(); $showBasePrice = ($user->authorise('core.admin','com_virtuemart') or $user->authorise('core.manage','com_virtuemart') or VmConfig::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(); parent::display($tpl); }
/** * @author Max Milbers * @param $product * @param $customfield */ public function displayProductCustomfieldFE (&$product, &$customfields) { static $idUnique = array(); if (!class_exists ('calculationHelper')) { require(VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php'); } $calculator = calculationHelper::getInstance (); $selectList = array(); $dynChilds = 1; //= array(); $session = JFactory::getSession (); $virtuemart_category_id = $session->get ('vmlastvisitedcategoryid', 0, 'vm'); foreach($customfields as $k => &$customfield){ if(!isset($customfield->display))$customfield->display = ''; $calculator ->_product = $product; if (!class_exists ('vmCustomPlugin')) { require(VMPATH_PLUGINLIBS . DS . 'vmcustomplugin.php'); } if ($customfield->field_type == "E") { JPluginHelper::importPlugin ('vmcustom'); $dispatcher = JDispatcher::getInstance (); $ret = $dispatcher->trigger ('plgVmOnDisplayProductFEVM3', array(&$product, &$customfield)); continue; } $fieldname = 'field['.$product->virtuemart_product_id.'][' . $customfield->virtuemart_customfield_id . '][customfield_value]'; $customProductDataName = 'customProductData['.$product->virtuemart_product_id.']['.$customfield->virtuemart_custom_id.']'; //This is a kind of fallback, setting default of custom if there is no value of the productcustom $customfield->customfield_value = empty($customfield->customfield_value) ? $customfield->custom_value : $customfield->customfield_value; $type = $customfield->field_type; $idTag = (int)$product->virtuemart_product_id.'-'.$customfield->virtuemart_customfield_id; if(!isset($idUnique[$idTag])){ $idUnique[$idTag] = 0; } else { $counter = $idUnique[$idTag]++; $idTag = $idTag.'-'.$counter; } $idTag = $idTag . 'customProductData'; if (!class_exists ('CurrencyDisplay')) require(VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php'); $currency = CurrencyDisplay::getInstance (); switch ($type) { case 'C': $html = ''; $dropdowns = array(); if(isset($customfield->options->{$product->virtuemart_product_id})){ $productSelection = $customfield->options->{$product->virtuemart_product_id}; } else { $productSelection = false; } $ignore = array(); foreach($customfield->options as $product_id=>$variants){ if(in_array($product_id,$ignore)) continue; foreach($variants as $k => $variant){ if(!isset($dropdowns[$k]) or !is_array($dropdowns[$k])) $dropdowns[$k] = array(); if(!in_array($variant,$dropdowns[$k]) ){ if($k==0 or !$productSelection){ $dropdowns[$k][] = $variant; } else if($k>0 and $productSelection[$k-1] == $variants[$k-1]){ $dropdowns[$k][] = $variant; } else { $ignore[] = $product_id; } } } } //vmJsApi::chosenDropDowns(); foreach($customfield->selectoptions as $k => $soption){ $options = array(); $selected = 0; foreach($dropdowns[$k] as $i=> $elem){ $elem = trim((string)$elem); $options[] = array('value'=>$elem,'text'=>$elem); if($productSelection and $productSelection[$k] == $elem){ $selected = $elem; } } $idTag .= 'cvard'.$k; $soption->slabel = empty($soption->clabel)? vmText::_('COM_VIRTUEMART_'.strtoupper($soption->voption)): vmText::_($soption->clabel); $html .= JHtml::_ ('select.genericlist', $options, $fieldname, 'class="vm-chzn-select cvselection" data-dynamic-update="1" ', "value", "text", $selected,$idTag); } $Itemid = vRequest::getInt('Itemid',''); // '&Itemid=127'; if(!empty($Itemid)){ $Itemid = '&Itemid='.$Itemid; } //create array for js $jsArray = array(); $url = ''; foreach($customfield->options as $product_id=>$variants){ $url = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id=' . $virtuemart_category_id . '&virtuemart_product_id='.$product_id.$Itemid); $jsArray[] = '["'.$url.'","'.implode('","',$variants).'"]'; } //vmdebug('my urls of child variants',$jsArray); $jsVariants = implode(',',$jsArray); vmJsApi::addJScript('cvselection'," var cvselection = function($) { jQuery( function($) { $('.cvselection').change(function() { var variants = [".$jsVariants."]; var selection = []; $('.cvselection').each(function() { selection[selection.length] = $(this).val(); //console.log('My selection '+selection[selection.length-1]); }); var index ; var i2 ; var hitcount; var runs; for (runs = 0; runs < selection.length; index++) { for (index = 0; index < variants.length; index++) { hitcount = 0; for (i2 = 0; i2 < selection.length; i2++) { if(selection[i2]==variants[index][i2+1]){ hitcount++; console.log('Attribute hit selection '+i2+' '+selection[i2]+' '+variants[index][i2+1] ); if(hitcount == (selection.length-runs)){ console.log('redirect to '+variants[index][0]) //console.log('Set on selected option the attr url = '+variants[index][0]); jQuery(this).find(':selected').attr('url',variants[index][0]); jQuery(this).attr('url',variants[index][0]); i2 = selection.length+1; index = variants.length+1; runs = variants.length+1; break; } } else { break; } } } if(index>selection.length){ break; } runs++; //console.log('Could not find product for selection '); } }); }) }; cvselection(); jQuery('body').on('updateVirtueMartProductDetail', cvselection); "); //$html .= '<script type="text/javascript">'.$script.'</script>'; //Now we need just the JS to reload the correct product $customfield->display = $html; break; case 'A': $html = ''; //if($selectedFound) continue; $options = array(); $productModel = VmModel::getModel ('product'); //Note by Jeremy Magne (Daycounts) 2013-08-31 //Previously the the product model is loaded but we need to ensure the correct product id is set because the getUncategorizedChildren does not get the product id as parameter. //In case the product model was previously loaded, by a related product for example, this would generate wrong uncategorized children list $productModel->setId($customfield->virtuemart_product_id); $uncatChildren = $productModel->getUncategorizedChildren ($customfield->withParent); if(!$customfield->withParent or ($customfield->withParent and $customfield->parentOrderable)){ $options[0] = array('value' => JRoute::_ ('index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id=' . $virtuemart_category_id . '&virtuemart_product_id=' . $customfield->virtuemart_product_id,FALSE), 'text' => vmText::_ ('COM_VIRTUEMART_ADDTOCART_CHOOSE_VARIANT')); } $selected = vRequest::getInt ('virtuemart_product_id',0); $selectedFound = false; if (empty($calculator) and $customfield->wPrice) { if (!class_exists ('calculationHelper')) require(VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php'); $calculator = calculationHelper::getInstance (); } $parentStock = 0; foreach ($uncatChildren as $k => $child) { if(!isset($child[$customfield->customfield_value])){ vmdebug('The child has no value at index '.$customfield->customfield_value,$customfield,$child); } else { $productChild = $productModel->getProduct((int)$child['virtuemart_product_id'],false); if(!$productChild) continue; $available = $productChild->product_in_stock - $productChild->product_ordered; if(VmConfig::get('stockhandle','none')=='disableit_children' and $available <= 0){ continue; } $parentStock += $available; $priceStr = ''; if($customfield->wPrice){ //$product = $productModel->getProductSingle((int)$child['virtuemart_product_id'],false); $productPrices = $calculator->getProductPrices ($productChild); $priceStr = ' (' . $currency->priceDisplay ($productPrices['salesPrice']) . ')'; } $options[] = array('value' => JRoute::_ ('index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id=' . $virtuemart_category_id . '&virtuemart_product_id=' . $child['virtuemart_product_id']), 'text' => $child[$customfield->customfield_value].$priceStr); if($selected==$child['virtuemart_product_id']){ $selectedFound = true; vmdebug($customfield->virtuemart_product_id.' $selectedFound by vRequest '.$selected); } //vmdebug('$child productId ',$child['virtuemart_product_id'],$customfield->customfield_value,$child); } } if(!$selectedFound){ $pos = array_search($customfield->virtuemart_product_id, $product->allIds); if(isset($product->allIds[$pos-1])){ $selected = $product->allIds[$pos-1]; //vmdebug($customfield->virtuemart_product_id.' Set selected to - 1 allIds['.($pos-1).'] = '.$selected.' and count '.$dynChilds); //break; } elseif(isset($product->allIds[$pos])){ $selected = $product->allIds[$pos]; //vmdebug($customfield->virtuemart_product_id.' Set selected to allIds['.$pos.'] = '.$selected.' and count '.$dynChilds); } else { $selected = $customfield->virtuemart_product_id; //vmdebug($customfield->virtuemart_product_id.' Set selected to $customfield->virtuemart_product_id ',$selected,$product->allIds); } } $url = 'index.php?option=com_virtuemart&view=productdetails&virtuemart_category_id='. $virtuemart_category_id .'&virtuemart_product_id='. $selected; $html .= JHtml::_ ('select.genericlist', $options, $fieldname, 'onchange="window.top.location.href=this.options[this.selectedIndex].value" size="1" class="vm-chzn-select" data-dynamic-update="1" ', "value", "text", JRoute::_ ($url,false),$idTag); vmJsApi::chosenDropDowns(); if($customfield->parentOrderable==0){ if($product->product_parent_id==0){ $product->orderable = FALSE; } else { $product->product_in_stock = $parentStock; } } else { } $dynChilds++; $customfield->display = $html; break; /*Date variant*/ case 'D': if(empty($customfield->custom_value)) $customfield->custom_value = 'LC2'; //Customer selects date if($customfield->is_input){ $customfield->display = '<span class="product_custom_date">' . vmJsApi::jDate ($customfield->customfield_value,$customProductDataName) . '</span>'; //vmJsApi::jDate($field->custom_value, 'field['.$row.'][custom_value]','field_'.$row.'_customvalue').$priceInput; } //Customer just sees a date else { $customfield->display = '<span class="product_custom_date">' . vmJsApi::date ($customfield->customfield_value, $customfield->custom_value, TRUE) . '</span>'; } break; /* text area or editor No vmText, only displayed in BE */ case 'X': case 'Y': $customfield->display = $customfield->customfield_value; break; /* string or integer */ case 'B': case 'S': case 'M': if($type== 'M'){ $selectType = 'select.radiolist'; $class = ''; } else { $selectType = 'select.genericlist'; if(!empty($customfield->is_input)){ vmJsApi::chosenDropDowns(); $class = 'class="vm-chzn-select"'; } } if($customfield->is_list){ if(!empty($customfield->is_input)){ $options = array(); $values = explode (';', $customfield->custom_value); foreach ($values as $key => $val) { if($type == 'M'){ $options[] = array('value' => $val, 'text' => $this->displayCustomMedia ($val)); } else { $options[] = array('value' => $val, 'text' => vmText::_($val)); } } $currentValue = $customfield->customfield_value; $customfield->display = JHtml::_ ($selectType, $options, $customProductDataName.'[' . $customfield->virtuemart_customfield_id . ']', $class, 'value', 'text', $currentValue,$idTag); } else { if($type == 'M'){ $customfield->display = $this->displayCustomMedia ($customfield->customfield_value); } else { $customfield->display = vmText::_ ($customfield->customfield_value); } } } else { if(!empty($customfield->is_input)){ if(!isset($selectList[$customfield->virtuemart_custom_id])) { $tmpField = clone($customfield); $tmpField->options = null; $customfield->options[$customfield->virtuemart_customfield_id] = $tmpField; $selectList[$customfield->virtuemart_custom_id] = $k; $customfield->customProductDataName = $customProductDataName; } else { $customfields[$selectList[$customfield->virtuemart_custom_id]]->options[$customfield->virtuemart_customfield_id] = $customfield; unset($customfields[$k]); //$customfield->options[$customfield->virtuemart_customfield_id] = $customfield; } $default = reset($customfields[$selectList[$customfield->virtuemart_custom_id]]->options); foreach ($customfields[$selectList[$customfield->virtuemart_custom_id]]->options as &$productCustom) { $price = self::_getCustomPrice($productCustom->customfield_price, $currency, $calculator); if($type == 'M'){ $productCustom->text = $this->displayCustomMedia ($productCustom->customfield_value).' '.$price; } else { $trValue = vmText::_($productCustom->customfield_value); if($productCustom->customfield_value!=$trValue and strpos($trValue,'%1')!==false){ $productCustom->text = vmText::sprintf($productCustom->customfield_value,$price); } else { $productCustom->text = $trValue.' '.$price; } } } $customfields[$selectList[$customfield->virtuemart_custom_id]]->display = JHtml::_ ($selectType, $customfields[$selectList[$customfield->virtuemart_custom_id]]->options, $customfields[$selectList[$customfield->virtuemart_custom_id]]->customProductDataName, $class, 'virtuemart_customfield_id', 'text', $default->customfield_value,$idTag); //*/ } else { if($type == 'M'){ $customfield->display = $this->displayCustomMedia ($customfield->customfield_value); } else { $customfield->display = vmText::_ ($customfield->customfield_value); } } } break; case 'Z': if(empty($customfield->customfield_value)) break; $html = ''; $q = 'SELECT * FROM `#__virtuemart_categories_' . VmConfig::$vmlang . '` as l JOIN `#__virtuemart_categories` AS c using (`virtuemart_category_id`) WHERE `published`=1 AND l.`virtuemart_category_id`= "' . (int)$customfield->customfield_value . '" '; $db = JFactory::getDBO(); $db->setQuery ($q); if ($category = $db->loadObject ()) { if(empty($category->virtuemart_category_id)) break; $q = 'SELECT `virtuemart_media_id` FROM `#__virtuemart_category_medias`WHERE `virtuemart_category_id`= "' . $category->virtuemart_category_id . '" '; $db->setQuery ($q); $thumb = ''; if ($media_id = $db->loadResult ()) { $thumb = $this->displayCustomMedia ($media_id,'category'); } $customfield->display = JHtml::link (JRoute::_ ('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $category->virtuemart_category_id), $thumb . ' ' . $category->category_name, array('title' => $category->category_name,'target'=>'_blank')); } break; case 'R': if(empty($customfield->customfield_value)){ $customfield->display = 'customfield related product has no value'; break; } $pModel = VmModel::getModel('product'); $related = $pModel->getProduct((int)$customfield->customfield_value,TRUE,$customfield->wPrice,TRUE,1); if(!$related) break; $thumb = ''; if($customfield->wImage){ if (!empty($related->virtuemart_media_id[0])) { $thumb = $this->displayCustomMedia ($related->virtuemart_media_id[0]).' '; } else { $thumb = $this->displayCustomMedia (0).' '; } } $customfield->display = shopFunctionsF::renderVmSubLayout('related',array('customfield'=>$customfield,'related'=>$related, 'thumb'=>$thumb)); break; } } }
function lVendor() { // If the current user is a vendor, load the store data if ($this->userDetails->user_is_vendor) { $front = JURI::root(true) . '/components/com_virtuemart/assets/'; $admin = JURI::root(true) . '/administrator/components/com_virtuemart/assets/'; $document = JFactory::getDocument(); $document->addScript($front . 'js/fancybox/jquery.mousewheel-3.0.4.pack.js'); $document->addScript($front . 'js/fancybox/jquery.easing-1.3.pack.js'); $document->addScript($front . 'js/fancybox/jquery.fancybox-1.3.4.pack.js'); vmJsApi::chosenDropDowns(); /*vmJsApi::js ('jquery-ui', FALSE, '', TRUE); vmJsApi::js ('jquery.ui.autocomplete.html'); vmJsApi::js( 'jquery.noConflict'); $document->addScript($admin.'js/vm2admin.js');*/ $currencymodel = VmModel::getModel('currency', 'VirtuemartModel'); $currencies = $currencymodel->getCurrencies(); $this->assignRef('currencies', $currencies); if (!$this->_orderList) { $this->lOrderlist(); } $vendorModel = VmModel::getModel('vendor'); /*if (Vmconfig::get('multix', 'none') === 'none') { //$vendorModel->setId(1); } else {*/ $vendorModel->setId($this->userDetails->virtuemart_vendor_id); //} $this->vendor = $vendorModel->getVendor(); $vendorModel->addImages($this->vendor); } }
/** * * @author Patrick Kohl * @param array $options ( value & text) * @param string $name option name * @param string $defaut defaut value * @param string $key option value * @param string $text option text * @param boolean $zero add a '0' value in the option * return a select list */ public static function select_add_on($name, $options, $default = '0', $attrib = "onchange='submit();'", $key = 'value', $text = 'text', $iframe_link, $zero = true, $chosenDropDowns = true, $tranlsate = true) { $doc = JFactory::getDocument(); $doc->addScript(JUri::root() . '/administrator/components/com_tsmart/assets/js/controller/html_select_add_on.js'); $doc->addLessStyleSheet(JUri::root() . '/administrator/components/com_tsmart/assets/js/controller/html_select_add_on.less'); $input = JFactory::getApplication()->input; $reload_iframe_id = $input->get('iframe_id', '', 'string'); $reload_ui_dialog_id = $input->get('ui_dialog_id', '', 'string'); $remove_ui_dialog = $input->get('remove_ui_dialog', false, 'boolean'); if ($zero == true) { $option = array($key => "0", $text => tsmText::_('com_tsmart_LIST_EMPTY_OPTION')); $options = array_merge(array($option), $options); } if ($chosenDropDowns) { vmJsApi::chosenDropDowns(); $attrib .= ' class="vm-chzn-select"'; } $select = VmHtml::genericlist($options, $name, $attrib, $key, $text, $default, false, $tranlsate); $doc = JFactory::getDocument(); ob_start(); ?> <script type="text/javascript"> jQuery(document).ready(function ($) { $('#div_<?php echo $name; ?> ').html_select_add_on({ id_field_edit_content_wrapper: 'field_edit_content_wrapper_<?php echo $name; ?> ', iframe_link: '<?php echo $iframe_link; ?> ', link_reload: '<?php echo base64_encode(JUri::getInstance()->toString()); ?> ', ui_dialog_id: 'dialog_content_<?php echo $name; ?> ', iframe_id: 'iframe_<?php echo $name; ?> ', reload_iframe_id: '<?php echo $reload_iframe_id; ?> ', reload_ui_dialog_id: '<?php echo $reload_ui_dialog_id; ?> ', remove_ui_dialog: '<?php echo json_encode($remove_ui_dialog); ?> ' }); }); </script> <?php $script_content = ob_get_clean(); $script_content = TSMUtility::remove_string_javascript($script_content); $doc->addScriptDeclaration($script_content); ob_start(); ?> <div id="div_<?php echo $name; ?> " class="html_select_add_on"> <div class="input-append "> <div id="field_edit_content_wrapper_<?php echo $name; ?> " style="display: none"> <iframe id="vm-iframe_<?php echo $name; ?> " scrolling="no" src=""></iframe> </div> <?php echo $select; ?> <button class="btn edit_content btn_<?php echo $name; ?> " type="button"><span class="icon-plus"></span> </button> </div> </div> <?php $html = ob_get_clean(); return $html; }