1: | <?php
|
2: | namespace Opencart\Catalog\Model\Extension\Opencart\Payment;
|
3: | |
4: | |
5: | |
6: | |
7: |
|
8: | class FreeCheckout extends \Opencart\System\Engine\Model {
|
9: | |
10: | |
11: | |
12: | |
13: | |
14: | |
15: |
|
16: | public function getMethods(array $address = []): array {
|
17: | $this->load->language('extension/opencart/payment/free_checkout');
|
18: |
|
19: |
|
20: | $totals = [];
|
21: | $taxes = $this->cart->getTaxes();
|
22: | $total = 0;
|
23: |
|
24: | $this->load->model('checkout/cart');
|
25: |
|
26: | ($this->model_checkout_cart->getTotals)($totals, $taxes, $total);
|
27: |
|
28: | if (!empty($this->session->data['vouchers'])) {
|
29: | $amounts = array_column($this->session->data['vouchers'], 'amount');
|
30: | } else {
|
31: | $amounts = [];
|
32: | }
|
33: |
|
34: | $total += array_sum($amounts);
|
35: |
|
36: | if ($this->currency->format($total, $this->config->get('config_currency'), false, false) <= 0.00) {
|
37: | $status = true;
|
38: | } elseif ($this->cart->hasSubscription()) {
|
39: | $status = false;
|
40: | } else {
|
41: | $status = false;
|
42: | }
|
43: |
|
44: | $method_data = [];
|
45: |
|
46: | if ($status) {
|
47: | $option_data['free_checkout'] = [
|
48: | 'code' => 'free_checkout.free_checkout',
|
49: | 'name' => $this->language->get('heading_title')
|
50: | ];
|
51: |
|
52: | $method_data = [
|
53: | 'code' => 'free_checkout',
|
54: | 'name' => $this->language->get('heading_title'),
|
55: | 'option' => $option_data,
|
56: | 'sort_order' => $this->config->get('payment_free_checkout_sort_order')
|
57: | ];
|
58: | }
|
59: |
|
60: | return $method_data;
|
61: | }
|
62: | }
|
63: | |