Norman in 't Veldt
Moderator OpenCart Forums
_________________ READ and Search BEFORE POSTING _________________
Our FREE search: Find your answer FAST!.
[How to] BTW + Verzend + betaal setup.
This is because Open Cart does not know what order_status_id is Cancelled. On your site, Cancelled may be an order status of 5 but on my site it may an order status of 10. So, Open Cart doesn't know what Cancelled is and hence it cannot be used to adjust the totals on a standard install.adwordsvouchersshop wrote:When i choose the order to be "CANCELLED or REFUND, should not the "Total Sales This Month" and "Total Sales This Year" decrease the amount? (dollars, euros...). If it is not a bug can it be done?
But you could hard code it into the model file - put in a Where clause to exclude the order status id that is cancelled on your site.
in admin/model/sale/order, look for the function getTotalSales and change the where clause to suit
Another alternative would be to add and to use a default value from the settings page which would only be specific to cancellation then to use the registered configuration object from the codes.jty wrote:This is because Open Cart does not know what order_status_id is Cancelled. On your site, Cancelled may be an order status of 5 but on my site it may an order status of 10. So, Open Cart doesn't know what Cancelled is and hence it cannot be used to adjust the totals on a standard install.adwordsvouchersshop wrote:When i choose the order to be "CANCELLED or REFUND, should not the "Total Sales This Month" and "Total Sales This Year" decrease the amount? (dollars, euros...). If it is not a bug can it be done?
But you could hard code it into the model file - put in a Where clause to exclude the order status id that is cancelled on your site.
in admin/model/sale/order, look for the function getTotalSales and change the where clause to suit
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
my thought was to add another field to the order_status table to flag the order statii as canceled or not but that's because I avoid the settings table as much as possible.straightlight wrote:Another alternative would be to add and to use a default value from the settings page which would only be specific to cancellation then to use the registered configuration object from the codes.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Insert the following db queries into "admin/model/sale/order.php"
Code: Select all
public function getDashboardTotalSales() {
$query = $this->db->query("SELECT SUM(total) AS total FROM `" . DB_PREFIX . "order` WHERE order_status_id = '" . (int)$this->config->get('config_complete_status_id') . "'");
return $query->row['total'];
}
Code: Select all
public function getDashboardTotalSalesByYear($year) {
$query = $this->db->query("SELECT SUM(total) AS total FROM `" . DB_PREFIX . "order` WHERE order_status_id = '" . (int)$this->config->get('config_complete_status_id') . "' AND YEAR(date_added) = '" . (int)$year . "'");
return $query->row['total'];
}
Code: Select all
public function getDashboardTotalSales() {
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order` WHERE order_status_id = '" . (int)$this->config->get('config_complete_status_id') . "'");
return $query->row['total'];
}
Code: Select all
$this->data['total_sale'] = $this->currency->format($this->model_sale_order->getTotalSales(), $this->config->get('config_currency'));
$this->data['total_sale_year'] = $this->currency->format($this->model_sale_order->getTotalSalesByYear(date('Y')), $this->config->get('config_currency'));
$this->data['total_order'] = $this->model_sale_order->getTotalOrders();
Code: Select all
$this->data['total_sale'] = $this->currency->format($this->model_sale_order->getDashboardTotalSales(), $this->config->get('config_currency'));
$this->data['total_sale_year'] = $this->currency->format($this->model_sale_order->getDashboardTotalSalesByYear(date('Y')), $this->config->get('config_currency'));
$this->data['total_order'] = $this->model_sale_order->getDashboardTotalOrders();
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!
http://www.opencart.com/index.php?route ... _id=100547, a part of the code from this vqmod modifies the following:
Code: Select all
<file name="adminmodzcp/model/sale/order.php">
<operation>
<search position="before"><![CDATA[public function getTotalSalesByYear($year) {]]></search>
<add><![CDATA[ public function getTotalSalesByMonth($month, $year) {
$query = $this->db->query("SELECT SUM(total) AS total FROM `" . DB_PREFIX . "order` WHERE order_status_id > '0' AND MONTH(date_added) = '" . $month . "' AND YEAR(date_added) = '" . (int)$year . "'");
return $query->row['total'];
}]]></add>
</operation>
</file>
Code: Select all
<file name="adminmodzcp/controller/common/home.php">
<operation>
<search position="replace"><![CDATA[ $this->data['text_total_sale_year'] = $this->language->get('text_total_sale_year');]]></search>
<add><![CDATA[ $this->data['text_total_sale_year'] = $this->language->get('text_total_sale_year');
$this->data['text_total_sale_month'] = $this->language->get('text_total_sale_month');]]></add>
</operation>
<operation>
<search position="replace"><![CDATA[ $this->data['text_total_affiliate_approval'] = $this->language->get('text_total_affiliate_approval');]]></search>
<add><![CDATA[ $this->data['text_total_affiliate_approval'] = $this->language->get('text_total_affiliate_approval');
$this->data['text_returns_approval'] = $this->language->get('text_returns_approval');]]></add>
</operation>
<operation>
<search position="replace"><![CDATA[ $this->data['total_sale_year'] = $this->currency->format($this->model_sale_order->getTotalSalesByYear(date('Y')), $this->config->get('config_currency'));]]></search>
<add><![CDATA[ $this->data['total_sale_year'] = $this->currency->format($this->model_sale_order->getTotalSalesByYear(date('Y')), $this->config->get('config_currency'));
$this->data['total_sale_month'] = $this->currency->format($this->model_sale_order->getTotalSalesByMonth(date("m"), date('Y')), $this->config->get('config_currency'));
]]></add>
</operation>
<operation>
<search position="replace"><![CDATA[ $this->data['total_affiliate_approval'] = $this->model_sale_affiliate->getTotalAffiliatesAwaitingApproval();]]></search>
<add><![CDATA[ $this->data['total_affiliate_approval'] = $this->model_sale_affiliate->getTotalAffiliatesAwaitingApproval();
$this->load->model('sale/return');
$data['filter_return_status_id']=4;
$this->data['total_returns_approval'] = $this->model_sale_return->getTotalReturns($data);
]]></add>
</operation>
</file>
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

Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Fatal error: Cannot redeclare ModelSaleOrder::getDashboardTotalSales() in /teststore/admin/model/sale/order.php on line 14
It is a fresh install and the only thing changed is the codes from fido.
I attached the order.php to see how it looks after adding the codes.
Attachments
Code: Select all
public function getDashboardTotalSales() {
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order` WHERE order_status_id = '" . (int)$this->config->get('config_complete_status_id') . "'");
return $query->row['total'];
}

Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Code: Select all
public function getDashboardTotalSales() {
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order` WHERE order_status_id = '" . (int)$this->config->get('config_complete_status_id') . "'");
return $query->row['total'];
}
Code: Select all
public function getDashboardTotalSalesCount() {
$query = $this->db->query("SELECT COUNT(total) AS total FROM `" . DB_PREFIX . "order` WHERE order_status_id = '" . (int)$this->config->get('config_complete_status_id') . "'");
return $query->row['total'];
}
public function getDashboardTotalSalesSum() {
$query = $this->db->query("SELECT SUM(total) AS total FROM `" . DB_PREFIX . "order` WHERE order_status_id = '" . (int)$this->config->get('config_complete_status_id') . "'");
return $query->row['total'];
}
to replace:
Code: Select all
<td><?php echo $total_sale; ?></td>
Code: Select all
<td><?php echo $total_count_sale; ?><br /><?php echo $total_sum_sale; ?></td>
to replace:
Code: Select all
$this->data['total_sale'] = $this->currency->format($this->model_sale_order->getDashboardTotalSales(), $this->config->get('config_currency'));
$this->data['total_sale_year'] = $this->currency->format($this->model_sale_order->getDashboardTotalSalesByYear(date('Y')), $this->config->get('config_currency'));
$this->data['total_order'] = $this->model_sale_order->getDashboardTotalOrders();
Code: Select all
$this->data['total_count_sale'] = $this->currency->format($this->model_sale_order->getDashboardTotalSalesCount(), $this->config->get('config_currency'));
$this->data['total_sum_sale'] = $this->currency->format($this->model_sale_order->getDashboardTotalSalesSum(), $this->config->get('config_currency'));
$this->data['total_sale_year'] = $this->currency->format($this->model_sale_order->getDashboardTotalSalesByYear(date('Y')), $this->config->get('config_currency'));
$this->data['total_order'] = $this->model_sale_order->getDashboardTotalOrders();
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
Code: Select all
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 '*) AS sum_total FROM `order` WHERE order_status_id = '5'' at line 1
Error No: 1064
SELECT COUNT(*) AS count_total, SUM(*) AS sum_total FROM `order` WHERE order_status_id = '5' in /teststore/system/database/mysql.php on line 49
Users browsing this forum: No registered users and 11 guests