Hi,
The badge cannot refresh when you change the variant as the badges are loaded only for the whole product, not per variant for now.
That will require some modifications to support that.
Let's try that.
Change the code:
$qty = 0;
if(isset($row->main)){
if(@$row->main->discount) $discount =& $row->main->discount;
elseif(@$row->discount) $discount =& $row->discount;
$product_id = $row->main->product_id;
$qty = $row->main->product_quantity;
}else{
if(@$row->discount) $discount =& $row->discount;
$product_id = $row->product_id;
$qty = $row->product_quantity;
}
$badge_filters=array(
'a.badge_start <= '.time(),
'( a.badge_end >= '.time().' OR a.badge_end =0 )',
'a.badge_published=1',
'(a.badge_quantity=\'\' OR a.badge_quantity='.(int)$qty.')',
);
if($discount && isset($discount->discount_id)){
$badge_filters[]='(badge_discount_id='.(int)@$discount->discount_id.' OR badge_discount_id LIKE \'%,'.(int)@$discount->discount_id.',%\' OR badge_discount_id=\'0\' OR badge_discount_id=\'\' )';
}else{
$badge_filters[]='(badge_discount_id=\'0\' OR badge_discount_id=\'\')';
}
$categories = array(
'originals' => array(),
'parents' => array()
);
$categoryClass = hikashop_get('class.category');
$productClass = hikashop_get('class.product');
to:
$qty = $row->product_quantity;
if(isset($row->main)){
if(@$row->main->discount) $discount =& $row->main->discount;
elseif(@$row->discount) $discount =& $row->discount;
$product_id = $row->main->product_id;
if($row->product_quantity==-1){
$qty = $row->main->product_quantity;
}
}else{
if(@$row->discount) $discount =& $row->discount;
$product_id = $row->product_id;
}
$badge_filters=array(
'a.badge_start <= '.time(),
'( a.badge_end >= '.time().' OR a.badge_end =0 )',
'a.badge_published=1',
'(a.badge_quantity=\'\' OR a.badge_quantity='.(int)$qty.')',
);
if($discount && isset($discount->discount_id)){
$badge_filters[]='(badge_discount_id='.(int)@$discount->discount_id.' OR badge_discount_id LIKE \'%,'.(int)@$discount->discount_id.',%\' OR badge_discount_id=\'0\' OR badge_discount_id=\'\' )';
}else{
$badge_filters[]='(badge_discount_id=\'0\' OR badge_discount_id=\'\')';
}
$categories = array(
'originals' => array(),
'parents' => array()
);
$categoryClass = hikashop_get('class.category');
$productClass = hikashop_get('class.product');
if(!isset($row->categories) && isset($row->main->categories)){
$row->categories =& $row->main->categories;
}
in administrator/components/com_hikashop/classes/badge.php
Add the code:
if(!empty($element->variants)){
foreach($element->variants as $k => $variant){
$classbadge->loadBadges($element->variants[$k]);
}
}
after the code:
$classbadge=hikashop_get('class.badge');
$this->assignRef('classbadge',$classbadge);
$classbadge->loadBadges($element);
in the file components/com_hikashop/views/product/view.html.php
And add the line:
$this->element->badges =& $variant->badges;
after the line:
$this->element->images =& $variant->images;
in the file "show" of the view "product" via the menu display>views.
That should allow the system to support that.
Let us know how it goes so that we can add it on our end for the next version.