![Quote](images/styles/zencart/misc/quote_icon.png)
Originally Posted by
mikebr
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:
Code:
zen_mail($send_to_name, $send_to_email, EMAIL_SUBJECT, $text_message, $name, $email_address, $html_msg,'contact_us');
to:
Code:
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']);
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.jpg
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:
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'];
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_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'];
The HTML email message could be modified as follows (or any other way as well):
from:
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']);
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'] . 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']);
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.
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']
Bookmarks