element->characteristics)) return; ?>
params->get('characteristic_display') != 'list') { $app = JFactory::getApplication(); $config = hikashop_config(); $characteristics_dynamic_display = $config->get('characteristics_dynamic_display', 1); $this->characteristics=&$this->element->main->characteristics; foreach($this->characteristics as $k => $characteristic) { if(empty($this->characteristics[$k]->characteristic_display_method)) { $this->characteristics[$k]->characteristic_display_method = $this->params->get('characteristic_display'); } } $chromePath = JPATH_THEMES . DS . $app->getTemplate() . DS . 'html' . DS . 'hikashop_characteristics.php'; if(file_exists($chromePath)) { require_once ($chromePath); if(function_exists('hikashop_characteristics_html')) { echo hikashop_characteristics_html($this->element, $params, $this); echo '
'; return; } } $html = ''; $js = ''; $ids = array_keys($this->characteristics); $list = '[\''.implode('\',\'',$ids).'\']'; switch($this->params->get('characteristic_display')){ case 'table': if(count($this->characteristics) == 2) { $html = ''; $firstCharacteristic = reset($this->characteristics); $secondCharacteristic = end($this->characteristics); $html.= ''; if(!empty($secondCharacteristic->values)){ foreach($secondCharacteristic->values as $value){ $html.=''; } } $html.=''; $this->options=' onclick="return hikashopUpdateVariantData(this.value);"'; $size=0; if(!empty($firstCharacteristic->values)){ foreach($firstCharacteristic->values as $value){ $html .= ''; if(strlen($value->characteristic_value)>$size) $size=strlen($value->characteristic_value); if(!empty($secondCharacteristic->values)) { foreach($secondCharacteristic->values as $value2) { $class = ''; $classspan = ''; $extra = ''; foreach($this->element->variants as $k => $variant) { $char1 = false; $char2 = false; foreach($variant->characteristics as $variantCharacteristic) { if($variantCharacteristic->characteristic_id == $value->characteristic_id) { $char1 = true; } elseif($variantCharacteristic->characteristic_id == $value2->characteristic_id) { $char2 = true; } if($char1 && $char2) { if(!$variant->product_published || $variant->product_quantity == 0) { $class = ' hikashop_product_variant_out_of_stock'; $classspan=' hikashop_product_variant_out_of_stock_span'; }else { $extra = ' data-stock="'.(int)$variant->product_quantity.'"'; } break 2; } } } $name = '_'.$value->characteristic_id.'_'.$value2->characteristic_id; $radio = "\n\toptions; if($this->characteristics[$value->characteristic_parent_id]->default->characteristic_id == $value->characteristic_id && !empty($this->characteristics[$value2->characteristic_parent_id]->default->characteristic_id) && $this->characteristics[$value2->characteristic_parent_id]->default->characteristic_id == $value2->characteristic_id) { $radio .= ' checked'; } $radio .= " />"; $html .= ''; } } $html .= ''; } } $html .= '
'.hikashop_translate($value->characteristic_value).'
'.hikashop_translate($value->characteristic_value).''.$radio.'
'; if($this->params->get('characteristic_display_text')) { $space = ''; for($i = 0; $i <= $size; $i++) { $space .= '  '; } $html = '
'.$space.@$secondCharacteristic->characteristic_value.'
'.$firstCharacteristic->characteristic_value.''.$html.'
'; } break; } default: case 'radio': case 'dropdown': $main_html = ''; $config = hikashop_config(); $count = count($this->characteristics); $i = 0; foreach($this->characteristics as $characteristic) { $i++; $main_html.=''; $values = array(); $switch_done = false; if(!empty($characteristic->values)) { foreach($characteristic->values as $k => $value){ if(!$config->get('show_out_of_stock',1)){ $hasQuantity = false; foreach($this->element->variants as $variant){ foreach($variant->characteristics as $variantCharacteristic){ if($variantCharacteristic->characteristic_id==$value->characteristic_id){ if($variant->product_quantity != 0){ $hasQuantity = true; }elseif( $this->element->product_id==$variant->product_id && !$switch_done){ if($characteristic->characteristic_display_method == 'dropdown'){ $id = 'hikashop_product_characteristic_'.$characteristic->characteristic_id; $js = "hikashopUpdateVariant(document.getElementById('".$id."'));"; }else{ $id = 'hikashop_product_characteristic['.$characteristic->characteristic_id.']'; $js = "var el = document.querySelector('[name=\"".$id."\"]'); if(el) el.checked = true; hikashopUpdateVariant(el);"; } $js = " window.hikashop.ready( function() {".$js."});"; $switch_done = true; } } } } if(!$hasQuantity) continue; } $values[$k] = $value->characteristic_value; } } if(empty($values) || !is_array($values)){ echo JText::_('NO_VALUES_FOUND'); echo ''; return; } if(is_array($this->characteristics)){ $characteristic_id = @$characteristic->characteristic_id; @$characteristic->characteristic_id = 'hikashop_product_characteristic['.$characteristic_id.']'; $id = 'hikashop_product_characteristic_'.$characteristic_id; }else{ $id = $characteristic_id = $map; } $selected = (int)@$characteristic->default->characteristic_id; $this->values = array(); if(($characteristics_dynamic_display && $count > 1) || $characteristics_dynamic_display > 1) { if($characteristic->characteristic_display_method!='radio') $this->values[] = JHTML::_('select.option', '', JText::_('PLEASE_SELECT') ); $selected = ''; } foreach($values as $key => $val){ if(strlen($val)!=0 && empty($val)){ $val = $val.' '; } if(strpos($val, 'characteristic_display_method != 'radio' && !empty($clean) ? $clean : $val); $obj = new stdClass; $obj->value = $key; $obj->text = $optionValue; $obj->id = 'hikashop_product_characteristic_'.$characteristic_id.'_'.$key; $this->values[] = $obj; } $type = 'onclick'; if($characteristic->characteristic_display_method!='radio'){ $characteristic->characteristic_display_method='generic'; $type = 'onchange'; } $options = ' '.$type.'="return hikashopVariantSelected(this);"'; $options .=' data-characteristic="'.$i.'"'; if($count == $i) $options .=' data-last="1"'; $html = JHTML::_('select.'.$characteristic->characteristic_display_method.'list', $this->values, @$characteristic->characteristic_id, 'class="custom-select" size="1"' . $options, 'value', 'text', $selected, $id ); if($this->params->get('characteristic_display_text') && isset($characteristic->characteristic_value)) { $html = hikashop_translate($characteristic->characteristic_value).''; } $main_html .= '
'.$html; } $main_html .= ''.$html.'
'; $html = $main_html; if($characteristics_dynamic_display) { $matches = $this->getAllValuesMatches($this->characteristics, $this->element->variants, $this->element->main); $js.="\r\n".'window.hikashop.availableValues = ['; if($matches) { foreach($matches as $value_id => $children) { $js.="\r\n\t"."[".implode(',',$children)."],"; } } $js.="\r\n".'];'; } break; } echo $html; ?> element->main->characteristics)) { $columns=0; if((int)$this->config->get('show_quantity_field') >= 2) { ?>
config->get('thumbnail') && @$this->displayVariants['images']) { $columns++; ?> displayVariants['variant_name']) { $columns++; ?> config->get('show_code')) { $columns++; ?> element->main->characteristics as $characteristic) { $columns++; ?> displayVariants['product_description']) { $columns++; ?> params->get('show_price','-1') == '-1') { $this->params->set('show_price', $this->config->get('show_price')); } if($this->params->get('show_price') && @$this->displayVariants['prices']) { $columns++; ?> params->get('catalogue')){ $columns++; ?> generateVariantData($this->element); foreach($this->element->variants as $variant) { if(isset($variant->map)) continue; if(!$this->config->get('show_out_of_stock', 1) && $variant->product_quantity == 0) continue; if(!$variant->product_published) continue; $this->row =& $variant; ?> config->get('thumbnail') && @$this->displayVariants['images']){ ?> displayVariants['variant_name']){ ?> config->get('show_code')) { ?> element->main->characteristics as $characteristic) { ?> displayVariants['product_description']) { ?> params->get('show_price') && @$this->displayVariants['prices']){ ?> params->get('catalogue')) { ?>
characteristic_value); ?>
images)) { $image = reset($variant->images); $width = $this->config->get('thumbnail_x'); $height = $this->config->get('thumbnail_y'); $this->image->checkSize($width,$height,$image); foreach($variant->images as $image) { ?>
image->display($image->file_path, true, $image->file_name, 'style="margin-top:10px;margin-bottom:10px;display:inline-block;vertical-align:middle"', '', $width, $height); ?>
variant_name; ?> product_code; ?> values)) { foreach($characteristic->values as $k => $value) { foreach($variant->characteristics as $variantCharacteristic) { if($variantCharacteristic->characteristic_id == $value->characteristic_id) { echo hikashop_translate($variantCharacteristic->characteristic_value); break 2; } } } } ?> #i', '', $variant->product_description)); ?> row->product_msrp) == ($this->element->main->product_msrp) ) $this->params->set('from_module',1); $this->setLayout('listing_price'); echo $this->loadTemplate(); $this->params->set('from_module',0); ?> config->get('show_quantity_field') < 2) { $this->params->set('main_div_name','variants'); $this->params->set('extra_div_name','hikashop_product_form'); $this->setLayout('add_to_cart_ajax'); echo $this->loadTemplate(); $this->params->set('extra_div_name',''); } else { $start_date = (@$this->row->product_sale_start || empty($this->element->main)) ? @$this->row->product_sale_start : $this->element->main->product_sale_start; $end_date = (@$this->row->product_sale_end || empty($this->element->main)) ? @$this->row->product_sale_end : $this->element->main->product_sale_end; $now = time(); if($end_date > 0 && $end_date < $now) { ?> 0 && $start_date > $now) { ?> params->get('date_format', '%d %B %Y'))); ?> row->product_quantity > 0) echo (($this->row->product_quantity == 1 && JText::_('X_ITEM_IN_STOCK') != 'X_ITEM_IN_STOCK') ? JText::sprintf('X_ITEM_IN_STOCK', $this->row->product_quantity) : JText::sprintf('X_ITEMS_IN_STOCK', $this->row->product_quantity)); elseif($this->row->product_quantity == 0) echo JText::_('NO_STOCK'); ?> row->product_quantity == -1 || $this->row->product_quantity > 0) { $quantityLayout = $this->quantityLayout; if(!empty($this->row->product_quantity_layout) && $this->row->product_quantity_layout != 'inherit') $quantityLayout = $this->row->product_quantity_layout; if(empty($quantityLayout) || !in_array($quantityLayout, array( 'show_select', 'show_select_price'))) { ?> row->product_min_per_order || empty($this->element->main)) ? $this->row->product_min_per_order : $this->element->main->product_min_per_order; $max_quantity = ($this->row->product_max_per_order || empty($this->element->main)) ? $this->row->product_max_per_order : $this->element->main->product_max_per_order; $min_quantity = max((int)$min_quantity, 1); $max_quantity = max((int)$max_quantity, 0); if($max_quantity == 0) $max_quantity = $min_quantity * $this->config->get('quantity_select_max_default_value', 15); $values = array(); if($quantityLayout == 'show_select' || empty($this->row->prices)) { $values = range($min_quantity, $max_quantity, $min_quantity); } else { foreach($this->row->prices as $price) { $price_min_qty = max((int)$price->price_min_quantity, $min_quantity); $values[$price_min_qty] = $price_min_qty; } } ?>
config->get('show_quantity_field') >= 2) { $this->ajax = 'if(hikashopCheckChangeForm(\'item\',\'hikashop_product_form_variants\')){ return hikashopModifyQuantity(\'\',field,1,\'hikashop_product_form_variants\'); } return false;'; $this->row = new stdClass(); $this->row->prices = array($this->row); $this->row->product_quantity = -1; $this->row->product_min_per_order = 0; $this->row->product_max_per_order = -1; $this->row->product_sale_start = 0; $this->row->product_sale_end = 0; $this->row->formName = 'hikashop_product_form_variants'; $this->row->prices = array('filler'); $this->params->set('show_quantity_field', 2); $this->setLayout('quantity'); echo $this->loadTemplate(); if(!empty($this->ajax) && $this->config->get('redirect_url_after_add_cart','stay_if_cart') == 'ask_user') { ?>