docs/api/source-catalog.controller.event.statistics.html
| 1: | <?php | | 2: | namespace Opencart\Catalog\Controller\Event; | | 3: | /** | | 4: | * Class Statistics | | 5: | * | | 6: | * @package Opencart\Catalog\Controller\Event | | 7: | */ | | 8: | class Statistics extends \Opencart\System\Engine\Controller { | | 9: | // catalog/model/catalog/review/addReview/after | | 10: | /** | | 11: | * Add Review | | 12: | * | | 13: | * @param string $route | | 14: | * @param array<int, mixed> $args | | 15: | * @param mixed $output | | 16: | * | | 17: | * @return void | | 18: | */ | | 19: | public function addReview(string &$route, array &$args, &$output): void { | | 20: | $this->load->model('report/statistics'); | | 21: | | | 22: | $this->model_report_statistics->addValue('review', 1); | | 23: | } | | 24: | | | 25: | // catalog/model/account/returns/addReturn/after | | 26: | | | 27: | /** | | 28: | * Add Return | | 29: | * | | 30: | * @param string $route | | 31: | * @param array<int, mixed> $args | | 32: | * @param mixed $output | | 33: | * | | 34: | * @return void | | 35: | */ | | 36: | public function addReturn(string &$route, array &$args, &$output): void { | | 37: | $this->load->model('report/statistics'); | | 38: | | | 39: | $this->model_report_statistics->addValue('returns', 1); | | 40: | } | | 41: | | | 42: | // catalog/model/checkout/order/addHistory/before | | 43: | | | 44: | /** | | 45: | * Add History | | 46: | * | | 47: | * @param string $route | | 48: | * @param array<int, mixed> $args | | 49: | * | | 50: | * @return void | | 51: | */ | | 52: | public function addHistory(string &$route, array &$args): void { | | 53: | $this->load->model('checkout/order'); | | 54: | | | 55: | $order_info = $this->model_checkout_order->getOrder($args[0]); | | 56: | | | 57: | if ($order_info) { | | 58: | $this->load->model('report/statistics'); | | 59: | | | 60: | $old_status_id = $order_info['order_status_id']; | | 61: | $new_status_id = $args[1]; | | 62: | | | 63: | $processing_status = (array)$this->config->get('config_processing_status'); | | 64: | $complete_status = (array)$this->config->get('config_complete_status'); | | 65: | | | 66: | $active_status = array_merge($processing_status, $complete_status); | | 67: | | | 68: | // If order status in complete or processing add value to sale total | | 69: | if (in_array($new_status_id, $active_status) && !in_array($old_status_id, $active_status)) { | | 70: | $this->model_report_statistics->addValue('order_sale', $order_info['total']); | | 71: | } | | 72: | | | 73: | // If order status not in complete or processing remove value to sale total | | 74: | if (!in_array($new_status_id, $active_status) && in_array($old_status_id, $active_status)) { | | 75: | $this->model_report_statistics->removeValue('order_sale', $order_info['total']); | | 76: | } | | 77: | | | 78: | // Add to processing status if new status is in the array | | 79: | if (in_array($new_status_id, $processing_status) && !in_array($old_status_id, $processing_status)) { | | 80: | $this->model_report_statistics->addValue('order_processing', 1); | | 81: | } | | 82: | | | 83: | // Remove from processing status if new status is not array and old status is | | 84: | if (!in_array($new_status_id, $processing_status) && in_array($old_status_id, $processing_status)) { | | 85: | $this->model_report_statistics->removeValue('order_processing', 1); | | 86: | } | | 87: | | | 88: | // Add to complete status if new status is not array | | 89: | if (in_array($new_status_id, $complete_status) && !in_array($old_status_id, $complete_status)) { | | 90: | $this->model_report_statistics->addValue('order_complete', 1); | | 91: | } | | 92: | | | 93: | // Remove from complete status if new status is not array | | 94: | if (!in_array($new_status_id, $complete_status) && in_array($old_status_id, $complete_status)) { | | 95: | $this->model_report_statistics->removeValue('order_complete', 1); | | 96: | } | | 97: | } | | 98: | } | | 99: | } | | 100: | |
OpenCart API API documentation generated by ApiGen dev-master