Hello, OPC and VMEE works without any known issues. The VMEE sends emails by the function mentioned above and please make sure that if you updated your VM, you also updated the VMEE code in the function.
You have to set up proper filters for the emails, such as order statuses, shopper groups and similar so they are triggered. Keep in mind, that OPC uses both -anonymous- and -default- shopper groups and this can be altered in the OPC backend configuration.
This is how your renderMail function should look like in /components/com_virtuemart/helpers/shopfunctionsf.php
- Code: Select all
/**
* Prepares a view for rendering email, then renders and sends
*
* @param object $controller
* @param string $viewName View which will render the email
* @param string $recipient shopper@whatever.com
* @param array $vars variables to assign to the view
*/
//TODO this is quirk, why it is using here $noVendorMail, but everywhere else it is using $doVendor => this make logic trouble
static public function renderMail ($viewName, $recipient, $vars=array(),$controllerName = NULL,$noVendorMail = FALSE) {
if(!class_exists('VirtueMartControllerVirtuemart')) require(JPATH_VM_SITE.DS.'controllers'.DS.'virtuemart.php');
// $format = (VmConfig::get('order_html_email',1)) ? 'html' : 'raw';
$lang = JFactory::getLanguage();
$tag = $lang->getTag();
$filename = 'com_virtuemart';
$lang->load($filename, JPATH_ADMINISTRATOR, $tag, true);
$lang->load($filename, JPATH_SITE, $tag, true);
$controller = new VirtueMartControllerVirtuemart();
//Todo, do we need that? refering to http://forum.virtuemart.net/index.php?topic=96318.msg317277#msg317277
$controller->addViewPath(JPATH_VM_SITE.DS.'views');
$view = $controller->getView($viewName, 'html');
if (!$controllerName) $controllerName = $viewName;
$controllerClassName = 'VirtueMartController'.ucfirst ($controllerName) ;
if (!class_exists($controllerClassName)) require(JPATH_VM_SITE.DS.'controllers'.DS.$controllerName.'.php');
//Todo, do we need that? refering to http://forum.virtuemart.net/index.php?topic=96318.msg317277#msg317277
$view->addTemplatePath(JPATH_VM_SITE.'/views/'.$viewName.'/tmpl');
$vmtemplate = VmConfig::get('vmtemplate','default');
if($vmtemplate=='default'){
if(JVM_VERSION == 2){
$q = 'SELECT `template` FROM `#__template_styles` WHERE `client_id`="0" AND `home`="1"';
} else {
$q = 'SELECT `template` FROM `#__templates_menu` WHERE `client_id`="0" AND `menuid`="0"';
}
$db = JFactory::getDbo();
$db->setQuery($q);
$template = $db->loadResult();
} else {
$template = $vmtemplate;
}
if($template){
$view->addTemplatePath(JPATH_ROOT.DS.'templates'.DS.$template.DS.'html'.DS.'com_virtuemart'.DS.$viewName);
} else {
if(isset($db)){
$err = $db->getErrorMsg() ;
} else {
$err = 'The selected vmtemplate is not existing';
}
if($err) vmError('renderMail get Template failed: '.$err);
}
foreach ($vars as $key => $val) {
$view->$key = $val;
}
//VMEEPRO START
$user = true;
$vmempro_args = array();
$vmempro_trigger = array();
switch ($viewName){
//order confirmation, order change status, order download ID
case 'invoice':
$vmempro_args['order_id'] = $vars['orderDetails']['details']['BT']->virtuemart_order_id;
if( isset($vars['newOrderData']['order_status']) &&
isset($vars['newOrderData']['current_order_status']) &&
count( $vars['orderDetails']['history']) > 2){
//indication that this is status changed
$vmempro_trigger[] = array('trigger'=>'TRIGGER_ORDER_STATUS_CHANGED','type'=>'user');
if (isset($view->doVendor) && !$noVendorMail) {
$vmempro_trigger[] = array('trigger'=>'TRIGGER_ADMIN_ORDER_STATUS_CHANGED','type'=>'admin');
}
}
else{
//new order
$vmempro_trigger[] = array('trigger'=>'TRIGGER_ORDER_CONFIRMATION','type'=>'user');
if (isset($view->doVendor) && !$noVendorMail) {
$vmempro_trigger[] = array('trigger'=>'TRIGGER_ADMIN_ORDER_CONFIRMATION','type'=>'admin');
}
}
break;
//user registration
case 'user':
$vmempro_args['user_name'] = $vars['user']->username;
$vmempro_args['password'] = $vars['password'];
$vmempro_trigger[] = array('trigger'=>'TRIGGER_USER_REGISTRATION','type'=>'user');
if (isset($view->doVendor) && !$noVendorMail) {
$vmempro_trigger[] = array('trigger'=>'TRIGGER_ADMIN_USER_REGISTRATION','type'=>'admin');
}
break;
//notify customer that product is back in stock
case 'waitinglist':
$urlPArams = parse_url($vars['url'],URL_QUERY);
parse_str($urlPArams);
$vmempro_args['product_id'] = $virtuemart_product_id;
$vmempro_args['user_id'] = $vars['user']->id;
$vmempro_trigger[] = array('trigger'=>'TRIGGER_WAITING_LIST','type'=>'user');
if (isset($view->doVendor) && !$noVendorMail) {
$vmempro_trigger[] = array('trigger'=>'TRIGGER_ADMIN_WAITING_LIST','type'=>'admin');
}
break;
//ask question about product
case 'vendor':
break;
// ask question email
case 'askquestion':
break;
//recommend product to a friend
case 'recommend':
/*$vmempro_args['product_id'] = $vars['product']->virtuemart_product_id;
$vmempro_args['user_name'] = $vars['user']['name'];
$vmempro_args['user_email'] = $vars['user']['email'];
$vmempro_args['to_mail'] = $recipient;
$vmempro_args['message'] = JRequest::getVar('comment', '');
$vmempro_trigger[] = array('trigger'=>'TRIGGER_RECOMMEND','type'=>'user');*/
break;
default:
break;
}
if(!empty($vmempro_trigger)){
JPluginHelper::importPlugin('vmeepro');
$dispatcher =& JDispatcher::getInstance();
foreach ($vmempro_trigger as $trigger){
$res = $dispatcher->trigger('OnSendMail', array($trigger['trigger'],$vmempro_args));
if($res[0] === false){
if ($trigger['type'] == 'admin') {
self::sendVmMail($view, $view->vendorEmail, true);
}
else{
$user= self::sendVmMail($view, $recipient,$noVendorMail);
}
}
}
}
else{
$user= self::sendVmMail($view, $recipient,$noVendorMail);
if (isset($view->doVendor) && !$noVendorMail) {
self::sendVmMail($view, $view->vendorEmail, true);
}
}
//VMEEPRO END
/*
$user= self::sendVmMail($view, $recipient,$noVendorMail);
if (isset($view->doVendor) && !$noVendorMail) {
self::sendVmMail($view, $view->vendorEmail, TRUE);
}
*/
$lang = JFactory::getLanguage();
$tag = $lang->getTag();
$filename = 'com_virtuemart';
$lang->load($filename, JPATH_ADMINISTRATOR, $tag, true);
$lang->load($filename, JPATH_SITE, $tag, true);
return $user ;
}
If this is set up correctly, the OPC does not alter this function no way. The code above fixes a VMEE bug which changes language to english when you are using any other language in your joomla front end.
Best Regards,
Stan