1: | <?php
2: | namespace Opencart\Admin\Model\Extension\Opencart\Dashboard;
3: | /**
4: | * Class Map
5: | *
6: | * @package Opencart\Admin\Model\Extension\Opencart\Dashboard
7: | */
8: | class Map extends \Opencart\System\Engine\Model {
9: | /**
10: | * Get Total Orders By Country
11: | *
12: | * @return array<int, array<string, mixed>>
13: | */
14: | public function getTotalOrdersByCountry(): array {
15: | $implode = [];
16: |
17: | if (is_array($this->config->get('config_complete_status'))) {
18: | foreach ($this->config->get('config_complete_status') as $order_status_id) {
19: | $implode[] = "'" . (int)$order_status_id . "'";
20: | }
21: | }
22: |
23: | if ($implode) {
24: | $query = $this->db->query("SELECT COUNT(*) AS `total`, SUM(`o`.`total`) AS `amount`, c.`iso_code_2` FROM `" . DB_PREFIX . "order` `o` LEFT JOIN `" . DB_PREFIX . "country` c ON (`o`.`payment_country_id` = c.`country_id`) WHERE `o`.`order_status_id` IN(" . implode(',', $implode) . ") AND `o`.`payment_country_id` != '0' GROUP BY `o`.`payment_country_id`");
25: |
26: | return $query->rows;
27: | } else {
28: | return [];
29: | }
30: | }
31: | }
32: |

OpenCart API API documentation generated by ApiGen dev-master