1 | <?php |
||
14 | class WC_Order_Item_Coupon extends WC_Order_Item { |
||
15 | |||
16 | /** |
||
17 | * Data properties of this order item object. |
||
18 | * @since 2.6.0 |
||
19 | * @var array |
||
20 | */ |
||
21 | protected $_data = array( |
||
22 | 'order_id' => 0, |
||
23 | 'order_item_id' => 0, |
||
24 | 'code' => '', |
||
25 | 'discount' => 0, |
||
26 | 'discount_tax' => 0, |
||
27 | ); |
||
28 | |||
29 | /** |
||
30 | * offsetGet for ArrayAccess/Backwards compatibility. |
||
31 | * @deprecated Add deprecation notices in future release. |
||
32 | * @param string $offset |
||
33 | * @return mixed |
||
34 | */ |
||
35 | public function offsetGet( $offset ) { |
||
43 | |||
44 | /** |
||
45 | * offsetExists for ArrayAccess |
||
46 | * @param string $offset |
||
47 | * @return bool |
||
48 | */ |
||
49 | public function offsetExists( $offset ) { |
||
55 | |||
56 | /** |
||
57 | * Read/populate data properties specific to this order item. |
||
58 | */ |
||
59 | public function read( $id ) { |
||
66 | |||
67 | /** |
||
68 | * Save properties specific to this order item. |
||
69 | * @return int Item ID |
||
70 | */ |
||
71 | public function save() { |
||
80 | |||
81 | /** |
||
82 | * Internal meta keys we don't want exposed as part of meta_data. |
||
83 | * @return array() |
||
84 | */ |
||
85 | protected function get_internal_meta_keys() { |
||
88 | |||
89 | /* |
||
90 | |-------------------------------------------------------------------------- |
||
91 | | Setters |
||
92 | |-------------------------------------------------------------------------- |
||
93 | */ |
||
94 | |||
95 | /** |
||
96 | * Set order item name. |
||
97 | * @param string $value |
||
98 | */ |
||
99 | public function set_name( $value ) { |
||
102 | |||
103 | /** |
||
104 | * Set code. |
||
105 | * @param string $value |
||
106 | */ |
||
107 | public function set_code( $value ) { |
||
110 | |||
111 | /** |
||
112 | * Set discount amount. |
||
113 | * @param string $value |
||
114 | */ |
||
115 | public function set_discount( $value ) { |
||
118 | |||
119 | /** |
||
120 | * Set discounted tax amount. |
||
121 | * @param string $value |
||
122 | */ |
||
123 | public function set_discount_tax( $value ) { |
||
126 | |||
127 | /* |
||
128 | |-------------------------------------------------------------------------- |
||
129 | | Getters |
||
130 | |-------------------------------------------------------------------------- |
||
131 | */ |
||
132 | |||
133 | /** |
||
134 | * Get order item type. |
||
135 | * @return string |
||
136 | */ |
||
137 | public function get_type() { |
||
140 | |||
141 | /** |
||
142 | * Get order item name. |
||
143 | * @return string |
||
144 | */ |
||
145 | public function get_name() { |
||
148 | |||
149 | /** |
||
150 | * Get coupon code. |
||
151 | * @return string |
||
152 | */ |
||
153 | public function get_code() { |
||
156 | |||
157 | /** |
||
158 | * Get discount amount. |
||
159 | * @return string |
||
160 | */ |
||
161 | public function get_discount() { |
||
164 | |||
165 | /** |
||
166 | * Get discounted tax amount. |
||
167 | * @return string |
||
168 | */ |
||
169 | public function get_discount_tax() { |
||
172 | } |
||
173 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.