Hi All,
I'm trying to produce a characteristic override to show price near the radio button.
I'm not a php expert (and english also ), but I have already override some view.
On my first step on override I have this error:
Notice: Trying to get property of non-object in .../html/hikashop_characteristics.php on line 7
My code,
where on "PREZZO" (on line #56) I would like insert the unit price:
<?php
function hikashop_characteristics_html(&$element,&$params,&$obj)
{
switch($params->get('characteristic_display')){
case 'table':
if(count($obj->characteristics)==2){
$html = '';
$firstCharacteristic = reset($obj->characteristics);
$secondCharacteristic = end($obj->characteristics);
$html.= '<table class="hikashop_product_characteristic_chooser"><tr><td></td>';
if(empty($secondCharacteristic->values)){
}else{
foreach($secondCharacteristic->values as $value){
$html.='<td>'.$value->characteristic_value.'</td>';
}
}
$html.='</tr>';
$obj->options=' onclick="return hikashopUpdateVariantData(this.value);"';
$size=0;
if(!empty($firstCharacteristic->values)){
foreach($firstCharacteristic->values as $value){
$html.='<tr><td style="text-align:right">'.$value->characteristic_value.'</td>';
if(strlen($value->characteristic_value)>$size)$size=strlen($value->characteristic_value);
if(!empty($secondCharacteristic->values)){
foreach($secondCharacteristic->values as $value2){
$class = '';
$classspan = '';
foreach($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';
}
break 2;
}
}
}
$name = '_'.$value->characteristic_id.'_'.$value2->characteristic_id;
$radio="\n\t<span class=\"hikashop_product_characteristic_span".$classspan."\"><input type=\"radio\" class=\"hikashop_product_characteristic".$class."\" name=\"hikashop_product_characteristic\" id=\"hikashop_product_characteristic".$name."\" value=\"".$name."\" ".$obj->options;
if($obj->characteristics[$value->characteristic_parent_id]->default->characteristic_id==$value->characteristic_id && !empty($obj->characteristics[$value2->characteristic_parent_id]->default->characteristic_id) && $obj->characteristics[$value2->characteristic_parent_id]->default->characteristic_id==$value2->characteristic_id){
$radio.=' checked';
}
$radio.=" /></span>";
$html.='<td>'.$radio.' PREZZO</td>';
}
}
$html.='</tr>';
}
}
$html.='</table>';
if($params->get('characteristic_display_text')){
$space = '';
for($i=0;$i<=$size;$i++){
$space.=' ';
}
$html='<table class="hikashop_product_characteristic_chooser"><tr><td></td/><td>'.$space.$secondCharacteristic->characteristic_value.'</td></tr><tr><td>'.$firstCharacteristic->characteristic_value.'</td><td>'.$html.'</td></table>';
}
break;
}
default:
case 'radio':
case 'dropdown':
$main_html = '<table class="hikashop_product_characteristics_table">';
$config =& hikashop_config();
foreach($obj->characteristics as $characteristic){
$main_html.='<tr>';
$values = array();
if(!empty($characteristic->values)){
foreach($characteristic->values as $k => $value){
if(!$config->get('show_out_of_stock')){
$hasQuantity = false;
foreach($element->variants as $variant){
foreach($variant->characteristics as $variantCharacteristic){
if($variantCharacteristic->characteristic_id==$value->characteristic_id){
if($variant->product_quantity != 0 || $element->product_id==$variant->product_id){
$hasQuantity = true;
}
}
}
}
if(!$hasQuantity) continue;
}
$values[$k]=$value->characteristic_value;
}
}
$html=$obj->display($characteristic->characteristic_id,@$characteristic->default->characteristic_id,$values,$params->get('characteristic_display'));
if($params->get('characteristic_display_text')){
$html=$characteristic->characteristic_value.'</td><td>'.$html;
}
$main_html.='<td>'.$html.'</td></tr>';
}
$main_html.='</table>';
$html = $main_html;
break;
}
}
?>