Custom field values don't change based on variants

  • Posts: 40
  • Thank you received: 0
10 years 3 months ago #203251

-- url of the page with the problem -- : ark.developwithrgb.com/categories2/Produ...toothpaste-small-med
-- HikaShop version -- : 1504301217
-- Joomla version -- : 3.4.1
-- PHP version -- : 5.4.38
-- Error-message(debug-mod must be tuned on) -- : I would like custom fields to change based on the variants selected.

Like when the user selects a different pet size, I want the short description and the dog / cat icons to change based on the selection

ark.developwithrgb.com/categories2/Produ...toothpaste-small-med

Could you please let me know how to modify this. I see the non-custom fields do change but not the custom ones

I would like custom fields to change based on the variants selected.

Like when the user selects a different pet size, I want the short description and the dog / cat icons to change based on the selection

ark.developwithrgb.com/categories2/Produ...toothpaste-small-med

Could you please let me know how to modify this. I see the non-custom fields do change but not the custom ones

Please Log in or Create an account to join the conversation.

  • Posts: 84304
  • Thank you received: 13698
  • MODERATOR
10 years 3 months ago #203293

Hi,

There is no easy system to change custom fields based on characteristics selection.
It would require custom JavaScript code to be added to the characteristics display system.
That would have to be added by a professional developer.
Otherwise, you could simply put your text/image in the product description, which can be different for each variant.

Please Log in or Create an account to join the conversation.

  • Posts: 40
  • Thank you received: 0
10 years 3 months ago #203375

I can write JS. Please let me know what file to edit and where are the non-custom fields are being updated based on variants.

Thank you

Please Log in or Create an account to join the conversation.

  • Posts: 84304
  • Thank you received: 13698
  • MODERATOR
10 years 3 months ago #203379

HI,

This is done in the file administrator/components/com_hikashop/types/characteristic.php

But that would mean that you would hack a core file of HikaShop and you would loose your changes after each update.
A cleaner solution would be to edit the file "show_block_characteristic" via the menu Display>Views and change the line:

echo $this->characteristic->displayFE($this->element, $this->params) . '</div>';

You could for example write:
echo str_replace('onclick="','onclick="mycustomJSFunction(this);',$this->characteristic->displayFE($this->element, $this->params) . '</div>');
and then you could do like that in order to add your custom JS:
$js="
function mycustomJSFunction(characteristicDropdownElement){
 if(characteristicDropdownElement.value=='value1'){
  //do your stuff here
 }
}
";
$doc = JFactory::getDocument();
$doc->addScriptDeclaration("\n<!--\n".$js."\n//-->\n");

That way, you won't loose your changes during updates.

Please Log in or Create an account to join the conversation.

Time to create page: 0.060 seconds
Powered by Kunena Forum