public static function sendMailVmemPro($viewName, $recipient, $vars = array(), $controllerName = NULL, $noVendorMail = FALSE,$useDefault=true) {
self::loadOrderLanguages();
$view = self::prepareViewForMail($viewName, $vars, $controllerName);
//VMEEPRO START
$user = true;
$vmempro_args = array();
$vmempro_trigger = array();
switch ($viewName){
//order confirmation, order change status
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 'productdetails':
case 'waitinglist':
$urlPArams = parse_url($vars['link'],PHP_URL_QUERY);
parse_str($urlPArams);
$vmempro_args['product_id'] = (int)$virtuemart_product_id;
$vmempro_args['email'] = $recipient;
if(!is_null($vars['user'])){
$vmempro_args['user_name'] = $vars['user'];
}
$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'] = JFactory::getApplication()->input->get('comment', '','RAW');
$vmempro_trigger[] = array('trigger'=>'TRIGGER_RECOMMEND','type'=>'user');*/
break;
default:
break;
}
if(!empty($vmempro_trigger)){
if((isset($vars['newOrderData']['customer_notified']) && $vars['newOrderData']['customer_notified']==1) || (!isset($vars['newOrderData']) && $viewName != 'invoice')){
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);
}
}
}
}
}
return $user;
//VMEEPRO END
}