VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: servlet on March 29, 2014, 09:33:33 AM

Title: Different confirmation mail for different shopperer group
Post by: servlet on March 29, 2014, 09:33:33 AM
Is there a way to send different confirmation mail for different shopperer group?
Title: Re: Different confirmation mail for different shopperer group
Post by: K&K media production on March 29, 2014, 12:59:50 PM
You can write a own override with a if request to the shoppergroup and then load different layout files.
Title: Re: Different confirmation mail for different shopperer group
Post by: servlet on March 29, 2014, 13:49:56 PM
Thank you for replay.
I can write 2 html templates but I cannt write php if request.
If someone have a time to do it...
Title: Re: Different confirmation mail for different shopperer group
Post by: K&K media production on March 29, 2014, 19:12:09 PM
add this to your mail_html.php to load different template overrides:


$shopperGroupModel = VmModel::getModel('shoppergroup');
$shopperGroups = $shopperGroupModel->getShoppergroupById($this->orderDetails['details']['BT']->virtuemart_user_id);
$shopperGroupArray = array();
foreach($shopperGroups as $shopperGroup) {
$shopperGroupArray[] = $shopperGroup['virtuemart_shoppergroup_id'];
}

if (in_array('2', $shopperGroupArray)) {
echo $this->loadTemplate('shopperaddresses2');
} else {
echo $this->loadTemplate('shopperaddresses1');
}


In this example the script is looking if the user is in shopper group with ID 2. If it's true, the view "shopperaddresses2" will be displayed, else "shoppergroup1".

To test your mails without sending a mail use this url and replace the orderID and orderpass with one existing order from your shop

index.php?option=com_virtuemart&view=invoice&layout=mail_html&order_number=xxxxxxx&order_pass=p_xxxxx&tmpl=component