Jump to content
Sign in to follow this  
vipwww

Всего продано на сумму:

Recommended Posts

Подскажите пожалуйста как сделать чтобы общая сумма в админке отображалась только от завершённых заказов ? В данный момент суммируются завершённые и те которые аннулированные заказы :|

Share this post


Link to post
Share on other sites

Решение:

 

Заходим в admin\model\sale , файл order.php

 

Находим:

 

    public function getTotalSales() {
          $query = $this->db->query("SELECT SUM(total) AS total FROM `" . DB_PREFIX . "order` WHERE order_status_id > '0'");

        return $query->row['total'];
    }

    public function getTotalSalesByYear($year) {
          $query = $this->db->query("SELECT SUM(total) AS total FROM `" . DB_PREFIX . "order` WHERE order_status_id > '0' AND YEAR(date_added) = '" . (int)$year . "'");

        return $query->row['total'];
    }

 

Заменяем на:

 

    public function getTotalSales() {
          $query = $this->db->query("SELECT SUM(total) AS total FROM `" . DB_PREFIX . "order` WHERE order_status_id > '0' and order_status_id not in (9,1,8,7,17,2)");

        return $query->row['total'];
    }

    public function getTotalSalesByYear($year) {
          $query = $this->db->query("SELECT SUM(total) AS total FROM `" . DB_PREFIX . "order` WHERE order_status_id > '0' and order_status_id not in (9,1,8,7,17,2) AND YEAR(date_added) = '" . (int)$year . "'");

        return $query->row['total'];
    }

 

где 9,1,8,7,17,2 ID статусы заказов

 

Чтобы в "Всего заказов" отображались только оплаченные к заказы к примеру то делаем следующее:

 

public function getTotalOrders($data = array()) {
          $sql = "SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order`";

        if (isset($data['filter_order_status_id']) && !is_null($data['filter_order_status_id'])) {
            $sql .= " WHERE order_status_id = '" . (int)$data['filter_order_status_id'] . "'";
        } else {
            $sql .= " WHERE order_status_id > '0'";
        }

 

Заменяем на:

 

    public function getTotalOrders($data = array()) {
          $sql = "SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order`";

        if (isset($data['filter_order_status_id']) && !is_null($data['filter_order_status_id'])) {
            $sql .= " WHERE order_status_id = '" . (int)$data['filter_order_status_id'] . "'";
        } else {
            $sql .= " WHERE order_status_id > '0' and order_status_id not in (9,1,8,7,17,2)";
        }

 

где 9,1,8,7,17,2 ID статуса заказа

 

На этом всё.

  • +1 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.