You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Today I had to sent an email to customers who had purchased one product. Guess what happened? The same email was sent 488 times to each customer (488 customers). My luck was that I stopped the process and email was sent only 14 times. How cool is to open your inbox and to find same email received hundreds of times? No so cool. Gmail thinks the same and blacklisted my website IP. Who's going to help me to remove my IP from blacklist now?
Anyway, the problem was on "admin/model/sale/order.php" and can be fixed by replacing this function:
public function getEmailsByProductsOrdered($products, $start, $end) {
$implode = array();
foreach ($products as $product_id) {
$implode[] = "op.product_id = '" . $product_id . "'";
}
$query = $this->db->query("SELECT DISTINCT email FROM `" . DB_PREFIX . "order` o LEFT JOIN " . DB_PREFIX . "order_product op ON (o.order_id = op.order_id) WHERE (" . implode(" OR ", $implode) . ") AND o.order_status_id <> '0'");
return $query->rows;
}
with this function
public function getEmailsByProductsOrdered($products, $start, $end) {
$implode = array();
foreach ($products as $product_id) {
$implode[] = "op.product_id = '" . $product_id . "'";
}
if(!empty($start) && !empty($end)){
$limit = " LIMIT ".$start.",".$end;
}
$query = $this->db->query("SELECT DISTINCT email FROM `" . DB_PREFIX . "order` o LEFT JOIN " . DB_PREFIX . "order_product op ON (o.order_id = op.order_id) WHERE (" . implode(" OR ", $implode) . ") AND o.order_status_id <> '0'".$limit);
return $query->rows;
}
The text was updated successfully, but these errors were encountered:
I have v1.5.2.1 but maybe you have to take a look again at your own script, because this is what I found on v1.5.6.1, at the file "admin/model/sale/order.php", downloaded from opencart.com, more exactly take a look at lines 782 - 792 and see if everything seems to be ok:
public function getEmailsByProductsOrdered($products, $start, $end) {
$implode = array();
foreach ($products as $product_id) {
$implode[] = "op.product_id = '" . $product_id . "'";
}
$query = $this->db->query("SELECT DISTINCT email FROM `" . DB_PREFIX . "order` o LEFT JOIN " . DB_PREFIX . "order_product op ON (o.order_id = op.order_id) WHERE (" . implode(" OR ", $implode) . ") AND o.order_status_id <> '0'");
return $query->rows;
}
Also, on the same file (in v1.5.6.1), next function is this:
public function getTotalEmailsByProductsOrdered($products) {
$implode = array();
foreach ($products as $product_id) {
$implode[] = "op.product_id = '" . $product_id . "'";
}
$query = $this->db->query("SELECT DISTINCT email FROM `" . DB_PREFIX . "order` o LEFT JOIN " . DB_PREFIX . "order_product op ON (o.order_id = op.order_id) WHERE (" . implode(" OR ", $implode) . ") AND o.order_status_id <> '0' LIMIT " . $start . "," . $end);
return $query->row['total'];
}
Today I had to sent an email to customers who had purchased one product. Guess what happened? The same email was sent 488 times to each customer (488 customers). My luck was that I stopped the process and email was sent only 14 times. How cool is to open your inbox and to find same email received hundreds of times? No so cool. Gmail thinks the same and blacklisted my website IP. Who's going to help me to remove my IP from blacklist now?
Anyway, the problem was on "admin/model/sale/order.php" and can be fixed by replacing this function:
with this function
The text was updated successfully, but these errors were encountered: