Specifications - Default Value

  • Posts: 9
  • Thank you received: 0
  • Hikashop Business
6 months 1 week ago #356118

-- HikaShop version -- : 5.0.0
-- Joomla version -- : 5.0.0
-- PHP version -- : 8.2

I made a custom field of type WYSIWYG for my product "Specifications" tab.

I would like the Specifications tab to have a table of information about the product.

I made the default value of the custom field a table, but when I create new products the table format/structure is lost; only the values appear.

Is there a way to have a table as the custom field's default value?

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

  • Posts: 81591
  • Thank you received: 13079
  • MODERATOR
6 months 1 week ago #356123

Hi,

Normally, that's not how you do it. You need to create one custom field for each row of information you want to display. HikaShop will display under that specifications tab a table of your custom product fields, with the values entered / selected in each custom field.

Now, I think the Wysiwyg custom field code is missing a piece to handle default values.
Add the code:

if(strlen($value) < 1 && !empty($field->field_default)){
			$value = $this->trans($field->field_default);
		}
before the line:
$editorHelper->content = $value;
in the file administrator/components/com_hikashop/classes/field.php and it should allow you to get the custom field default value when editing a product.
Let us know how it goes so that we can add the patch for the next release.

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

  • Posts: 9
  • Thank you received: 0
  • Hikashop Business
6 months 1 week ago #356167

I tried the code change but it does not seem to make a difference. Note that this is only an issue of the default value. Once a product is created, the WYSIWYG values display as expected.

The issue is that a table created as the Default Value is not saved with the WYSIWYG custom field.

Example:
Create the WYSIWYG custom field ("Specifications") and make a table as it's default value. Populate it with values. Save & Close.
Open the field again for editing - the table structure will be lost ; only the values will remain.

Similarly, if you make a new product, the (Default) table values appear as the default, but the structure is not present.

However, if when editing a product I create a table in the custom filed called Specifications, it will stay there and display as expected.

--

I know this isn't the "right way", but my the Specifications custom field is special and I love the flexible way it works to accomodate both "information" and "data" about products. Because my products (fancy superautomatic espresso machines) have many technical characteristics, not all of which apply to every model, I'm using "Specifications" for information about the product and a bunch of other custom fields to capture values (also used for "Compare"). Having a flexible way (a simple table above the other custom fields) is great.

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

  • Posts: 81591
  • Thank you received: 13079
  • MODERATOR
6 months 1 week ago #356168

Hi,

The table being stripped might be because of the "input filtering" setting of the custom field. Please try to turn that setting off in the custom field and try again.

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

  • Posts: 9
  • Thank you received: 0
  • Hikashop Business
6 months 1 week ago #356175

OK - very great. Input filtering was the problem; the additional code was not necessary. Cool.

But - there's a weird interaction between the Specifications data and the other Custom Fields data.

When the other custom fields have values, their presence shrinks the Specifications table.

Example:

Just the table in Specifications: j5.expressoshoppe.com/index.php/cat/product/sample-product-a

Also using other Custom Fields: j5.expressoshoppe.com/index.php/cat/product/sample-product-b

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

  • Posts: 81591
  • Thank you received: 13079
  • MODERATOR
6 months 1 week ago #356178

Hi,

The issue is that you've added CSS to hide the name of the custom field:
i.imgur.com/K826Xdt.png
With your .hikashop_product_custom_specifications_line td.key { display: none; } code, the browser thinks that for the first row, the second column is now the first column, and thus the table goes on the left side (the first column).

You could change it to:
.hikashop_product_custom_specifications_line td.key { color: transparent; }
i.imgur.com/cIYhwKX.png
But then it would mess the display without the other custom fields.

The best will be to not use CSS and instead do a view override of product / show_block_custom_main via the menu Display>Views and make it so that the main custom field displays outside of the table of custom fields. This will require some PHP knowledge.

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

Time to create page: 0.066 seconds
Powered by Kunena Forum