- Posts: 17
- Thank you received: 0
Price and stock don't update when picking another variant
8 years 8 months ago #289579
by nrgiser
Price and stock don't update when picking another variant was created by nrgiser
-- url of the page with the problem -- :
staging6.2-sleep.be/index.php/categoriee...ue-check-kussensloop
-- HikaShop version -- : 3.3.0
-- Joomla version -- : 3.8.5 (3.8.6 just came out a few hours ago)
-- PHP version -- : 7.0.27
-- Browser(s) name and version -- : Google Chrome 64.0.3282.186
Hi,
The URL above points to a product with 5 variants. 1 of them has a price 41,32 and a stock of 10, a second one has the same price but a stock of 15 and the other 3 have no stock and a price of 49,59.
The one with the stock of 15 is the default variant. When opening the above URL the stock and price of the default variant is shown. But when I pick another variant, the stock and price stay doesn't change.
I'm 100% sure that the price used to change when picking another variant. The stock I don't know because I just activated that a few days ago.
What could be causing this problem?
Kind regards,
Jan Buskens
-- HikaShop version -- : 3.3.0
-- Joomla version -- : 3.8.5 (3.8.6 just came out a few hours ago)
-- PHP version -- : 7.0.27
-- Browser(s) name and version -- : Google Chrome 64.0.3282.186
Hi,
The URL above points to a product with 5 variants. 1 of them has a price 41,32 and a stock of 10, a second one has the same price but a stock of 15 and the other 3 have no stock and a price of 49,59.
The one with the stock of 15 is the default variant. When opening the above URL the stock and price of the default variant is shown. But when I pick another variant, the stock and price stay doesn't change.
I'm 100% sure that the price used to change when picking another variant. The stock I don't know because I just activated that a few days ago.
What could be causing this problem?
Kind regards,
Jan Buskens
Please Log in or Create an account to join the conversation.
8 years 8 months ago #289584
by Jerome
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Replied by Jerome on topic Price and stock don't update when picking another variant
Hello,
Do you have an override for the characteristic selector ?
It would be a file in your template folder ( html/hikashop_characteristics.php )
CF : www.hikashop.com/support/documentation/6...tation.html#override
Regards,
Do you have an override for the characteristic selector ?
It would be a file in your template folder ( html/hikashop_characteristics.php )
CF : www.hikashop.com/support/documentation/6...tation.html#override
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
8 years 8 months ago #289616
by nrgiser
Replied by nrgiser on topic Price and stock don't update when picking another variant
Yes, there is.
Since I can't attach it, below you can find the code that's in it.
Did I break it myself?
Kind regards,
Since I can't attach it, below you can find the code that's in it.
Code:
<?php
defined('_JEXEC') or die('Restricted access');
?>
<?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)){
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.'</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 class="hikashop_charactersitic_name">'.$space.@$secondCharacteristic->characteristic_value.'</td></tr><tr><td class="hikashop_charactersitic_name">'.$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 style="vertical-align: top;">';
$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($element->variants as $variant){
foreach($variant->characteristics as $variantCharacteristic){
if($variantCharacteristic->characteristic_id==$value->characteristic_id){
if($variant->product_quantity != 0){
$hasQuantity = true;
}elseif( $element->product_id==$variant->product_id && !$switch_done){
$id = 'hikashop_product_characteristic_'.$characteristic->characteristic_id;
$js = "
window.hikashop.ready( function() {hikashopUpdateVariant(document.getElementById('".$id."'));});";
if (!HIKASHOP_PHP5) {
$doc =& JFactory::getDocument();
}else{
$doc = JFactory::getDocument();
}
$doc->addScriptDeclaration("\n<!--\n".$js."\n//-->\n");
$switch_done = true;
}
}
}
}
if(!$hasQuantity) continue;
}
$values[$k]=$value->characteristic_value;
}
}
$html=$obj->display(@$characteristic->characteristic_id,@$characteristic->default->characteristic_id,$values,$characteristic->characteristic_display_method);
if($params->get('characteristic_display_text') && isset($characteristic->characteristic_value)){
$html=$characteristic->characteristic_value.'</td><td>'.$html;
}
$main_html.='<td>'.$html.'</td></tr>';
}
$main_html.='</table>';
$html = $main_html;
break;
}
return $html;
}
?>
Did I break it myself?
Kind regards,
Please Log in or Create an account to join the conversation.
8 years 8 months ago #289624
by nicolas
Replied by nicolas on topic Price and stock don't update when picking another variant
Hi,
Well that's code coming from the template or added by yourself.
Apparently, it is missing some pieces.
Rename that file to something else in order to deactivate it.
That way, you'll use the default characteristics selector of HikaShop and it should work properly.
You might want to report that to your template provider.
Well that's code coming from the template or added by yourself.
Apparently, it is missing some pieces.
Rename that file to something else in order to deactivate it.
That way, you'll use the default characteristics selector of HikaShop and it should work properly.
You might want to report that to your template provider.
Please Log in or Create an account to join the conversation.
8 years 8 months ago #289871
by nrgiser
Replied by nrgiser on topic Price and stock don't update when picking another variant
Hi,
That was indeed the problem.
Where can I find the original file? I would like to compare it with the override file.
Kind regards,
Jan Buskens
That was indeed the problem.
Where can I find the original file? I would like to compare it with the override file.
Kind regards,
Jan Buskens
Please Log in or Create an account to join the conversation.
8 years 8 months ago #289893
by nicolas
Replied by nicolas on topic Price and stock don't update when picking another variant
Hi,
The file you want to look at is administrator/components/com_hikahsop/types/characteristic.php
Note that it's not a direct copy of the code. Some things have to be modified for the override to work.
The file you want to look at is administrator/components/com_hikahsop/types/characteristic.php
Note that it's not a direct copy of the code. Some things have to be modified for the override to work.
Please Log in or Create an account to join the conversation.
Time to create page: 0.064 seconds