/
cod.php
69 lines (57 loc) · 2.03 KB
/
cod.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/*
$Id$
CE Phoenix, E-Commerce made Easy
https://phoenixcart.org
Copyright (c) 2021 Phoenix Cart
Released under the GNU General Public License
*/
class cod extends abstract_payment_module {
const CONFIG_KEY_BASE = 'MODULE_PAYMENT_COD_';
public function __construct() {
parent::__construct();
$this->sort_order = defined('MODULE_PAYMENT_COD_SORT_ORDER') ? MODULE_PAYMENT_COD_SORT_ORDER : 0;
}
public function update_status() {
if (!$this->enabled || !isset($GLOBALS['order'])) {
return;
}
// disable the module if the order only contains virtual products
if ('virtual' === $GLOBALS['order']->content_type) {
$this->enabled = false;
return;
}
if (isset($GLOBALS['order']->delivery['country']['id'])) {
$this->update_status_by($GLOBALS['order']->delivery);
}
}
protected function get_parameters() {
return [
'MODULE_PAYMENT_COD_STATUS' => [
'title' => 'Enable Cash On Delivery Module',
'value' => 'True',
'desc' => 'Do you want to accept Cash On Delivery payments?',
'set_func' => "Config::select_one(['True', 'False'], ",
],
'MODULE_PAYMENT_COD_ZONE' => [
'title' => 'Payment Zone',
'value' => '0',
'desc' => 'If a zone is selected, only enable this payment method for that zone.',
'use_func' => 'geo_zone::fetch_name',
'set_func' => 'Config::select_geo_zone(',
],
'MODULE_PAYMENT_COD_SORT_ORDER' => [
'title' => 'Sort order of display.',
'value' => '0',
'desc' => 'Sort order of display. Lowest is displayed first.',
],
'MODULE_PAYMENT_COD_ORDER_STATUS_ID' => [
'title' => 'Set Order Status',
'value' => '0',
'desc' => 'Set the status of orders made with this payment module to this value',
'set_func' => 'Config::select_order_status(',
'use_func' => 'order_status::fetch_name',
],
];
}
}