Hi.
I have many orders placed using coupon codes. I need to find a few specific one's which were used.
Is there a way I can search for the order using the Discount Code that they used to find which order and to whom.
Thank you
Don't believe there is an extension. You can have someone dev this for you. You would need to alter all 3 files Model,view,and control. Very doable by just adding on to what is already there.
Here is a little bit of how you would start the model file to get what you want:
In admin: admin/model/sale/order.php find this function
You will be adding to what is already here. You first would need to join the coupon_history table using order_id for ON()
This will allow you to get the coupon code and use it to run searches because it's tied to an order_id.
All that is left to do now is create another condition/AND procedure similar to what is already there:
Here is a little bit of how you would start the model file to get what you want:
In admin: admin/model/sale/order.php find this function
Code: Select all
public function getOrders($data = array()) {
$sql = "SELECT o.order_id, CONCAT(o.firstname, ' ', o.lastname) AS customer, (SELECT os.name FROM " . DB_PREFIX . "order_status os WHERE os.order_status_id = o.order_status_id AND os.language_id = '" . (int)$this->config->get('config_language_id') . "') AS status, o.total, o.currency_code, o.currency_value, o.date_added, o.date_modified FROM `" . DB_PREFIX . "order` o";
if (isset($data['filter_order_status_id']) && !is_null($data['filter_order_status_id'])) {
$sql .= " WHERE o.order_status_id = '" . (int)$data['filter_order_status_id'] . "'";
} else {
$sql .= " WHERE o.order_status_id > '0'";
}
if (!empty($data['filter_order_id'])) {
$sql .= " AND o.order_id = '" . (int)$data['filter_order_id'] . "'";
}
if (!empty($data['filter_customer'])) {
$sql .= " AND LCASE(CONCAT(o.firstname, ' ', o.lastname)) LIKE '" . $this->db->escape(utf8_strtolower($data['filter_customer'])) . "%'";
}
if (!empty($data['filter_date_added'])) {
$sql .= " AND DATE(o.date_added) = DATE('" . $this->db->escape($data['filter_date_added']) . "')";
}
if (!empty($data['filter_total'])) {
$sql .= " AND o.total = '" . (float)$data['filter_total'] . "'";
}
$sort_data = array(
'o.order_id',
'customer',
'status',
'o.date_added',
'o.date_modified',
'o.total'
);
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
$sql .= " ORDER BY " . $data['sort'];
} else {
$sql .= " ORDER BY o.order_id";
}
if (isset($data['order']) && ($data['order'] == 'DESC')) {
$sql .= " DESC";
} else {
$sql .= " ASC";
}
if (isset($data['start']) || isset($data['limit'])) {
if ($data['start'] < 0) {
$data['start'] = 0;
}
if ($data['limit'] < 1) {
$data['limit'] = 20;
}
$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
}
$query = $this->db->query($sql);
return $query->rows;
}
This will allow you to get the coupon code and use it to run searches because it's tied to an order_id.
All that is left to do now is create another condition/AND procedure similar to what is already there:
Code: Select all
if (isset($data['filter_order_id']) && !is_null($data['filter_order_id'])) {
$sql .= " AND o.order_id = '" . (int)$data['filter_order_id'] . "'";
}
Who is online
Users browsing this forum: No registered users and 21 guests