Adding attachment field to ask a question form on product detail page

  • Posts: 79
  • Thank you received: 0
7 years 5 months ago #272495

-- HikaShop version -- : hikashop business 3.0.1
-- Joomla version -- : joomla 3.7

Hi, i would like to add an attachment field on the contact form on product detail page.

do you have any tutorial or documentation to show how to get this done?

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
7 years 5 months ago #272506

Hi,

It should be no problem. Go in the menu Display>Custom fields, click on the "new" button, select the table "contact" and the type "ajax file" and save. Check also the display settings so that they are like you want and you're done.

You can find the documentation on custom fields here:
www.hikashop.com/support/documentation/4...shop-field-form.html

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

  • Posts: 79
  • Thank you received: 0
7 years 5 months ago #272588

Hi, thanks for the reply, i have succeed to add the field to the contact form.

However the uploaded images is not sending to admin/vendor as attachment.
how can i add the field to email template also?

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
7 years 5 months ago #272598

Hi,

In the contact email notification, you should have a download link and that download link will allow you to get access to the file.
You didn't had the link in the email ?
If so, how did you configure the custom field ?

There is no option to have the file as an attachment of that email instead of a download link.
That would require you to add custom code in the "preload" of the contact form notification email via the menu System>Emails.

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

  • Posts: 79
  • Thank you received: 0
7 years 4 months ago #273019

Hi, attached is my config on custom field, and another one is notification email i received.
As your can see, there is no download link of the file . please advice.

Attachments:

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

  • Posts: 4747
  • Thank you received: 644
  • MODERATOR
7 years 4 months ago #273056

Hello,

I get it ! Can you go in your customization "A contact request has been made" page, and go to your PRELOAD VERSION part, around line 47, you have this :

if(hikashop_level(1)) {
	$null = null;
	$fieldsClass = hikashop_get('class.field');
	$contactFields = $fieldsClass->getFields('frontcomp',$null,'contact');
	if(!empty($contactFields)){
		foreach($contactFields as $field){
			$namekey = $field->field_namekey;
			if(empty($data->element->$namekey) && !strlen($data->element->$namekey)) continue;
			$vars['PRODUCT_DETAILS'] .= '<p>'.$fieldsClass->getFieldName($field).': '.$fieldsClass->show($field, $data->element->$namekey, 'admin_email').'</p>';
		}
	}
}

Replace it for this :
if(hikashop_level(1)) {
	$null = null;
	$fieldsClass = hikashop_get('class.field');
	$contactFields = $fieldsClass->getFields('frontcomp',$data->product,'contact');
	if(!empty($contactFields)){
		foreach($contactFields as $field){
			$namekey = $field->field_namekey;
			if(empty($data->element->$namekey) && !strlen($data->element->$namekey)) continue;
			$vars['PRODUCT_DETAILS'] .= '<p>'.$fieldsClass->getFieldName($field).': '.$fieldsClass->show($field, $data->element->$namekey, 'admin_email').'</p>';
		}
	}
}

The difference is on line 4 of this code sample :
$contactFields = $fieldsClass->getFields('frontcomp',$null,'contact');
For
$contactFields = $fieldsClass->getFields('frontcomp',$data->product,'contact');

That would solve your link display issue.

Regards

Last edit: 7 years 4 months ago by Philip.

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

  • Posts: 79
  • Thank you received: 0
7 years 4 months ago #273202

Hi,

I had tried to modified your code but end up admin cant receive the email edi. Anything i did wrong?
One more thing, when user upload an image on the ask a question form, the thumbnail shows a broken image, is this normal? anyway to fix this? cause this is not very good looking on UI.

Attachments:

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

  • Posts: 4747
  • Thank you received: 644
  • MODERATOR
7 years 4 months ago #273211

Hello,

On our side, we haven't this kind of issue, so maybe you make something wrong inside your emails code...
Try to redo the modification from a default code, and so in emails listing click on the little trash icon in order to remove modification (you can save on your side your code before remove it).
And as said previously, just remove "$null" for "$data->product"
Awaiting news from you.

Regards

Last edit: 7 years 4 months ago by Philip.

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

  • Posts: 79
  • Thank you received: 0
7 years 4 months ago #273316

Hi,

i did a mistake which i direct modified from the core file.
Now i redo your steps from the system configuration, the email is sending out already.
But still don't have the download link for the image that user uploaded at the contact form.

(ps: this form is submitted from vendor detail page, just in case the place that submit the form affected the output)

Attachments:

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

  • Posts: 4747
  • Thank you received: 644
  • MODERATOR
