echo $currency->createPriceDiv('salesPrice', JText::_("Price: "), $price, false, false, 1.0, true); } if (!empty($item->prices['salesPriceWithDiscount'])) { echo $currency->createPriceDiv('salesPriceWithDiscount', JText::_("Price: "), $price, false, false, 1.0, true); } echo '</div>'; echo '</div>'; } ?> <?php if ($params->get('item_addtocart_display', 1)) { $_item['product'] = $item; ?> <div class="item-addtocart"> <?php echo shopFunctionsF::renderVmSubLayout('addtocart', $_item); ?> </div> <?php } ?> <div class="content-date-read"> <?php if ((int) $params->get('item_description_display', 1) && VMListingTabsHelper::_trimEncode($item->_description) != '') { ?> <div class="item-desc"> <?php echo $item->_description; ?> </div> <?php
/** * Return an array with userFields in several formats. * * @access public * @param $_selection An array, as returned by getuserFields(), with fields that should be returned. * @param $_userData Array with userdata holding the values for the fields * @param $_prefix string Optional prefix for the formtag name attribute * @author Oscar van Eijk * @return array List with all userfield data in the format: * array( * 'fields' => array( // All fields * <fieldname> => array( * 'name' => // Name of the field * 'value' => // Existing value for the current user, or the default * 'title' => // Title used for label and such * 'type' => // Field type as specified in the userfields table * 'hidden' => // True/False * 'required' => // True/False. If True, the formcode also has the class "required" for the Joomla formvalidator * 'formcode' => // Full HTML tag * ) * [...] * ) * 'functions' => array() // Optional javascript functions without <script> tags. * // Possible usage: if (count($ar('functions')>0) echo '<script ...>'.join("\n", $ar('functions')).'</script>; * 'scripts' => array( // Array with scriptsources for use with JHtml::script(); * <name> => <path> * [...] * ) * 'links' => array( // Array with stylesheets for use with JHtml::stylesheet(); * <name> => <path> * [...] * ) * ) * @example This example illustrates the use of this function. For additional examples, see the Order view * and the User view in the administrator section. * <pre> * // In the controller, make sure this model is loaded. * // In view.html.php, make the following calls: * $_usrDetails = getUserDetailsFromSomeModel(); // retrieve an user_info record, eg from the usermodel or ordermodel * $_usrFieldList = $userFieldsModel->getUserFields( * 'registration' * , array() // Default switches * , array('delimiter_userinfo', 'username', 'email', 'password', 'password2', 'agreed', 'address_type') // Skips * ); * $usrFieldValues = $userFieldsModel->getUserFieldsFilled( * $_usrFieldList * ,$_usrDetails * ); * $this->assignRef('userfields', $userfields); * // In the template, use code below to display the data. For an extended example using * // delimiters, JavaScripts and StyleSheets, see the edit_shopper.php in the user view * <table class="admintable" width="100%"> * <thead> * <tr> * <td class="key" style="text-align: center;" colspan="2"> * <?php echo vmText::_('COM_VIRTUEMART_TABLE_HEADER') ?> * </td> * </tr> * </thead> * <?php * foreach ($this->shipmentfields['fields'] as $_field ) { * echo ' <tr>'."\n"; * echo ' <td class="key">'."\n"; * echo ' '.$_field['title']."\n"; * echo ' </td>'."\n"; * echo ' <td>'."\n"; * * echo ' '.$_field['value']."\n"; // Display only * Or: * echo ' '.$_field['formcode']."\n"; // Input form * * echo ' </td>'."\n"; * echo ' </tr>'."\n"; * } * ?> * </table> * </pre> */ public function getUserFieldsFilled($_selection, $_userData = null, $_prefix = ''){ //if(!class_exists('ShopFunctions')) require(VMPATH_ADMIN.DS.'helpers'.DS.'shopfunctions.php'); $_return = array( 'fields' => array() ,'functions' => array() ,'scripts' => array() ,'links' => array() ); $admin = false; $user = JFactory::getUser(); if($user->authorise('core.admin','com_virtuemart') or $user->authorise('core.manage','com_virtuemart')){ $admin = true; } // vmdebug('my user data in getUserFieldsFilled',$_selection,$_userData); $_userData=(array)($_userData); if (is_array($_selection)) { foreach ($_selection as $_fld) { $_return['fields'][$_fld->name] = array( 'name' => $_prefix . $_fld->name ,'value' => (($_userData == null || !array_key_exists($_fld->name, $_userData)) ? $_fld->default : $_userData[$_fld->name]) ,'title' => vmText::_($_fld->title) ,'type' => $_fld->type ,'required' => $_fld->required ,'hidden' => false ,'formcode' => '' ,'description' => vmText::_($_fld->description) ); $readonly = ''; if(!$admin){ if($_fld->readonly ){ $readonly = ' readonly="readonly" '; } } //vmdebug ('getUserFieldsFilled',$_fld->name,$_return['fields'][$_fld->name]['value']); // if($_fld->name==='email') vmdebug('user data email getuserfieldbyuser',$_userData); // First, see if there are predefined fields by checking the name switch( $_fld->name ) { // case 'email': // $_return['fields'][$_fld->name]['formcode'] = $_userData->email; // break; case 'virtuemart_country_id': if(!class_exists('shopFunctionsF'))require(VMPATH_SITE.DS.'helpers'.DS.'shopfunctionsf.php'); $attrib = array(); if ($_fld->size) { $attrib = array('style'=>"width: ".$_fld->size."px"); } $_return['fields'][$_fld->name]['formcode'] = ShopFunctionsF::renderCountryList($_return['fields'][$_fld->name]['value'], false, $attrib , $_prefix, $_fld->required); if(!empty($_return['fields'][$_fld->name]['value'])){ // Translate the value from ID to name $_return['fields'][$_fld->name]['virtuemart_country_id'] = (int)$_return['fields'][$_fld->name]['value']; $db = JFactory::getDBO (); $q = 'SELECT * FROM `#__virtuemart_countries` WHERE virtuemart_country_id = "' . (int)$_return['fields'][$_fld->name]['value'] . '"'; $db->setQuery ($q); $r = $db->loadAssoc(); if($r){ $_return['fields'][$_fld->name]['value'] = !empty($r['country_name'])? $r['country_name']:'' ; $_return['fields'][$_fld->name]['country_2_code'] = !empty($r['country_2_code'])? $r['country_2_code']:'' ; $_return['fields'][$_fld->name]['country_3_code'] = !empty($r['country_3_code'])? $r['country_3_code']:'' ; } else { vmError('Model Userfields, country with id '.$_return['fields'][$_fld->name]['value'].' not found'); } } else { $_return['fields'][$_fld->name]['value'] = '' ; $_return['fields'][$_fld->name]['country_2_code'] = '' ; $_return['fields'][$_fld->name]['country_3_code'] = '' ; } //$_return['fields'][$_fld->name]['value'] = vmText::_(shopFunctions::getCountryByID($_return['fields'][$_fld->name]['value'])); //$_return['fields'][$_fld->name]['state_2_code'] = vmText::_(shopFunctions::getCountryByID($_return['fields'][$_fld->name]['value'])); break; case 'virtuemart_state_id': if (!class_exists ('shopFunctionsF')) require(VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php'); $attrib = array(); if ($_fld->size) { $attrib = array('style'=>"width: ".$_fld->size."px"); } $_return['fields'][$_fld->name]['formcode'] = shopFunctionsF::renderStateList( $_return['fields'][$_fld->name]['value'], $_prefix, false, $_fld->required, $attrib ); if(!empty($_return['fields'][$_fld->name]['value'])){ // Translate the value from ID to name $_return['fields'][$_fld->name]['virtuemart_state_id'] = (int)$_return['fields'][$_fld->name]['value']; $db = JFactory::getDBO (); $q = 'SELECT * FROM `#__virtuemart_states` WHERE virtuemart_state_id = "' . (int)$_return['fields'][$_fld->name]['value'] . '"'; $db->setQuery ($q); $r = $db->loadAssoc(); if($r){ $_return['fields'][$_fld->name]['value'] = !empty($r['state_name'])? $r['state_name']:'' ; $_return['fields'][$_fld->name]['state_2_code'] = !empty($r['state_2_code'])? $r['state_2_code']:'' ; $_return['fields'][$_fld->name]['state_3_code'] = !empty($r['state_3_code'])? $r['state_3_code']:'' ; } else { vmError('Model Userfields, state with id '.$_return['fields'][$_fld->name]['value'].' not found'); } } else { $_return['fields'][$_fld->name]['value'] = '' ; $_return['fields'][$_fld->name]['state_2_code'] = '' ; $_return['fields'][$_fld->name]['state_3_code'] = '' ; } //$_return['fields'][$_fld->name]['value'] = shopFunctions::getStateByID($_return['fields'][$_fld->name]['value']); break; //case 'agreed': // $_return['fields'][$_fld->name]['formcode'] = '<input type="checkbox" id="'.$_prefix.'agreed_field" name="'.$_prefix.'agreed" value="1" ' // . ($_fld->required ? ' class="required"' : '') . ' />'; // break; case 'password': case 'password2': $_return['fields'][$_fld->name]['formcode'] = '<input type="password" id="' . $_prefix.$_fld->name . '_field" name="' . $_prefix.$_fld->name .'" '.($_fld->required ? ' class="required"' : ''). ' size="30" class="inputbox" />'."\n"; break; break; //case 'agreed': //case 'tos': break; // It's not a predefined field, so handle it by it's fieldtype default: if(strpos($_fld->type,'plugin')!==false){ JPluginHelper::importPlugin('vmuserfield'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('plgVmOnUserfieldDisplay',array($_prefix, $_fld,isset($_userData['virtuemart_user_id'])?$_userData['virtuemart_user_id']:0, &$_return) ); break; } switch( $_fld->type ) { case 'hidden': $_return['fields'][$_fld->name]['formcode'] = '<input type="hidden" id="' . $_prefix.$_fld->name . '_field" name="' . $_prefix.$_fld->name.'" size="' . $_fld->size . '" value="' . $_return['fields'][$_fld->name]['value'] .'" ' . ($_fld->required ? ' class="required"' : '') . ($_fld->maxlength ? ' maxlength="' . $_fld->maxlength . '"' : '') . $readonly . ' /> '; $_return['fields'][$_fld->name]['hidden'] = true; break; case 'date': case 'age_verification': //echo JHtml::_('behavior.calendar'); /* * TODO We must add the joomla.javascript here that contains the calendar, * since Joomla does not load it when there's no user logged in. * Gotta find out why... some security issue or a bug??? * Note by Oscar */ // if ($_userData === null) { // Not logged in // $_doc = JFactory::getDocument(); // $_doc->addScript( JURI::root(true).'/includes/js/joomla.javascript.js'); // } $currentYear= date('Y'); // $calendar = vmJsApi::jDate($_return['fields'][$_fld->name]['value'], $_prefix.$_fld->name, $_prefix.$_fld->name . '_field',false,($currentYear-100).':'.$currentYear); // $_return['fields'][$_fld->name]['formcode'] = $calendar ; //if(empty($_return['fields'][$_fld->name]['value'])){ // $_return['fields'][$_fld->name]['value'] = "1912-01-01 00:00:00"; //} jDate($date='',$name="date",$id=null,$resetBt = true, $yearRange='') { // Year range MUST start 100 years ago, for birthday $_return['fields'][$_fld->name]['formcode'] = vmJsApi::jDate($_return['fields'][$_fld->name]['value'], $_prefix.$_fld->name,$_prefix.$_fld->name . '_field',false,($currentYear-100).':'.$currentYear); break; case 'emailaddress': if( JFactory::getApplication()->isSite()) { if(empty($_return['fields'][$_fld->name]['value'])) { $_return['fields'][$_fld->name]['value'] = JFactory::getUser()->email; } } // vmdebug('emailaddress',$_fld); case 'text': case 'webaddress': $_return['fields'][$_fld->name]['formcode'] = '<input type="text" id="' . $_prefix.$_fld->name . '_field" name="' . $_prefix.$_fld->name.'" size="' . $_fld->size . '" value="' . $_return['fields'][$_fld->name]['value'] .'" ' . ($_fld->required ? ' class="required"' : '') . ($_fld->maxlength ? ' maxlength="' . $_fld->maxlength . '"' : '') . $readonly . ' /> '; break; case 'textarea': $_return['fields'][$_fld->name]['formcode'] = '<textarea id="' . $_prefix.$_fld->name . '_field" name="' . $_prefix.$_fld->name . '" cols="' . $_fld->cols . '" rows="'.$_fld->rows . '" class="inputbox" ' . $readonly.'>' . $_return['fields'][$_fld->name]['value'] .'</textarea>'; break; case 'editorta': jimport( 'joomla.html.editor' ); $editor = JFactory::getEditor(); $_return['fields'][$_fld->name]['formcode'] = $editor->display($_prefix.$_fld->name, $_return['fields'][$_fld->name]['value'], '150', '100', $_fld->cols, $_fld->rows, array('pagebreak', 'readmore')); break; case 'checkbox': $_return['fields'][$_fld->name]['formcode'] = '<input type="checkbox" name="' . $_prefix.$_fld->name . '" id="' . $_prefix.$_fld->name . '_field" value="1" ' . ($_return['fields'][$_fld->name]['value'] ? 'checked="checked"' : '') .'/>'; if($_return['fields'][$_fld->name]['value']) { $_return['fields'][$_fld->name]['value'] = vmText::_($_prefix.$_fld->title); } break; case 'custom': if(!class_exists('shopFunctionsF'))require(VMPATH_SITE.DS.'helpers'.DS.'shopfunctionsf.php'); $_return['fields'][$_fld->name]['formcode'] = shopFunctionsF::renderVmSubLayout($_fld->name,array('field'=>$_return['fields'][$_fld->name],'userData' => $_userData,'prefix' => $_prefix)); break; // /*##mygruz20120223193710 { :*/ // case 'userfieldplugin': //why not just vmuserfieldsplugin ? // JPluginHelper::importPlugin('vmuserfield'); // $dispatcher = JDispatcher::getInstance(); // //Todo to adjust to new pattern, using & // $html = '' ; // $dispatcher->trigger('plgVmOnUserFieldDisplay',array($_return['fields'][$_fld->name], &$html) ); // $_return['fields'][$_fld->name]['formcode'] = $html; // break; // /*##mygruz20120223193710 } */ case 'multicheckbox': case 'multiselect': case 'select': case 'radio': $_qry = 'SELECT fieldtitle, fieldvalue ' . 'FROM #__virtuemart_userfield_values ' . 'WHERE virtuemart_userfield_id = ' . $_fld->virtuemart_userfield_id . ' ORDER BY ordering '; $_values = $this->_getList($_qry); // We need an extra lok here, especially for the Bank info; the values // must be translated. // Don't check on the field name though, since others might be added in the future :-( foreach ($_values as $_v) { $_v->fieldtitle = vmText::_($_v->fieldtitle); } $_attribs = array(); if ($_fld->readonly and !$admin) { $_attribs['readonly'] = 'readonly'; } if ($_fld->required) { $_attribs['class'] = 'required'; } if ($_fld->type == 'radio' or $_fld->type == 'select') { $_selected = $_return['fields'][$_fld->name]['value']; } else { $_attribs['size'] = $_fld->size; // Use for all but radioselects if (!is_array($_return['fields'][$_fld->name]['value'])){ $_selected = explode("|*|", $_return['fields'][$_fld->name]['value']); } else { $_selected = $_return['fields'][$_fld->name]['value']; } } // Nested switch... switch($_fld->type) { case 'multicheckbox': // todo: use those $_attribs['rows'] = $_fld->rows; $_attribs['cols'] = $_fld->cols; $formcode = ''; $field_values=""; $_idx = 0; $separator_form = '<br />'; $separator_title = ','; foreach ($_values as $_val) { if ( in_array($_val->fieldvalue, $_selected)) { $is_selected='checked="checked"'; $field_values.= vmText::_($_val->fieldtitle). $separator_title; } else { $is_selected=''; } $formcode .= '<input type="checkbox" name="' . $_prefix.$_fld->name . '[]" id="' . $_prefix.$_fld->name . '_field' . $_idx . '" value="'. $_val->fieldvalue . '" ' . $is_selected .'/> <label for="' . $_prefix.$_fld->name . '_field' . $_idx . '">'.vmText::_($_val->fieldtitle) .'</label>'. $separator_form; $_idx++; } // remove last br $_return['fields'][$_fld->name]['formcode'] =substr($formcode ,0,-strlen($separator_form)); $_return['fields'][$_fld->name]['value'] = substr($field_values,0,-strlen($separator_title)); break; case 'multiselect': $_attribs['multiple'] = 'multiple'; $_attribs['class'] = 'vm-chzn-select'; $field_values=""; $_return['fields'][$_fld->name]['formcode'] = JHtml::_('select.genericlist', $_values, $_prefix.$_fld->name.'[]', $_attribs, 'fieldvalue', 'fieldtitle', $_selected); $separator_form = '<br />'; $separator_title = ','; foreach ($_values as $_val) { if ( in_array($_val->fieldvalue, $_selected)) { $field_values.= vmText::_($_val->fieldtitle). $separator_title; } } $_return['fields'][$_fld->name]['value'] = substr($field_values,0,-strlen($separator_title)); break; case 'select': $_attribs['class'] = 'vm-chzn-select'; if ($_fld->size) { $_attribs['style']= "width: ".$_fld->size."px"; } if(!$_fld->required){ $obj = new stdClass(); $obj->fieldtitle = vmText::_('COM_VIRTUEMART_LIST_EMPTY_OPTION'); $obj->fieldvalue = ''; array_unshift($_values,$obj); } $_return['fields'][$_fld->name]['formcode'] = JHTML::_('select.genericlist', $_values, $_prefix.$_fld->name, $_attribs, 'fieldvalue', 'fieldtitle', $_selected); if ( !empty($_selected)){ foreach ($_values as $_val) { if ( $_val->fieldvalue==$_selected ) { // vmdebug('getUserFieldsFilled set empty select to value',$_selected,$_fld,$_return['fields'][$_fld->name]); $_return['fields'][$_fld->name]['value'] = vmText::_($_val->fieldtitle); } } } break; case 'radio': $_return['fields'][$_fld->name]['formcode'] = JHtml::_('select.radiolist', $_values, $_prefix.$_fld->name, $_attribs, 'fieldvalue', 'fieldtitle', $_selected); if ( !empty($_selected)){ foreach ($_values as $_val) { if ( $_val->fieldvalue==$_selected) { $_return['fields'][$_fld->name]['value'] = vmText::_($_val->fieldtitle); } } } break; } break; } break; } } } else { vmdebug('getUserFieldsFilled $_selection is not an array ',$_selection); // $_return['fields'][$_fld->name]['formcode'] = ''; } return $_return; }
</div> <div class="clear"></div> </div> <!-- end of orderby-displaynumber --> <!--<h1><?php //echo $this->category->category_name; ?> </h1>--> <?php if (!empty($this->products)) { $products = array(); $products[0] = $this->products; echo shopFunctionsF::renderVmSubLayout($this->productsLayout, array('products' => $products, 'currency' => $this->currency, 'products_per_row' => $this->perRow, 'showRating' => $this->showRating)); ?> <div class="orderby-displaynumber bottom"> <div class="vm-view-list col-md-2 col-sm-3 col-xs-12"> <div class="icon-list-grid"> <div class="vm-view vm-grid active" data-view="vm-grid"><i class="listing-icon"></i></div> <div class="vm-view vm-list" data-view="vm-list"><i class="listing-icon"></i></div> </div> </div> <div class="toolbar-center col-md-6 col-sm-5 col-xs-12"> <div class="vm-order-list"> <?php echo $this->orderByList['orderby']; ?>
/** * @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; } } }
} ?> </p> <?php } ?> <div class="clearfix"></div> </div> <?php //echo $rowsHeight[$row]['customs'] ?> <div class="vm-product-addcart vm3pr-<?php echo $rowsHeight[$row]['customfields']; ?> "> <?php echo shopFunctionsF::renderVmSubLayout('addtocart', array('product' => $product, 'rowHeights' => $rowsHeight[$row])); ?> </div> <div class="vm-details-button"> <?php // Product Details Button $link = empty($product->link) ? $product->canonical : $product->link; echo JHtml::link($link . $ItemidStr, vmText::_('COM_VIRTUEMART_PRODUCT_DETAILS'), array('title' => $product->product_name, 'class' => 'product-details')); //echo JHtml::link ( JRoute::_ ( 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $product->virtuemart_product_id . '&virtuemart_category_id=' . $product->virtuemart_category_id , FALSE), vmText::_ ( 'COM_VIRTUEMART_PRODUCT_DETAILS' ), array ('title' => $product->product_name, 'class' => 'product-details' ) ); ?> </div> </div> </div> </div>
/** * @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; } } }
</h2> <div class="vm-product-rating-container"> <?php echo shopFunctionsF::renderVmSubLayout('rating', array('showRating' => $showRating, 'product' => $product)); ?> </div> </div> <div class="align-right"> <?php //echo $rowsHeight[$row]['price'] ?> <div class="vm3pr-<?php echo $rowsHeight[$row]['price']; ?> "> <?php echo shopFunctionsF::renderVmSubLayout('prices', array('product' => $product, 'currency' => $currency)); ?> </div> </div> <div class="clearbreak"></div> </div> <div class="vm-product-descr-container-<?php echo $rowsHeight[$row]['product_s_desc']; ?> "> <?php if (!empty($rowsHeight[$row]['product_s_desc'])) { ?> <!--p class="product_s_desc"> <?php
echo shopFunctionsF::limitStringByWord($product->product_s_desc, 40, '...'); ?> </p> <?php } ?> <div class="vm3pr-<?php echo $rowsHeight[$row]['price']; ?> "> <?php echo shopFunctionsF::renderVmSubLayout('prices', array('product' => $product, 'currency' => $currency)); ?> </div> <?php echo shopFunctionsF::renderVmSubLayout('addtocart', array('product' => $product, 'row' => 0)); ?> <div class="vm-details-button"> <?php // Product Details Button echo JHtml::link(JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $product->virtuemart_product_id . '&virtuemart_category_id=' . $product->virtuemart_category_id, FALSE), vmText::_('COM_VIRTUEMART_PRODUCT_DETAILS'), array('title' => $product->product_name, 'class' => 'product-details')); ?> </div> </div> </div> <?php $nb++; // Do we need to close the current row now? if ($col == $products_per_row || $nb > $BrowseTotalProducts) {
$("form.js-recalculate").each(function(){ if ($(this).find(".product-fields").length && !$(this).find(".no-vm-bind").length) { var id= $(this).find(\'input[name="virtuemart_product_id[]"]\').val(); Virtuemart.setproducttype($(this),id); } }); });'; //vmJsApi::addJScript('recalcReady',$j); /** GALT * Notice for Template Developers! * Templates must set a Virtuemart.container variable as it takes part in * dynamic content update. * This variable points to a topmost element that holds other content. */ $j = "Virtuemart.container = jQuery('.productdetails-view');\nVirtuemart.containerSelector = '.productdetails-view';"; vmJsApi::addJScript('ajaxContent', $j); if (VmConfig::get('jdynupdate', TRUE)) { $j = "jQuery(document).ready(function(\$) {\n\tVirtuemart.stopVmLoading();\n\tvar msg = '';\n\tjQuery('a[data-dynamic-update=\"1\"]').off('click', Virtuemart.startVmLoading).on('click', {msg:msg}, Virtuemart.startVmLoading);\n\tjQuery('[data-dynamic-update=\"1\"]').off('change', Virtuemart.startVmLoading).on('change', {msg:msg}, Virtuemart.startVmLoading);\n});"; vmJsApi::addJScript('vmPreloader', $j); } echo vmJsApi::writeJS(); if ($this->product->prices['salesPrice'] > 0) { echo shopFunctionsF::renderVmSubLayout('snippets', array('product' => $this->product, 'currency' => $this->currency, 'showRating' => $this->showRating)); } ?> </div>
<div class="vm3pr-<?php echo $rowsHeight[$row]['price']; ?> "> <?php echo shopFunctionsF::renderVmSubLayout('prices', array('product' => $product, 'currency' => $currency)); ?> <div class="clear"></div> </div> <?php //echo $rowsHeight[$row]['customs'] ?> <div class="vm3pr-<?php echo $rowsHeight[$row]['customfields']; ?> "> <?php echo shopFunctionsF::renderVmSubLayout('addtocart', array('product' => $product, 'rowHeights' => $rowsHeight[$row], 'position' => array('ontop', 'addtocart'))); ?> </div> <div class="vm-details-button"> <?php // Product Details Button $link = empty($product->link) ? $product->canonical : $product->link; echo JHtml::link($link . $ItemidStr, vmText::_('COM_VIRTUEMART_PRODUCT_DETAILS'), array('title' => $product->product_name, 'class' => 'product-details')); //echo JHtml::link ( JRoute::_ ( 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $product->virtuemart_product_id . '&virtuemart_category_id=' . $product->virtuemart_category_id , FALSE), vmText::_ ( 'COM_VIRTUEMART_PRODUCT_DETAILS' ), array ('title' => $product->product_name, 'class' => 'product-details' ) ); ?> </div> </div> </div>
if ($this->product->product_box) { ?> <div class="product-box"> <?php echo vmText::_('COM_VIRTUEMART_PRODUCT_UNITS_IN_BOX') . $this->product->product_box; ?> </div> <?php } // Product Packaging END ?> <?php echo shopFunctionsF::renderVmSubLayout('customfields', array('product' => $this->product, 'position' => 'onbot')); echo shopFunctionsF::renderVmSubLayout('customfields', array('product' => $this->product, 'position' => 'related_products', 'class' => 'product-related-products', 'customTitle' => true)); echo shopFunctionsF::renderVmSubLayout('customfields', array('product' => $this->product, 'position' => 'related_categories', 'class' => 'product-related-categories')); ?> </div> <script> // GALT /* * Notice for Template Developers! * Templates must set a Virtuemart.container variable as it takes part in * dynamic content update. * This variable points to a topmost element that holds other content. */ // If this <script> block goes right after the element itself there is no // need in ready() handler, which is much better. //jQuery(document).ready(function() { Virtuemart.container = jQuery('.productdetails-view');
} else { $step = 1; } if ($step == 0) { $step = 1; } ?> <div class="addtocart-area"> <form method="post" class="product js-recalculate" role="form" action="<?php echo JRoute::_('index.php?option=com_virtuemart', false); ?> "> <?php if (!empty($rowHeights['customfields'])) { echo shopFunctionsF::renderVmSubLayout('customfields', array('product' => $product, 'position' => 'addtocart')); } if (!VmConfig::get('use_as_catalog', 0)) { ?> <div class="addtocart-bar"> <?php // Display the quantity box $stockhandle = VmConfig::get('stockhandle', 'none'); if (($stockhandle == 'disableit' or $stockhandle == 'disableadd') and $product->product_in_stock - $product->product_ordered < 1) { ?> <a href="<?php echo JRoute::_('index.php?option=com_virtuemart&view=productdetails&layout=notify&virtuemart_product_id=' . $product->virtuemart_product_id); ?> " class="notify"><?php echo vmText::_('COM_VIRTUEMART_CART_NOTIFY');
<div class="prod-details fixclear"> <h3><?php echo JHtml::link($link . $itemid, $product->product_name); ?> </h3> <p class="desc"><?php echo JHtmlString::truncate($product->product_desc, 80, true, false); ?> </p> <?php echo shopFunctionsF::renderVmSubLayout('kl_prices_basic', array('product' => $product, 'currency' => $currency)); ?> <div class="kl-extra-info"> <?php echo shopFunctionsF::renderVmSubLayout('kl_rating', array('showRating' => $showRating, 'product' => $product)); ?> </div> </div><!-- /.prod-details --> <div class="prod-actions"> <?php // More info button echo JHtml::link($link . $itemid, vmText::_('COM_VIRTUEMART_PRODUCT_DETAILS'), array('title' => $product->product_name, 'class' => 'product-details')); // Add to cart button // echo shopFunctionsF::renderVmSubLayout('kl_addtocart',array('product'=>$product)); if ($show_addtocart) { echo mod_virtuemart_product_hgcarousel::addtocart($product, $params); } ?> </div><!-- /.actions -->
<?php if ((int) $params->get('item_price_display', 1)) { ?> <div class="item-price"> <?php if (!empty($item->prices['salesPrice'])) { echo $currency->createPriceDiv('salesPrice', JText::_("Price: "), $item->prices, false, false, 1.0, true); } if (!empty($item->prices['salesPriceWithDiscount'])) { $currency = CurrencyDisplay::getInstance(); echo $currency->createPriceDiv('salesPriceWithDiscount', JText::_("Price: "), $item->prices, false, false, 1.0, true); } ?> </div> <?php } ?> <?php if ($params->get('item_addtocart_display', 1)) { ?> <div class="item-addtocart"> <?php echo shopFunctionsF::renderVmSubLayout('addtocart', array('product' => $item)); ?> </div> <?php } ?> </div> </div>
} } $position = 'addtocart'; ?> <div class="addtocart-area"> <form method="post" class="product js-recalculate" action="<?php echo JRoute::_('index.php?option=com_virtuemart', false); ?> "> <?php if (!empty($rowHeights['customfields'])) { echo shopFunctionsF::renderVmSubLayout('customfields', array('product' => $product, 'position' => 'addtocart')); } if (!VmConfig::get('use_as_catalog', 0)) { echo shopFunctionsF::renderVmSubLayout('addtocartbar', array('product' => $product)); } ?> <input type="hidden" name="option" value="com_virtuemart"/> <input type="hidden" name="view" value="cart"/> <input type="hidden" name="virtuemart_product_id[]" value="<?php echo $product->virtuemart_product_id; ?> "/> <input type="hidden" class="pname" value="<?php echo $product->product_name; ?> "/> <?php $itemId = vRequest::getInt('Itemid', false); if ($itemId) {
"/> <input type="hidden" class="pname" value="<?php echo $product->product_name; ?> "/> <?php $itemId = vRequest::getInt('Itemid', false); if ($itemId) { echo '<input type="hidden" name="Itemid" value="' . $itemId . '"/>'; } ?> </form> </div> </div> <?php echo shopFunctionsF::renderVmSubLayout('stockhandle', array('product' => $this->product)); ?> <?php if (VmConfig::get('display_stock', 1) || $this->product->product_box) { ?> <ul class="productDetailInfo"> <?php if (VmConfig::get('display_stock', 1)) { ?> <li> <b><?php echo JText::_('COM_VIRTUEMART_STOCK_LEVEL_DISPLAY_TITLE_TIP'); ?> :</b> <?php echo $this->product->product_in_stock; ?> </li>
static function addtocart($product) { echo shopFunctionsF::renderVmSubLayout('addtocart', array('product' => $product)); }
$position = 'addtocart'; //if (!empty($product->customfieldsSorted[$position]) or !empty($addtoCartButton)) { if (isset($product->step_order_level)) $step=$product->step_order_level; else $step=1; if($step==0) $step=1; ?> <div class="addtocart-area"> <form method="post" class="product js-recalculate" action="<?php echo JRoute::_ ('index.php?option=com_virtuemart',false); ?>"> <?php if(!empty($rowHeights['customfields'])) echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$product,'position'=>'addtocart')); if (!VmConfig::get('use_as_catalog', 0) ) { ?> <div class="addtocart-bar"> <?php // Display the quantity box $stockhandle = VmConfig::get ('stockhandle', 'none'); if (($stockhandle == 'disableit' or $stockhandle == 'disableadd') and ($product->product_in_stock - $product->product_ordered) < 1) { ?> <a href="<?php echo JRoute::_ ('index.php?option=com_virtuemart&view=productdetails&layout=notify&virtuemart_product_id=' . $product->virtuemart_product_id); ?>" class="notify"><?php echo vmText::_ ('COM_VIRTUEMART_CART_NOTIFY') ?></a><?php } else { $tmpPrice = (float) $product->prices['costPrice']; if (!( VmConfig::get('askprice', true) and empty($tmpPrice) ) ) { ?> <?php if ($product->orderable) { ?> <!-- <label for="quantity<?php echo $product->virtuemart_product_id; ?>" class="quantity_box"><?php echo vmText::_ ('COM_VIRTUEMART_CART_QUANTITY'); ?>: </label> --> <span class="quantity-box">