I was wondering, is there any option to setup so that when a product is out of stock, I will be notified by email? It would be handy if I was away and checking my emails.
Thank you very much for this great shopping cart software. I left zencart, because of its ugly design and hard to configure admin options. This software is a piece of art.
Thank you very much for this great shopping cart software. I left zencart, because of its ugly design and hard to configure admin options. This software is a piece of art.
1. EDIT: catalog/model/checkout/order.php
2. FIND:
3. AFTER, ADD:
2. FIND:
Code: Select all
$this->db->query("UPDATE " . DB_PREFIX . "product SET quantity = (quantity - " . (int)$product['quantity'] . ") WHERE product_id = '" . (int)$product['product_id'] . "'");
Code: Select all
//Q: Alert store owner on low stock
$qry = $this->db->query("SELECT quantity, model FROM " . DB_PREFIX . "product WHERE product_id = '" . (int)$product['product_id'] . "'");
if ($qry->row['quantity'] < 2) {
$mail = new Mail($this->config->get('config_mail_protocol'), $this->config->get('config_smtp_host'), $this->config->get('config_smtp_username'), html_entity_decode($this->config->get('config_smtp_password'), ENT_QUOTES, 'UTF-8'), $this->config->get('config_smtp_port'), $this->config->get('config_smtp_timeout'));
$mail->setTo($this->config->get('config_email'));
$mail->setFrom($this->config->get('config_email'));
$mail->setSender(html_entity_decode($this->config->get('config_store'), ENT_QUOTES, 'UTF-8'));
$mail->setSubject('Low Stock on model: '. $qry->row['model']);
$mail->setText('Low Stock on model: '. $qry->row['model']);
$mail->send();
}
//
Mate here the problem I see.
1. Code is triggred everytime some one orders a product and sends email if product is less than 2
Looks like you need to change the code a little. I am no php king but getting into code because of our friend Open Cart
>>Should only trigger once when the quantity reaches two. Give it a try and let me know how you go.
1. Code is triggred everytime some one orders a product and sends email if product is less than 2
Looks like you need to change the code a little. I am no php king but getting into code because of our friend Open Cart

Code: Select all
//Q: Alert store owner on low stock
$qry = $this->db->query("SELECT quantity, model FROM " . DB_PREFIX . "product WHERE product_id = '" . (int)$product['product_id'] . "'");
if ($qry->row['quantity'] [color=#FF0000][b]==[/b][/color] 2) {
$mail = new Mail($this->config->get('config_mail_protocol'), $this->config->get('config_smtp_host'), $this->config->get('config_smtp_username'), html_entity_decode($this->config->get('config_smtp_password'), ENT_QUOTES, 'UTF-8'), $this->config->get('config_smtp_port'), $this->config->get('config_smtp_timeout'));
$mail->setTo($this->config->get('config_email'));
$mail->setFrom($this->config->get('config_email'));
$mail->setSender(html_entity_decode($this->config->get('config_store'), ENT_QUOTES, 'UTF-8'));
$mail->setSubject('Low Stock on model: '. $qry->row['model']);
$mail->setText('Low Stock on model: '. $qry->row['model']);
$mail->send();
}
//
What is the difference between
(int)$result[] and (int)$product[]?
Because on your example its:
But on my OC1.3.2, its:
Thank you.
(int)$result[] and (int)$product[]?
Because on your example its:
Code: Select all
$this->db->query("UPDATE " . DB_PREFIX . "product SET quantity = (quantity - " . (int)$product['quantity'] . ") WHERE product_id = '" . (int)$product['product_id'] . "'");
Code: Select all
$this->db->query("UPDATE " . DB_PREFIX . "product SET quantity = (quantity - " . (int)$result['quantity'] . ") WHERE product_id = '" . (int)$result['product_id'] . "'");
I am using V1.4.4. There may have been some changes in DB since your version. Did you make any head way on the issue getting several emails. Also I just noticed the mailing logic goes inside 'for loop' you may get more than one emails.
Let me know how you go.
Let me know how you go.
Sorry old thread, but i made a quick vqmod for 1.5 for this:
http://forum.opencart.com/viewtopic.php ... 54&start=0
http://forum.opencart.com/viewtopic.php ... 54&start=0
Who is online
Users browsing this forum: No registered users and 12 guests