change separator Multiple Dropdown - custom field

  • Posts: 31
  • Thank you received: 3
5 years 10 months ago #306008

-- HikaShop version -- : 4.0.3
-- Joomla version -- : 3.9.5
-- PHP version -- : 7.2
-- Browser(s) name and version -- : Firefox last version

hello, how are you
I created a new custom field of Multiple Dropdown type
I set the values
When display value in the website (frontend) with a separator ( , )
For example Multiple Dropdown value:
value 1-> 12
value 2->49
value 3->79
frontend display : 12 , 49 , 79
how to change separator Multiple Dropdown - custom field
thanks

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

  • Posts: 83483
  • Thank you received: 13505
  • MODERATOR
5 years 10 months ago #306019

Hi,

The crudest method would be to change the line:
return implode(', ',$results);
in the file administrator/components/com_hikashop/classes/field.php
A cleaner version would be to do a view override of the view file displaying the area where you have the custom field and add a str_replace to change the , to what you want.
For example, if it's a custom product field, you would edit the file product/show_block_custom_main.php via the menu Display>Views and you would change :
<?php echo $this->fieldsClass->show($oneExtraField,$value); ?>
to for example:
<?php echo str_replace(', ', '<br/>',$this->fieldsClass->show($oneExtraField,$value)); ?>
to have the field values separated by a br tag instead of a comma.

The following user(s) said Thank You: p30yaran

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

Time to create page: 0.046 seconds
Powered by Kunena Forum