mc12345678.. You truly are Totally Zenned, Thank you!
Printable View
mc12345678.. You truly are Totally Zenned, Thank you!
...since I hacked this up over 5 years ago, I make no excuses for it...I've never looked at it since so I've no doubt it could and should be done better. In fact Conor-Ceon was integrating this functionality into Back in Stock for me when he passed, so it almost got done "properly".
ZC-1.5.5e, PHP 5.6.32, Database patch level 1.5.5
Is there any way of including an image of the product the 'ask a question' is about in the email to the webmaster?
thanks in advance
Course its possible just depends on how you want it included. Can be attached to the document/email by adding another parameter to the zen_mail function that has either the full path to the image or just the relative path to the image or could "build" the file(s) that are to be attached. Another way is to incorporate the image into the email body message generating a link to the image that uses the full uri to reach it.
The image information is already included in the sql return, just need to use it for the desired effect.
To include as an attachment around line 103 change:
to:Code:zen_mail($send_to_name, $send_to_email, EMAIL_SUBJECT, $text_message, $name, $email_address, $html_msg,'contact_us');
To incorporate in the email as part of the "text" recommended methods have been to build an html image tag with the image referenced within the tag as if to get to it via URL: ie. https: // your store . com/ images / my-email-img.jpgCode:zen_mail($send_to_name, $send_to_email, EMAIL_SUBJECT, $text_message, $name, $email_address, $html_msg,'contact_us', DIR_FS_CATALOG . DIR_WS_IMAGES . $product_info->fields['products_image']);
This can be done with zen_href_link to build the address and some additional text in either/both the text version and the html version of the email. Then for the html version it may just be better to create a separate variable to be populated instead of "cramming" in with text and the added difficulty of manipulating it, but to each their own.
Incorporating the image into the plain text message (at least the uri is generated) would be by changing:
To:Code:// Prepare Text-only portion of message
$text_message = OFFICE_FROM . "\t" . $name . "\n" .
OFFICE_EMAIL . "\t" . $email_address . "\n" .
PROD_NAME . "\t" . $product_info->fields['products_name'] . "\n" .
zen_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . (int)$_GET['products_id']) .
"\n\n" .
'------------------------------------------------------' . "\n\n" .
strip_tags($_POST['enquiry']) . "\n\n" .
'------------------------------------------------------' . "\n\n" .
$extra_info['TEXT'];
The HTML email message could be modified as follows (or any other way as well):Code:// Prepare Text-only portion of message
$text_message = OFFICE_FROM . "\t" . $name . "\n" .
OFFICE_EMAIL . "\t" . $email_address . "\n" .
PROD_NAME . "\t" . $product_info->fields['products_name'] . "\n" .
zen_image(($request_type == 'SSL' ? HTTPS_SERVER . DIR_WS_HTTPS_CATALOG : HTTP_SERVER . DIR_WS_CATALOG) . DIR_WS_IMAGES . $product_info->fields['products_image'], $product_info->fields['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . "\n" .
zen_href_link(zen_get_info_page((int)$_GET['products_id']), 'products_id=' . (int)$_GET['products_id']) .
"\n\n" .
'------------------------------------------------------' . "\n\n" .
strip_tags($_POST['enquiry']) . "\n\n" .
'------------------------------------------------------' . "\n\n" .
$extra_info['TEXT'];
from:
To:Code:// Prepare HTML-portion of message
$html_msg['EMAIL_MESSAGE_HTML'] = '<b>Product: </b><a href="' . zen_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . (int)$_GET['products_id']) . '">' . $product_info->fields['products_name'] . '</a><br />' . strip_tags($_POST['enquiry']);
This puts the image after (may end up below or to the right of) the product's name. Include additional surrounding html tags to support improved/easier css handling.Code:// Prepare HTML-portion of message
$html_msg['EMAIL_MESSAGE_HTML'] = '<b>Product: </b><a href="' . zen_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . (int)$_GET['products_id']) . '">' . $product_info->fields['products_name'] . zen_image(($request_type == 'SSL' ? HTTPS_SERVER . DIR_WS_HTTPS_CATALOG : HTTP_SERVER . DIR_WS_CATALOG) . DIR_WS_IMAGES . $product_info->fields['products_image'], $product_info->fields['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br />' . strip_tags($_POST['enquiry']);
Hope that helps. Note, images are not likely to be displayed in the non-html version of the email... Afterall, supposed to be plain text right? to generate just the link, well, would use:Code:// Prepare Text-only portion of message
$text_message = OFFICE_FROM . "\t" . $name . "\n" .
OFFICE_EMAIL . "\t" . $email_address . "\n" .
PROD_NAME . "\t" . $product_info->fields['products_name'] . "\n" .
($request_type == 'SSL' ? HTTPS_SERVER . DIR_WS_HTTPS_CATALOG : HTTP_SERVER . DIR_WS_CATALOG) . DIR_WS_IMAGES . $product_info->fields['products_image'] . "\n" .
zen_href_link(zen_get_info_page((int)$_GET['products_id']), 'products_id=' . (int)$_GET['products_id']) .
"\n\n" .
'------------------------------------------------------' . "\n\n" .
strip_tags($_POST['enquiry']) . "\n\n" .
'------------------------------------------------------' . "\n\n" .
$extra_info['TEXT'];($request_type == 'SSL' ? HTTPS_SERVER . DIR_WS_HTTPS_CATALOG : HTTP_SERVER . DIR_WS_CATALOG) . DIR_WS_IMAGES . $product_info->fields['products_image']
Thanks so much
the attachment method works great.
This works great only problem I am having is showing the image of the button. I am using responsive classic template on 1.5.5f
I uploaded button_ask_question.gif to includes/templates_default/buttons/English
I uploaded ask_a_question_defines.php to includes/languages/English
and button displays but not the image I wanted. What am I doing wrong?
Right click on the button and use your browser's "Open Image in New Tab" function (this is what it's called in Chrome; might be different in your browser.) Then you'll see where the image is being pulled from. This will help you narrow down what's happening.