docs/api/source-admin.controller.mail.transaction.html
| 1: | <?php | | 2: | namespace Opencart\Admin\Controller\Mail; | | 3: | /** | | 4: | * Class Transaction | | 5: | * | | 6: | * @package Opencart\Admin\Controller\Mail | | 7: | */ | | 8: | class Transaction extends \Opencart\System\Engine\Controller { | | 9: | /** | | 10: | * Index | | 11: | * | | 12: | * @param string $route | | 13: | * @param array<int, mixed> $args | | 14: | * @param mixed $output | | 15: | * | | 16: | * @throws \Exception | | 17: | * | | 18: | * @return void | | 19: | */ | | 20: | public function index(string &$route, array &$args, &$output): void { | | 21: | if (isset($args[0])) { | | 22: | $customer_id = $args[0]; | | 23: | } else { | | 24: | $customer_id = 0; | | 25: | } | | 26: | | | 27: | if (isset($args[1])) { | | 28: | $description = $args[1]; | | 29: | } else { | | 30: | $description = ''; | | 31: | } | | 32: | | | 33: | if (isset($args[2])) { | | 34: | $amount = $args[2]; | | 35: | } else { | | 36: | $amount = 0; | | 37: | } | | 38: | | | 39: | if (isset($args[3])) { | | 40: | $order_id = $args[3]; | | 41: | } else { | | 42: | $order_id = 0; | | 43: | } | | 44: | | | 45: | $this->load->model('customer/customer'); | | 46: | | | 47: | $customer_info = $this->model_customer_customer->getCustomer($customer_id); | | 48: | | | 49: | if ($customer_info) { | | 50: | $this->load->language('mail/transaction'); | | 51: | | | 52: | $this->load->model('setting/store'); | | 53: | | | 54: | $store_info = $this->model_setting_store->getStore($customer_info['store_id']); | | 55: | | | 56: | if ($store_info) { | | 57: | $store_name = html_entity_decode($store_info['name'], ENT_QUOTES, 'UTF-8'); | | 58: | $store_url = $store_info['store_url']; | | 59: | } else { | | 60: | $store_name = html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'); | | 61: | $store_url = $this->config->get('config_url'); | | 62: | } | | 63: | | | 64: | $this->load->model('localisation/language'); | | 65: | | | 66: | $language_info = $this->model_localisation_language->getLanguage($customer_info['language_id']); | | 67: | | | 68: | if ($language_info) { | | 69: | $language_code = $language_info['code']; | | 70: | } else { | | 71: | $language_code = $this->config->get('config_language'); | | 72: | } | | 73: | | | 74: | $this->load->language('default', 'mail', $language_code); | | 75: | $this->load->language('mail/transaction', 'mail', $language_code); | | 76: | | | 77: | $subject = sprintf($this->language->get('mail_text_subject'), $store_name); | | 78: | | | 79: | $data['text_received'] = sprintf($this->language->get('mail_text_received'), $this->currency->format($amount, $this->config->get('config_currency'))); | | 80: | $data['text_total'] = sprintf($this->language->get('mail_text_total'), $this->currency->format($this->model_customer_customer->getTransactionTotal($customer_id), $this->config->get('config_currency'))); | | 81: | | | 82: | $data['store'] = $store_name; | | 83: | $data['store_url'] = $store_url; | | 84: | | | 85: | if ($this->config->get('config_mail_engine')) { | | 86: | $mail_option = [ | | 87: | 'parameter' => $this->config->get('config_mail_parameter'), | | 88: | 'smtp_hostname' => $this->config->get('config_mail_smtp_hostname'), | | 89: | 'smtp_username' => $this->config->get('config_mail_smtp_username'), | | 90: | 'smtp_password' => html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8'), | | 91: | 'smtp_port' => $this->config->get('config_mail_smtp_port'), | | 92: | 'smtp_timeout' => $this->config->get('config_mail_smtp_timeout') | | 93: | ]; | | 94: | | | 95: | $mail = new \Opencart\System\Library\Mail($this->config->get('config_mail_engine'), $mail_option); | | 96: | $mail->setTo($customer_info['email']); | | 97: | $mail->setFrom($this->config->get('config_email')); | | 98: | $mail->setSender($store_name); | | 99: | $mail->setSubject($subject); | | 100: | $mail->setHtml($this->load->view('mail/transaction', $data)); | | 101: | $mail->send(); | | 102: | } | | 103: | } | | 104: | } | | 105: | } | | 106: | |
OpenCart API API documentation generated by ApiGen dev-master