News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Enabling Mail to Customers Who Purchased - from the Product Status tab

Started by thewitt, March 02, 2015, 09:14:29 AM

Previous topic - Next topic

thewitt

I have made a few changes to the code for sending email to Customers to Bought This Product - this is in the Product Status tab under Products in the admin area.

The changes are:

1) Enable both Notify Waiting and Customers Who Bought emails regardless of configuration setting.
2) Corrected logic to allow both functions to work
3) Corrected subject of email character encoding
4) Added a link to the Customers Who Bought email template for selecting the order.

There are minor changes to 6 files in support of this.

How should I give these back to the developers of the software? 

What's the process?

I will post a followup message with the instructions, and attach them as a .txt file as well for anyone who wishes to make this work on their system.

This is for VirtueMart 3.0.6

Thanks,

-Tim

thewitt

To Enable the Notify and Email Customer features of the Product Status Tab under the Product item in Virtuemart 3.0.6

There are a few things to change to make these functions more usable.

Six files need to be changed, however the changes are very minor.

1) /components/com_virtuemart/language/en-GB/en-GB.com_virtuemart.ini

Add the line:

COM_VIRTUEMART_CART_ORDER_INFO="Your Order Information: "

2) /administrator/components/com_virtuemart/language/en-GB/en-GB.com_virtuemart.ini

Add the line:

COM_VIRTUEMART_PRODUCT_SELECT_ORDER_STATUS="Please select a Status type for notification"

3) /administrator/components/com_virtuemart/views/product/tmpl/product_edit_customer.php

Comment out the lines around line 32 like this:


// if (VmConfig::get ('stockhandle', 0) != 'disableadd' or empty($this->waitinglist)) {
// echo '<input type="hidden" name="customer_email_type" value="customer" id="customer_email_type0">';
// }
// else {
echo VmHtml::radioList ('customer_email_type', $mail_default, $mail_options);
// }


In the middle of line 70, change:

htmlentities($this->product->product_name)

To:

html_entity_decode($this->product->product_name, ENT_QUOTES)

Line 110, change this:

<?php if (VmConfig::get ('stockhandle'0) == 'disableadd' && !empty($this->waitinglist)) { ?>

To this:

<?php if (!empty($this->waitinglist)) { ?>

Line 218, correct this bug:

else if (email_type = 'customer') {

To:

else if (email_type == 'customer') {

Starting at line 218, change this:


else if (email_type = 'customer') {
var $subject = jQuery('#mail-subject').val();
var $body = jQuery('#mail-body').val();
if ($subject == '') {
alert("<?php echo vmText::('COM_VIRTUEMART_PRODUCT_EMAIL_ENTER_SUBJECT')?>");
}
else if ($body == '') {
alert("<?php echo vmText::('COM_VIRTUEMART_PRODUCT_EMAIL_ENTER_BODY')?>");
}
else {
var $statut = jQuery('select#order_status').val();
jQuery.post($customerMailLink, { subject:$subject, mailbody:$body, statut:$statut, token:'<?php echo JSession::getFormToken() ?>' },


To look like the section below. The changes are not as bad as they look. You are simply moving one line up to the top of the input validation tests, and then adding one more validation test before calling the mail link.


else if (email_type == 'customer') {
var $subject = jQuery('#mail-subject').val();
var $body = jQuery('#mail-body').val();
var $statut = jQuery('select#order_status').val();
if ($subject == '') {
alert("<?php echo vmText::('COM_VIRTUEMART_PRODUCT_EMAIL_ENTER_SUBJECT')?>");
}
else if ($body == '') {
alert("<?php echo vmText::('COM_VIRTUEMART_PRODUCT_EMAIL_ENTER_BODY')?>");
}
else if ($statut == null) {
alert("<?php echo vmText::('COM_VIRTUEMART_PRODUCT_SELECT_ORDER_STATUS')?>");
} else {
jQuery.post($customerMailLink, { subject:$subject, mailbody:$body, statut:$statut, token:'<?php echo JSession::getFormToken() ?>' },


4) /administrator/components/com_virtuemart/models/product.php

Change line 2571, fix the bug and change from:

$order_states = vRequest::getInt ('statut');

To:

$order_states = vRequest::getVar ('statut');

Around line 2586, change this:

$vars['user'] = $productShopper['name'];

To this:


$vars['user'] = $productShopper['name'];
$vars['order_number'] = $productShopper['order_number'];
$vars['order_pass'] = $productShopper['order_pass'];


Around the original line 2621, modify the SQL statment to include o.order_pass like this:

$q = 'SELECT ou.* , oi.product_quantity , o.order_number, o.order_pass, o.order_status, oi.`order_status` AS order_item_status ,

Around the original line 2642, add two new lines here - from this:

$shoppers[$key]['nb_orders'] = 0;

To this:


$shoppers[$key]['nb_orders'] = 0;
$shoppers[$key]['order_number'] = $productShopper['order_number'];
$shoppers[$key]['order_pass'] = $productShopper['order_pass'];


Around the origina line 2646, add one new line, from this:

$shoppers[$key]['order_info'][$i]['order_id'] = $productShopper['virtuemart_order_id'];


To this:


$shoppers[$key]['order_info'][$i]['order_id'] = $productShopper['virtuemart_order_id'];
$shoppers[$key]['order_info'][$i]['order_pass'] = $productShopper['order_pass'];



5) /components/com_virtuemart/helpers/shopfunctionsf.php

Around line 581, change this:

$mailer->setSubject(  html_entity_decode( $subject) );

To this:

$mailer->setSubject( html_entity_decode( $subject, ENT_QUOTES ) );


6) /components/com_virtuemart/views/productdetails/tmpl/mail_html_notify.php

Add these line somewhere near the footer of the template to display the order link.


if (!empty($this->order_number) && !empty($this->order_pass)) {
echo '<br/><br/>';
$link = JURI::root().'index.php?option=com_virtuemart&view=orders&layout=details&order_number='.$this->order_number.'&order_pass='.$this->order_pass.' ';
echo vmText::_('COM_VIRTUEMART_CART_ORDER_INFO') . '<a href="'.$link.'">'.$this->order_number.'</a>';
}