Hi.
I'm having problems with the low stock notification email. The email is being sent ok, and received by the vendor. But it doesnt tell the vendor what the product is :
The email is coming through with the subject as : COM_VIRTUEMART_PRODUCT_LOW_STOCK_EMAIL_SUBJECT
and the email body just has written in it : COM_VIRTUEMART_PRODUCT_LOW_STOCK_EMAIL_BODY
So the vendor has no idea which product the email is referring to.
Website is : www.bluefrogtoys.co.uk
Joomla: 2.5.27
VM: 2.6.6
thanks for looking
You should be on 2.6.10 minimum.. http://virtuemart.net/news/latest-news/462-security-release-of-vm2-6-10-and-vm2-9-9b
don't know why your lang constants aren't there but should be
COM_VIRTUEMART_PRODUCT_LOW_STOCK_EMAIL_BODY="The product %s has a stock of %d."
COM_VIRTUEMART_PRODUCT_LOW_STOCK_EMAIL_SUBJECT="The product %s has a low stock"
Ok thanks i have upgraded now to 2.6.10
perhaps i should have looked at the language file before and after upgrading but the file en-GB.com_virtuemart.ini does contain
COM_VIRTUEMART_PRODUCT_LOW_STOCK_EMAIL_BODY="The product %s has a stock of %d."
COM_VIRTUEMART_PRODUCT_LOW_STOCK_EMAIL_SUBJECT="The product %s has a low stock"
is there anything else that might stop the emails sending correctly ?
no idea - you need to have a poke around in function lowStockWarningEmail($virtuemart_product_id)
admin models/product.php ~ line 2366
Mm thanks i can poke around but i wont know what im looking at. This is the code around that section - can you tell me if anything looks wrong ?
// vmdebug( 'stockupdate in DB', $product->virtuemart_product_id,$amount, $signInStock, $signOrderedStock );
$validFields = array('=', '+', '-');
if (!in_array ($signInStock, $validFields)) {
return FALSE;
}
if (!in_array ($signOrderedStock, $validFields)) {
return FALSE;
}
//sanitize fields
$id = (int)$product->virtuemart_product_id;
$amount = (float)$amount;
$update = array();
if ($signInStock != '=' or $signOrderedStock != '=') {
if ($signInStock != '=') {
$update[] = '`product_in_stock` = `product_in_stock` ' . $signInStock . $amount;
if (strpos ($signInStock, '+') !== FALSE) {
$signInStock = '-';
}
else {
$signInStock = '+';
}
$update[] = '`product_sales` = `product_sales` ' . $signInStock . $amount;
}
if ($signOrderedStock != '=') {
$update[] = '`product_ordered` = `product_ordered` ' . $signOrderedStock . $amount;
}
$q = 'UPDATE `#__virtuemart_products` SET ' . implode (", ", $update) . ' WHERE `virtuemart_product_id` = ' . $id;
$this->_db->setQuery ($q);
$this->_db->query ();
//The low on stock notification comes now, when the people ordered.
//You need to know that the stock is going low before you actually sent the wares, because then you ususally know it already yoursefl
//note by Max Milbers
if ($signInStock == '+') {
$this->_db->setQuery ('SELECT (IFNULL(`product_in_stock`,"0")+IFNULL(`product_ordered`,"0")) < IFNULL(`low_stock_notification`,"0") '
. 'FROM `#__virtuemart_products` '
. 'WHERE `virtuemart_product_id` = ' . $id
);
if ($this->_db->loadResult () == 1) {
$this->lowStockWarningEmail( $id) ;
}
}
}
}
function lowStockWarningEmail($virtuemart_product_id) {
if(VmConfig::get('lstockmail',TRUE)){
if (!class_exists ('shopFunctionsF')) {
require(JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php');
}
/* Load the product details */
$q = "SELECT l.product_name,product_in_stock FROM `#__virtuemart_products_" . VMLANG . "` l
JOIN `#__virtuemart_products` p ON p.virtuemart_product_id=l.virtuemart_product_id
WHERE p.virtuemart_product_id = " . $virtuemart_product_id;
$this->_db->setQuery ($q);
$vars = $this->_db->loadAssoc ();
$url = JURI::root () . 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $virtuemart_product_id;
$link = '<a href="'. $url.'">'. $vars['product_name'].'</a>';
$vars['subject'] = JText::sprintf('COM_VIRTUEMART_PRODUCT_LOW_STOCK_EMAIL_SUBJECT',$vars['product_name']);
$vars['mailbody'] =JText::sprintf('COM_VIRTUEMART_PRODUCT_LOW_STOCK_EMAIL_BODY',$link, $vars['product_in_stock']);
$virtuemart_vendor_id = 1;
$vendorModel = VmModel::getModel ('vendor');
$vendor = $vendorModel->getVendor ($virtuemart_vendor_id);
$vendorModel->addImages ($vendor);
$vars['vendor'] = $vendor;
$vars['vendorAddress']= shopFunctions::renderVendorAddress($virtuemart_vendor_id);
$vars['vendorEmail'] = $vendorModel->getVendorEmail ($virtuemart_vendor_id);
$vars['user'] = $vendor->vendor_store_name ;
shopFunctionsF::renderMail ('productdetails', $vars['vendorEmail'], $vars, 'productdetails', TRUE) ;
return TRUE;
} else {
return FALSE;
}
}
it can't be wrong or there would be 50 other posts on here complaining that it didn't work
therefore it is specific to your install --
by poke around I meant work out what in that function isn't working for you - is the lang being loaded etc?