I am fairly new to open cart and have some experience in WooCommerce and pretty general knowledge of PHP, HTML, etc. I am looking into creating a simple script that would, ideally, look at a customers order history and add a comment to their order if they have not ordered in the last 6 months. It sounds simple enough but I'm not totally sure what the best course of action would be to achieve this.
Thanks in advance and sorry if this is a stupid question!
Yes is possible.
You can do that in Customer Orders Report
Opencart Developer - For custom work and support contact @ webcorvo@gmail.com
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
webcorvo@gmail.com
Opencart Developer - For custom work and support contact @ webcorvo@gmail.com
in your catalog/model/checkout/order.php file,
find:
Code: Select all
// If old order status is the processing or complete status but new status is not then commence restock, and remove coupon, voucher and reward history
Code: Select all
$order_period = $this->db->query("SELECT `order_id` FROM `" . DB_PREFIX . "order` WHERE `date_modified` > DATE_SUB(now(), INTERVAL 6 MONTH) AND `order_period_comment` = '0' AND `order_id` = '" . (int)$order_id . "'");
if ($order_period->num_rows) {
$this->db->query("INSERT INTO " . DB_PREFIX . "order_history SET order_id = '" . (int)$order_id . "', order_status_id = '" . (int)$order_status_id . "', notify = '" . (int)$notify . "', `comment` = 'More than 6 months', date_added = NOW()");
$this->db->query("UPDATE `" . DB_PREFIX . "order` SET `order_period_comment` = '1' WHERE `order_id` = '" . (int)$order_id . "'");
}
Then, in your PHPMyAdmin, on your order table, go to the SQL tab and execute the following query:
Code: Select all
ALTER TABLE `oc_order` ADD `order_period_comment` INT(1) NOT NULL DEFAULT '0';
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
straightlight wrote: ↑Sun Nov 12, 2017 1:42 amI see. Well, to automatically add a comment to the customer's order and able to see it from the admin order history,
in your catalog/model/checkout/order.php file,
find:
add above:Code: Select all
// If old order status is the processing or complete status but new status is not then commence restock, and remove coupon, voucher and reward history
The More than 6 months message can be changed to your preference.Code: Select all
$order_period = $this->db->query("SELECT `order_id` FROM `" . DB_PREFIX . "order` WHERE `date_modified` > DATE_SUB(now(), INTERVAL 6 MONTH) AND `order_period_comment` = '0' AND `order_id` = '" . (int)$order_id . "'"); if ($order_period->num_rows) { $this->db->query("INSERT INTO " . DB_PREFIX . "order_history SET order_id = '" . (int)$order_id . "', order_status_id = '" . (int)$order_status_id . "', notify = '" . (int)$notify . "', `comment` = 'More than 6 months', date_added = NOW()"); $this->db->query("UPDATE `" . DB_PREFIX . "order` SET `order_period_comment` = '1' WHERE `order_id` = '" . (int)$order_id . "'"); }
Then, in your PHPMyAdmin, on your order table, go to the SQL tab and execute the following query:
Note: Replace oc_ with your current database table prefix from the query before launching the query. This should resolve the request.Code: Select all
ALTER TABLE `oc_order` ADD `order_period_comment` INT(1) NOT NULL DEFAULT '0';
Opencart Developer - For custom work and support contact @ webcorvo@gmail.com
Code: Select all
$order_period = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order` WHERE `date_modified` > DATE_SUB(now(), INTERVAL 6 MONTH) AND `order_period_comment` = '0'");
if ($order_period->num_rows) {
foreach ($order_period->rows as $order_per) {
$this->db->query("INSERT INTO " . DB_PREFIX . "order_history SET order_id = '" . (int)$order_per['order_id'] . "', order_status_id = '" . (int)$order_per['order_status_id'] . "', notify = '0', `comment` = 'More than 6 months', date_added = NOW()");
$this->db->query("UPDATE `" . DB_PREFIX . "order` SET `order_period_comment` = '1' WHERE `order_id` = '" . (int)$order_per['order_id'] . "'");
}
}
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
In Customer Orders Reportstraightlight wrote: ↑Sun Nov 12, 2017 2:16 amIn addition, the admin reports can already indicate the date intervals within the same year which 6 months results should already appear by using the report filters.
Opencart Developer - For custom work and support contact @ webcorvo@gmail.com
Users browsing this forum: Amazon [Bot], Bing [Bot] and 430 guests