im using open cart 2.2 in my backend page "admin/index.php?route=common/dashboard" theres a table of recent_orders i also want to display the shipping_method(see attached pic).
i think this 2 file below that i needed to edit to get what im trying to do..
heres the recent.php] : came from admin/controler/dashboard
<?php
class ControllerDashboardRecent extends Controller {
public function index() {
$this->load->language('dashboard/recent');
$data['heading_title'] = $this->language->get('heading_title');
$data['text_no_results'] = $this->language->get('text_no_results');
$data['column_order_id'] = $this->language->get('column_order_id');
$data['column_customer'] = $this->language->get('column_customer');
$data['column_status'] = $this->language->get('column_status');
$data['column_date_added'] = $this->language->get('column_date_added');
$data['column_total'] = $this->language->get('column_total');
$data['column_action'] = $this->language->get('column_action');
$data['button_view'] = $this->language->get('button_view');
$data['token'] = $this->session->data['token'];
// Last 5 Orders
$data['orders'] = array();
$filter_data = array(
'sort' => 'o.date_added',
'order' => 'DESC',
'start' => 0,
'limit' => 5
);
$results = $this->model_sale_order->getOrders($filter_data);
foreach ($results as $result) {
$data['orders'][] = array(
'order_id' => $result['order_id'],
'customer' => $result['customer'],
'status' => $result['order_status'],
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
'total' => $this->currency->format($result['total'], $result['currency_code'], $result['currency_value']),
'view' => $this->url->link('sale/order/info', 'token=' . $this->session->data['token'] . '&order_id=' . $result['order_id'], true),
);
}
return $this->load->view('dashboard/recent', $data);
}
}
///////////////////////////////////////////////////////////////////////////////////////
Attachments
here its - 1.jpg (26.08 KiB) Viewed 3225 times
<?php
class ModelSaleOrder extends Model {
public function getOrder($order_id) {
$order_query = $this->db->query("SELECT *, (SELECT CONCAT(c.firstname, ' ', c.lastname) FROM " . DB_PREFIX . "customer c WHERE c.customer_id = o.customer_id) 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 order_status FROM `" . DB_PREFIX . "order` o WHERE o.order_id = '" . (int)$order_id . "'");
if ($order_query->num_rows) {
$country_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "country` WHERE country_id = '" . (int)$order_query->row['payment_country_id'] . "'");
if ($country_query->num_rows) {
$payment_iso_code_2 = $country_query->row['iso_code_2'];
$payment_iso_code_3 = $country_query->row['iso_code_3'];
} else {
$payment_iso_code_2 = '';
$payment_iso_code_3 = '';
}
$zone_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone` WHERE zone_id = '" . (int)$order_query->row['payment_zone_id'] . "'");
if ($zone_query->num_rows) {
$payment_zone_code = $zone_query->row['code'];
} else {
$payment_zone_code = '';
}
$country_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "country` WHERE country_id = '" . (int)$order_query->row['shipping_country_id'] . "'");
if ($country_query->num_rows) {
$shipping_iso_code_2 = $country_query->row['iso_code_2'];
$shipping_iso_code_3 = $country_query->row['iso_code_3'];
} else {
$shipping_iso_code_2 = '';
$shipping_iso_code_3 = '';
}
$zone_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone` WHERE zone_id = '" . (int)$order_query->row['shipping_zone_id'] . "'");
if ($zone_query->num_rows) {
$shipping_zone_code = $zone_query->row['code'];
} else {
$shipping_zone_code = '';
}
$reward = 0;
$order_product_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$order_id . "'");
foreach ($order_product_query->rows as $product) {
$reward += $product['reward'];
}
if ($order_query->row['affiliate_id']) {
$affiliate_id = $order_query->row['affiliate_id'];
} else {
$affiliate_id = 0;
}
$this->load->model('marketing/affiliate');
$affiliate_info = $this->model_marketing_affiliate->getAffiliate($affiliate_id);
if ($affiliate_info) {
$affiliate_firstname = $affiliate_info['firstname'];
$affiliate_lastname = $affiliate_info['lastname'];
} else {
$affiliate_firstname = '';
$affiliate_lastname = '';
}
$this->load->model('localisation/language');
$language_info = $this->model_localisation_language->getLanguage($order_query->row['language_id']);
if ($language_info) {
$language_code = $language_info['code'];
} else {
$language_code = $this->config->get('config_language');
}
return array(
'order_id' => $order_query->row['order_id'],
'invoice_no' => $order_query->row['invoice_no'],
'invoice_prefix' => $order_query->row['invoice_prefix'],
'store_id' => $order_query->row['store_id'],
'store_name' => $order_query->row['store_name'],
'store_url' => $order_query->row['store_url'],
'customer_id' => $order_query->row['customer_id'],
'customer' => $order_query->row['customer'],
'customer_group_id' => $order_query->row['customer_group_id'],
'firstname' => $order_query->row['firstname'],
'lastname' => $order_query->row['lastname'],
'email' => $order_query->row['email'],
'telephone' => $order_query->row['telephone'],
'fax' => $order_query->row['fax'],
'custom_field' => json_decode($order_query->row['custom_field'], true),
'payment_firstname' => $order_query->row['payment_firstname'],
'payment_lastname' => $order_query->row['payment_lastname'],
'payment_company' => $order_query->row['payment_company'],
'payment_address_1' => $order_query->row['payment_address_1'],
'payment_address_2' => $order_query->row['payment_address_2'],
'payment_postcode' => $order_query->row['payment_postcode'],
'payment_city' => $order_query->row['payment_city'],
'payment_zone_id' => $order_query->row['payment_zone_id'],
'payment_zone' => $order_query->row['payment_zone'],
'payment_zone_code' => $payment_zone_code,
'payment_country_id' => $order_query->row['payment_country_id'],
'payment_country' => $order_query->row['payment_country'],
'payment_iso_code_2' => $payment_iso_code_2,
'payment_iso_code_3' => $payment_iso_code_3,
'payment_address_format' => $order_query->row['payment_address_format'],
'payment_custom_field' => json_decode($order_query->row['payment_custom_field'], true),
'payment_method' => $order_query->row['payment_method'],
'payment_code' => $order_query->row['payment_code'],
'shipping_firstname' => $order_query->row['shipping_firstname'],
'shipping_lastname' => $order_query->row['shipping_lastname'],
'shipping_company' => $order_query->row['shipping_company'],
'shipping_address_1' => $order_query->row['shipping_address_1'],
'shipping_address_2' => $order_query->row['shipping_address_2'],
'shipping_postcode' => $order_query->row['shipping_postcode'],
'shipping_city' => $order_query->row['shipping_city'],
'shipping_zone_id' => $order_query->row['shipping_zone_id'],
'shipping_zone' => $order_query->row['shipping_zone'],
'shipping_zone_code' => $shipping_zone_code,
'shipping_country_id' => $order_query->row['shipping_country_id'],
'shipping_country' => $order_query->row['shipping_country'],
'shipping_iso_code_2' => $shipping_iso_code_2,
'shipping_iso_code_3' => $shipping_iso_code_3,
'shipping_address_format' => $order_query->row['shipping_address_format'],
'shipping_custom_field' => json_decode($order_query->row['shipping_custom_field'], true),
'shipping_method' => $order_query->row['shipping_method'],
'shipping_code' => $order_query->row['shipping_code'],
'comment' => $order_query->row['comment'],
'total' => $order_query->row['total'],
'reward' => $reward,
'order_status_id' => $order_query->row['order_status_id'],
'order_status' => $order_query->row['order_status'],
'affiliate_id' => $order_query->row['affiliate_id'],
'affiliate_firstname' => $affiliate_firstname,
'affiliate_lastname' => $affiliate_lastname,
'commission' => $order_query->row['commission'],
'language_id' => $order_query->row['language_id'],
'language_code' => $language_code,
'currency_id' => $order_query->row['currency_id'],
'currency_code' => $order_query->row['currency_code'],
'currency_value' => $order_query->row['currency_value'],
'ip' => $order_query->row['ip'],
'forwarded_ip' => $order_query->row['forwarded_ip'],
'user_agent' => $order_query->row['user_agent'],
'accept_language' => $order_query->row['accept_language'],
'date_added' => $order_query->row['date_added'],
'date_modified' => $order_query->row['date_modified']
);
} else {
return;
}
}
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 order_status, o.shipping_code, 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'])) {
$implode = array();
$order_statuses = explode(',', $data['filter_order_status']);
foreach ($order_statuses as $order_status_id) {
$implode[] = "o.order_status_id = '" . (int)$order_status_id . "'";
}
if ($implode) {
$sql .= " WHERE (" . implode(" OR ", $implode) . ")";
}
} 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 CONCAT(o.firstname, ' ', o.lastname) LIKE '%" . $this->db->escape($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_date_modified'])) {
$sql .= " AND DATE(o.date_modified) = DATE('" . $this->db->escape($data['filter_date_modified']) . "')";
}
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;
}
public function getOrderProducts($order_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$order_id . "'");
return $query->rows;
}
public function getOrderOptions($order_id, $order_product_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int)$order_id . "' AND order_product_id = '" . (int)$order_product_id . "'");
return $query->rows;
}
public function getOrderVouchers($order_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_voucher WHERE order_id = '" . (int)$order_id . "'");
return $query->rows;
}
public function getOrderVoucherByVoucherId($voucher_id) {
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order_voucher` WHERE voucher_id = '" . (int)$voucher_id . "'");
return $query->row;
}
public function getOrderTotals($order_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_total WHERE order_id = '" . (int)$order_id . "' ORDER BY sort_order");
return $query->rows;
}
public function getTotalOrders($data = array()) {
$sql = "SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order`";
if (isset($data['filter_order_status'])) {
$implode = array();
$order_statuses = explode(',', $data['filter_order_status']);
foreach ($order_statuses as $order_status_id) {
$implode[] = "order_status_id = '" . (int)$order_status_id . "'";
}
if ($implode) {
$sql .= " WHERE (" . implode(" OR ", $implode) . ")";
}
} else {
$sql .= " WHERE order_status_id > '0'";
}
if (!empty($data['filter_order_id'])) {
$sql .= " AND order_id = '" . (int)$data['filter_order_id'] . "'";
}
if (!empty($data['filter_customer'])) {
$sql .= " AND CONCAT(firstname, ' ', lastname) LIKE '%" . $this->db->escape($data['filter_customer']) . "%'";
}
if (!empty($data['filter_date_added'])) {
$sql .= " AND DATE(date_added) = DATE('" . $this->db->escape($data['filter_date_added']) . "')";
}
if (!empty($data['filter_date_modified'])) {
$sql .= " AND DATE(date_modified) = DATE('" . $this->db->escape($data['filter_date_modified']) . "')";
}
if (!empty($data['filter_total'])) {
$sql .= " AND total = '" . (float)$data['filter_total'] . "'";
}
$query = $this->db->query($sql);
return $query->row['total'];
}
public function getTotalOrdersByStoreId($store_id) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order` WHERE store_id = '" . (int)$store_id . "'");
return $query->row['total'];
}
public function getTotalOrdersByOrderStatusId($order_status_id) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order` WHERE order_status_id = '" . (int)$order_status_id . "' AND order_status_id > '0'");
return $query->row['total'];
}
public function getTotalOrdersByProcessingStatus() {
$implode = array();
$order_statuses = $this->config->get('config_processing_status');
foreach ($order_statuses as $order_status_id) {
$implode[] = "order_status_id = '" . (int)$order_status_id . "'";
}
if ($implode) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order` WHERE " . implode(" OR ", $implode));
return $query->row['total'];
} else {
return 0;
}
}
public function getTotalOrdersByCompleteStatus() {
$implode = array();
$order_statuses = $this->config->get('config_complete_status');
foreach ($order_statuses as $order_status_id) {
$implode[] = "order_status_id = '" . (int)$order_status_id . "'";
}
if ($implode) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order` WHERE " . implode(" OR ", $implode) . "");
return $query->row['total'];
} else {
return 0;
}
}
public function getTotalOrdersByLanguageId($language_id) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order` WHERE language_id = '" . (int)$language_id . "' AND order_status_id > '0'");
return $query->row['total'];
}
public function getTotalOrdersByCurrencyId($currency_id) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order` WHERE currency_id = '" . (int)$currency_id . "' AND order_status_id > '0'");
return $query->row['total'];
}
public function createInvoiceNo($order_id) {
$order_info = $this->getOrder($order_id);
if ($order_info && !$order_info['invoice_no']) {
$query = $this->db->query("SELECT MAX(invoice_no) AS invoice_no FROM `" . DB_PREFIX . "order` WHERE invoice_prefix = '" . $this->db->escape($order_info['invoice_prefix']) . "'");
if ($query->row['invoice_no']) {
$invoice_no = $query->row['invoice_no'] + 1;
} else {
$invoice_no = 1;
}
$this->db->query("UPDATE `" . DB_PREFIX . "order` SET invoice_no = '" . (int)$invoice_no . "', invoice_prefix = '" . $this->db->escape($order_info['invoice_prefix']) . "' WHERE order_id = '" . (int)$order_id . "'");
return $order_info['invoice_prefix'] . $invoice_no;
}
}
public function getOrderHistories($order_id, $start = 0, $limit = 10) {
if ($start < 0) {
$start = 0;
}
if ($limit < 1) {
$limit = 10;
}
$query = $this->db->query("SELECT oh.date_added, os.name AS status, oh.comment, oh.notify FROM " . DB_PREFIX . "order_history oh LEFT JOIN " . DB_PREFIX . "order_status os ON oh.order_status_id = os.order_status_id WHERE oh.order_id = '" . (int)$order_id . "' AND os.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY oh.date_added DESC LIMIT " . (int)$start . "," . (int)$limit);
return $query->rows;
}
public function getTotalOrderHistories($order_id) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "order_history WHERE order_id = '" . (int)$order_id . "'");
return $query->row['total'];
}
public function getTotalOrderHistoriesByOrderStatusId($order_status_id) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "order_history WHERE order_status_id = '" . (int)$order_status_id . "'");
return $query->row['total'];
}
public function getEmailsByProductsOrdered($products, $start, $end) {
$implode = array();
foreach ($products as $product_id) {
$implode[] = "op.product_id = '" . (int)$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 " . (int)$start . "," . (int)$end);
return $query->rows;
}
public function getTotalEmailsByProductsOrdered($products) {
$implode = array();
foreach ($products as $product_id) {
$implode[] = "op.product_id = '" . (int)$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->row['total'];
}
}
/////////////////////////////////////////////////////////////////////////////////////
i hope someone could help me...
im trying to add " 'shipping_method' => $result['shipping_method'], " inside the foreach but after i refresh the page it says undefined so review the code again then i'vee seen that the variable $results has get the data from the function getOrders so i search my files then find the order.php in model where i found the getOrders function but the problem is on this point im dont have any idea what to do next.... i hope someone could help me...
In the language file (admin/language/en-gb/dashboard/recent.php), insert:
Code: Select all
$_['column_shipping_method'] = 'Shipping Method';
Code: Select all
$data['column_shipping_method'] = $this->language->get('column_shipping_method');
Code: Select all
$data['orders'][] = array(
'order_id' => $result['order_id'],
'customer' => $result['customer'],
'status' => $result['order_status'],
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
'total' => $this->currency->format($result['total'], $result['currency_code'], $result['currency_value']),
'view' => $this->url->link('sale/order/info', 'token=' . $this->session->data['token'] . '&order_id=' . $result['order_id'], true),
);
Code: Select all
$data['orders'][] = array(
'order_id' => $result['order_id'],
'customer' => $result['customer'],
'status' => $result['order_status'],
'shipping_method' => $result['shipping_method'],
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
'total' => $this->currency->format($result['total'], $result['currency_code'], $result['currency_value']),
'view' => $this->url->link('sale/order/info', 'token=' . $this->session->data['token'] . '&order_id=' . $result['order_id'], true),
);
Code: Select all
<td><?php echo $column_shipping_method; ?></td>
Code: Select all
<td><?php echo $column_status; ?></td>
Code: Select all
<td><?php echo $order['shipping_method']; ?></td>
Code: Select all
<td><?php echo $order['status']; ?></td>
Code: Select all
<td class="text-center" colspan="6"><?php echo $text_no_results; ?></td>
Code: Select all
<td class="text-center" colspan="7"><?php echo $text_no_results; ?></td>
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool
If you're not living on the edge ... you're taking up too much space!
fido-x still says undefined? did i do something wrong? i follow everything you said... thanks..
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool
If you're not living on the edge ... you're taking up too much space!
If the vQmod manager has an upload function, then I suppose you could. It's not a question I can answer, as I've never used the vQmod manager, so I don't know if it has an upload function.edseljay wrote:do i need to upload that xml throught vqmod manager?
Personally, I'd upload via FTP and place it in the vqmod/xml folder.
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool
If you're not living on the edge ... you're taking up too much space!
Attachments
2.jpg (78.92 KiB) Viewed 3170 times
1.jpg (58.87 KiB) Viewed 3170 times
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool
If you're not living on the edge ... you're taking up too much space!
No. This mod is for OpenCart 2.kanchi2012 wrote:is this working in 1.5.6 @fido-x
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool
If you're not living on the edge ... you're taking up too much space!
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool
If you're not living on the edge ... you're taking up too much space!
go to admin/model/sale/order.php
then find this "public function getOrders($data = array()) {"
and below that line find this "AS status, o.total, " then add the "o.shipping_method, "
then just few line after there find the
$sort_data = array(
'o.order_id',
'customer',
'status',
'o.date_added',
'o.date_modified',
'o.total'
);
and then just add the 'o.shipping_method',
just like this:
$sort_data = array(
'o.order_id',
'customer',
'status',
'shipping_method',
'o.date_added',
'o.date_modified',
'o.total'
);
then next is go to your admin/controller/common/home.php
then find this:
$this->data['orders'][] = array(
'order_id' => $result['order_id'],
'customer' => $result['customer'],
'status' => $result['status'],
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
'total' => $this->currency->format($result['total'], $result['currency_code'], $result['currency_value']),
'action' => $action
);
and then just add the 'shipping_method' => $result['shipping_method'],
just like this:
$this->data['orders'][] = array(
'order_id' => $result['order_id'],
'customer' => $result['customer'],
'status' => $result['status'],
'shipping_method' => $result['shipping_method'],
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
'total' => $this->currency->format($result['total'], $result['currency_code'], $result['currency_value']),
'action' => $action
);
then your done, in your backend if you used the the shipping_method variable to show the shipping_method used by the customer the variable will not be undefined anymore.. Thanks you fido-x it able to give me clue base on the xml file for opencart 2.2 that he gave me before...
Users browsing this forum: No registered users and 270 guests