Display product custom fields in product contact form

  • Posts: 26
  • Thank you received: 3
  • Hikashop Business
4 years 2 months ago #327826

-- HikaShop version -- : 4.4.0
-- Joomla version -- : 3.9.23
-- PHP version -- : 7.3.7
-- Browser(s) name and version -- : not relevant
-- Error-message(debug-mod must be tuned on) -- : none

Hi Guys,
I would like to display the contents of the product custom fields on the contact form of the product.
I checked the docs and forum, but did not find what I'm looking for, so I hope you can help.

The URL I entered above shows what the product page looks like - it's currently in "catalog mode".

We would like to allow a visitor to enter available info about the picture and stimulate this by showing all we already know (which is mainly in custom fields).
I have tried creating custom contact fields, which works, but I would then need to transfer the values of the product custom fields to the form, but I cannot find the proper way to access the custom fields of the product.
Getting values into the form is not the problem, getting the right values there, that's my problem.

Again, I hope you can give me a little push in the proper direction.

Cheers,
André

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

  • Posts: 83404
  • Thank you received: 13498
  • MODERATOR
4 years 2 months ago #327828

Hi,

Supposing that your custom contact fields are named xxx and yyy and that the corresponding custom product fields are named xxx_product and yyy_product, then, you should be able to do that by changing the code:
$itemData = @$formData->$fieldName;
to:
$column_name = $fieldName.'_product';
$itemData = @$this->product->$column_name;
in the file "contact" of the view "product" via the menu Display>Views.

The following user(s) said Thank You: multigeo

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

  • Posts: 26
  • Thank you received: 3
  • Hikashop Business
4 years 2 months ago #327839

Great! Thanks Nicholas.
That was just what I needed, problem solved!
Only some CSS tweaking left and I'm done :-)

The following user(s) said Thank You: Philip

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

Time to create page: 0.048 seconds
Powered by Kunena Forum