Пытаюсь подружить два модуля Customer Group Discounts и Customer Group Auto Switcher with email alert
Версия Opencart 1.5.1.3
Изначально возникли следующие ошибки (настройки модуля Customer Group Auto Switcher with email alert вообще не отображались):
2012-07-11 11:00:08 - PHP Notice: Undefined index: reach_customer_group_id in /home/s/snabvlzru/public_html/vqmod/vqcache/vq2-admin_controller_sale_customer_group.php on line 198
2012-07-11 11:00:08 - PHP Notice: Undefined index: reach_value in /home/s/snabvlzru/public_html/vqmod/vqcache/vq2-admin_controller_sale_customer_group.php on line 210
2012-07-11 11:00:08 - PHP Notice: Undefined index: reach_value in /home/s/snabvlzru/public_html/vqmod/vqcache/vq2-admin_controller_sale_customer_group.php on line 211
2012-07-11 11:00:08 - PHP Notice: Undefined index: reach_customer_group_id in /home/s/snabvlzru/public_html/vqmod/vqcache/vq2-admin_controller_sale_customer_group.php on line 198
2012-07-11 11:00:08 - PHP Notice: Undefined index: reach_value in /home/s/snabvlzru/public_html/vqmod/vqcache/vq2-admin_controller_sale_customer_group.php on line 210
2012-07-11 11:00:08 - PHP Notice: Undefined index: reach_value in /home/s/snabvlzru/public_html/vqmod/vqcache/vq2-admin_controller_sale_customer_group.php on line 211
2012-07-11 11:00:08 - PHP Notice: Undefined index: reach_customer_group_id in /home/s/snabvlzru/public_html/vqmod/vqcache/vq2-admin_controller_sale_customer_group.php on line 198
2012-07-11 11:00:08 - PHP Notice: Undefined index: reach_value in /home/s/snabvlzru/public_html/vqmod/vqcache/vq2-admin_controller_sale_customer_group.php on line 210
2012-07-11 11:00:08 - PHP Notice: Undefined index: reach_value in /home/s/snabvlzru/public_html/vqmod/vqcache/vq2-admin_controller_sale_customer_group.php on line 211
Покопавшись в xml файлах модулей увидел, что оба модуля меняют одни и те же строки в admin/model/sale/customer_group.php:
в xml файле Customer Group Discounts:
<operation>
<search position="replace"><![CDATA[customer_group SET]]></search>
<add><![CDATA[customer_group SET discount = '" . (($data['discount'] != '') ? (float)$data['discount'] : '') . "',]]></add>
</operation>
в xml файле Customer Group Auto Switcher:
<operation>
<search position="replace"><![CDATA[$this->db->query("INSERT INTO " . DB_PREFIX . "customer_group SET name = '" . $this->db->escape($data['name']) . "'");]]></search>
<add><![CDATA[$this->db->query("INSERT INTO " . DB_PREFIX . "customer_group SET name = '" . $this->db->escape($data['name']) . "', reach_value = '" . (float)($data['reach_value']) . "', reach_customer_group_id = '" . (int)($data['reach_customer_group_id']) . "', reach_order_status_id = '" . (int)($data['reach_order_status_id']) . "', admin_notify = '" . (isset($data['admin_notify']) ? (int)$data['admin_notify'] : 0) . "', customer_notify = '" . (isset($data['customer_notify']) ? (int)$data['customer_notify'] : 0) . "'");]]></add>
</operation>
<operation>
<search position="replace"><![CDATA[$this->db->query("UPDATE " . DB_PREFIX . "customer_group SET name = '" . $this->db->escape($data['name']) . "' WHERE customer_group_id = '" . (int)$customer_group_id . "'");]]></search>
<add><![CDATA[$this->db->query("UPDATE " . DB_PREFIX . "customer_group SET name = '" . $this->db->escape($data['name']) . "', reach_value = '" . (float)($data['reach_value']) . "', reach_customer_group_id = '" . (int)($data['reach_customer_group_id']) . "', reach_order_status_id = '" . (int)($data['reach_order_status_id']) . "', admin_notify = '" . (isset($data['admin_notify']) ? (int)$data['admin_notify'] : 0) . "', customer_notify = '" . (isset($data['customer_notify']) ? (int)$data['customer_notify'] : 0) . "' WHERE customer_group_id = '" . (int)$customer_group_id . "'");]]></add>
</operation>
Я удалил коды из обоих файлов, а вместо этого изменил вручну стандартный код движка (файл admin/model/sale/customer_group.php) на:
public function addCustomerGroup($data) {
$this->db->query("INSERT INTO " . DB_PREFIX . "customer_group SET name = '" . $this->db->escape($data['name']) . "', discount = '" . (($data['discount'] != '') ? (float)$data['discount'] : '') . "' , reach_value = '" . (float)($data['reach_value']) . "', reach_customer_group_id = '" . (int)($data['reach_customer_group_id']) . "', reach_order_status_id = '" . (int)($data['reach_order_status_id']) . "', admin_notify = '" . (isset($data['admin_notify']) ? (int)$data['admin_notify'] : 0) . "', customer_notify = '" . (isset($data['customer_notify']) ? (int)$data['customer_notify'] : 0) . "'");
$this->cache->delete('product');
}
public function editCustomerGroup($customer_group_id, $data) {
$this->db->query("UPDATE " . DB_PREFIX . "customer_group SET name = '" . $this->db->escape($data['name']) . "', discount = '" . (($data['discount'] != '') ? (float)$data['discount'] : '') . "', reach_value = '" . (float)($data['reach_value']) . "', reach_customer_group_id = '" . (int)($data['reach_customer_group_id']) . "', reach_order_status_id = '" . (int)($data['reach_order_status_id']) . "', admin_notify = '" . (isset($data['admin_notify']) ? (int)$data['admin_notify'] : 0) . "', customer_notify = '" . (isset($data['customer_notify']) ? (int)$data['customer_notify'] : 0) . "' WHERE customer_group_id = '" . (int)$customer_group_id . "'");
$this->cache->delete('product');
}
На всякий случай вот стандартный код:
public function addCustomerGroup($data) {
$this->db->query("INSERT INTO " . DB_PREFIX . "customer_group SET name = '" . $this->db->escape($data['name']) . "'");
}
public function editCustomerGroup($customer_group_id, $data) {
$this->db->query("UPDATE " . DB_PREFIX . "customer_group SET name = '" . $this->db->escape($data['name']) . "' WHERE customer_group_id = '" . (int)$customer_group_id . "'");
}
Выше описанные ошибки исчезли. В группах покупателей могу задать скидки/наценки и порог после которого следует переводить покупателя в другую группу.
Пробую сделать заказ - всё до последнего этапа работает нормально. При нажатии кнопки "Оформить заказ" появляется ошибка:
2012-07-11 13:12:34 - PHP Notice: Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order WHERE customer_id = '2' AND order_status_id = '5'' at line 1<br />Error No: 1064<br />SELECT total FROM order WHERE customer_id = '2' AND order_status_id = '5' in /home/s/snabvlzru/public_html/system/database/mysql.php on line 49
При этом заказ магазин принимает, но покупателя в другую группу не переводит.
О чём говорит ошибка и как можно это исправить? Может быть где-то попутал с точками, запятыми, кавычками?