7 years 4 months ago #273323

Hello,

You have to be more precise because I believed that you want have your contact form in your product detail page...

" i would like to add an attachment field on the contact form on product detail page."


Vendor page or Product page isn't important because it's the same form, but not the same context and especially limits, when I look in your Custom field configuration you have a restriction on Product categories, and so I wonder how you can have the file dropped area with this configuration on your vendor page...
Anyway remove this restriction, there is no purpose if you have to use this custom field from vendor page and maybe that will solve your issue.

Awaiting news from you.

Regards

Last edit: 7 years 4 months ago by Philip.

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

  • Posts: 79
  • Thank you received: 0
7 years 4 months ago #273341

Hi ,

After i remove the restriction, i can see the image name that uploaded by user already but it is not a download link yet.

Attachments:

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

  • Posts: 4747
  • Thank you received: 644
  • MODERATOR
7 years 4 months ago #273363

Hello,

Quite strange result... I don't know what can leads this kind of display, I see only 1 solution right now :
Provide backend/frontend access and an Url link in order to process some test.
Use our Contact us form to provide this AND don't forget to add in your message an Url link to this topic.
Notify us by posting in this topic when it's done.

Regards

Last edit: 7 years 4 months ago by Philip.

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
7 years 4 months ago #273457

Hi,

We got the access. Thanks.
I didn't understood that you were talking about the vendor contact form. It's now clearer why you have the problem.
I changed the code:

$vars['PRODUCT_DETAILS'] .= '<p>'.$fieldsClass->getFieldName($field).': '.$fieldsClass->show($field, $data->element->$namekey, 'user_email').'</p>';
to:
$vars['PRODUCT_DETAILS'] .= '<p>'.$fieldsClass->getFieldName($field).': '.$fieldsClass->show($field, $data->element->$namekey, 'admin_email').'</p>';
in the preload of the contact email on your website (and on our end too) and that will make the link available.
However, note that this is a download link which requires a backend authentication (for security).
There is no way to have a download link available for the vendors on the frontend since otherwise, anyone would be able to download the files uploaded by users on the frontend and that would be a security issue.
So you can't have a custom fields of the type "ajax file", "ajax image", "file" or "image" for the vendor contact form.

Last edit: 7 years 4 months ago by nicolas.

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

  • Posts: 25
  • Thank you received: 1
4 years 4 months ago #322081

Hi, I know it's an old entry.

But I am having the same problem and the solutions given here do not solve it.

I need a loaded file to arrive from a custom fields ajax of the hikashop contact form.

Thank you

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
4 years 4 months ago #322088

Hi,

The code by default should already support that properly.
Could you provide a URL to your contact form and a screenshot of an email that you got from a test on it where the custom field link wasn't included ?
Could you also provide a screenshot of the custom field settings ?

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

  • Posts: 25
  • Thank you received: 1
4 years 4 months ago #322108

Hi, Thank you,
I am working on a big update, and I do not have this online, however I send a screen of the tests done.

Guide me on what to do please, thanks

Attachments:

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

  • Posts: 25
  • Thank you received: 1
4 years 4 months ago #322109

Hi, I have discovered, if I send the file from the product button the file does arrive, but if I send from the form as a contact outside the product, the file does not arrive.

I need the email with the file to arrive from the contact form outside the product

Attachments:

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

  • Posts: 4747
  • Thank you received: 644
  • MODERATOR
4 years 4 months ago #322110

Hello,

Then this would require to see the full custom field screenshot configuration, please.
Later, add an url link to see it by ourselves.
regards

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

  • Posts: 25
  • Thank you received: 1
4 years 4 months ago #322137

Hi Philip,
The website I am updating it in a local environment, I send you the screenshot configuration and the email message.

I appreciate your help in this

Attachments:

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
4 years 4 months ago #322163

Hi,

I think what's missing is this piece of code:

if(!empty($vars['PRODUCT_DETAILS']))
			$vars['PRODUCT'] = true;
after the code:
foreach($contactFields as $field){
			$namekey = $field->field_namekey;
			if(!isset($data->element->$namekey)) continue;
			if(empty($data->element->$namekey) && !strlen($data->element->$namekey)) continue;
			$vars['PRODUCT_DETAILS'] .= '<p>'.$fieldsClass->getFieldName($field).': '.$fieldsClass->show($field, $data->element->$namekey, 'admin_email').'</p>';
		}
in the file media/com_hikashop/mail/contact_request.preload.php

The following user(s) said Thank You: alisse

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

Time to create page: 0.130 seconds
Powered by Kunena Forum