1: | <?php
2: | namespace Opencart\Catalog\Model\Extension\Opencart\Total;
3: | /**
4: | * Class Credit
5: | *
6: | * @package Opencart\Catalog\Model\Extension\Opencart\Total
7: | */
8: | class Credit extends \Opencart\System\Engine\Model {
9: | /**
10: | * Get Total
11: | *
12: | * @param array<int, array<string, mixed>> $totals
13: | * @param array<int, float> $taxes
14: | * @param float $total
15: | *
16: | * @return void
17: | */
18: | public function getTotal(array &$totals, array &$taxes, float &$total): void {
19: | $this->load->language('extension/opencart/total/credit');
20: |
21: | $balance = $this->customer->getBalance();
22: |
23: | if ((float)$balance) {
24: | $credit = min($balance, $total);
25: |
26: | if ((float)$credit > 0) {
27: | $totals[] = [
28: | 'extension' => 'opencart',
29: | 'code' => 'credit',
30: | 'title' => $this->language->get('text_credit'),
31: | 'value' => -$credit,
32: | 'sort_order' => (int)$this->config->get('total_credit_sort_order')
33: | ];
34: |
35: | $total -= $credit;
36: | }
37: | }
38: | }
39: |
40: | /**
41: | * Confirm
42: | *
43: | * @param array<string, mixed> $order_info
44: | * @param array<string, mixed> $order_total
45: | *
46: | * @return void
47: | */
48: | public function confirm(array $order_info, array $order_total): void {
49: | $this->load->language('extension/opencart/total/credit');
50: |
51: | if ($order_info['customer_id']) {
52: | $this->load->model('account/transaction');
53: |
54: | $this->model_account_transaction->addTransaction($order_info['customer_id'], $order_info['order_id'], sprintf($this->language->get('text_order_id'), (int)$order_info['order_id']), (float)$order_total['value']);
55: | }
56: | }
57: |
58: | /**
59: | * Unconfirm
60: | *
61: | * @param array<string, mixed> $order_info
62: | *
63: | * @return void
64: | */
65: | public function unconfirm(array $order_info): void {
66: | $this->load->model('account/transaction');
67: |
68: | $this->model_account_transaction->deleteTransactionByOrderId($order_info['order_id']);
69: | }
70: | }
71: |

OpenCart API API documentation generated by ApiGen dev-master