how can display a custom field under the product title and sku

  • Posts: 43
  • Thank you received: 3
2 years 7 months ago #341445

-- HikaShop version -- : 4.5.1
-- Joomla version -- : 4.1.2

Hi,
How can display a custom field, for example, "Short description" under the title and SKU of product on the product page?
Thanks in advance

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

  • Posts: 83022
  • Thank you received: 13403
  • MODERATOR
2 years 7 months ago #341454

Hi,

First, you can create the custom field of the table "product" and of the type "WYSIWYG" via the menu Display>Custom fields.
Then, in your products edit form, you can add text in that custom field.
Finally, in the menu Display>Views, you can edit the file product / show_default and add such code:

<?php echo $this->element->xxx; ?>
where xxx is the column name of your custom field and it will display the content of the custom field in the position you add it in the view file.

The following user(s) said Thank You: diacotm

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

  • Posts: 43
  • Thank you received: 3
2 years 7 months ago #341499

Thanks;
It worked!

It shows in the specification tab too; is it possible to hide this specific item there?
Thanks in advance

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

  • Posts: 83022
  • Thank you received: 13403
  • MODERATOR
2 years 7 months ago #341504

Hi,

Yes. The display in the specifications tab depends on the corresponding display setting of the custom field. So edit it via the menu Display>Custom fields and check its settings and turn off the display setting for the frontend product page.

The following user(s) said Thank You: diacotm

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

  • Posts: 43
  • Thank you received: 3
2 years 7 months ago #341513

Hi,
It worked!
Thank u so much

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

  • Posts: 53
  • Thank you received: 3
  • Hikashop Business
8 months 2 days ago #360433

Hi, it works perfectly but, if I wont to display a check box custom field, it shows me the field data value, but I need to show the field data title.
Can you help me?

Last edit: 8 months 2 days ago by nico1979.

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

  • Posts: 83022
  • Thank you received: 13403
  • MODERATOR
8 months 2 days ago #360436

Hi,

The code in my message above is indeed to display the value stored in the database directly. If you want to display the title corresponding to the value, then you need code which is a bit more complex:

<?php
$fieldClass = hikashop_get('class.field');
$field = $fieldClass->getField('xxx', 'product');
echo $fieldClass->show($field, $this->element->xxx);
?>
where xxx is the column name of the field.

Last edit: 6 months 3 weeks ago by nicolas.

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

  • Posts: 53
  • Thank you received: 3
  • Hikashop Business
6 months 4 weeks ago #361200

Hi,
I've tried with your code, replacing "xxx" with column name, but it gives me error.
1 () JROOT/templates/allura/html/com_hikashop/product/show_default.php:210
2 include() JROOT/libraries/src/MVC/View/HtmlView.php:416
And more...
Thank you

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

  • Posts: 53
  • Thank you received: 3
  • Hikashop Business
6 months 4 weeks ago #361202

This is the correct code:

<?php
$fieldClass = hikashop_get('class.field');
$field = $fieldClass->getField('xxx', 'product');
echo $fieldClass->show($field, $this->element->xxx);
?>

The following user(s) said Thank You: nicolas

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

  • Posts: 83022
  • Thank you received: 13403
  • MODERATOR
6 months 3 weeks ago #361205

Indeed. I forgot to add the second parameter with the table of the field when writting the code to give to you. Sorry for that.
I've updated the code in my message too.

Last edit: 6 months 3 weeks ago by nicolas.

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

Time to create page: 0.069 seconds
Powered by Kunena Forum
loading