1 | <?php |
||
11 | class EcommerceCustomDeliveryModifier extends OrderModifier |
||
|
|||
12 | { |
||
13 | |||
14 | // ######################################## *** model defining static variables (e.g. $db, $has_one) |
||
15 | |||
16 | /** |
||
17 | * add extra fields as you need them. |
||
18 | * |
||
19 | **/ |
||
20 | public static $db = array( |
||
21 | "PostalCode" => "Varchar(10)", |
||
22 | "SpecialProductCount" => "Int", |
||
23 | "NonSpecialProductCount" => "Int" |
||
24 | ); |
||
25 | |||
26 | |||
27 | // ######################################## *** cms variables + functions (e.g. getCMSFields, $searchableFields) |
||
28 | |||
29 | /** |
||
30 | * standard SS method |
||
31 | */ |
||
32 | public function getCMSFields() |
||
37 | |||
38 | public static $singular_name = "Delivery Charge"; |
||
39 | public function i18n_singular_name() |
||
43 | |||
44 | public static $plural_name = "Delivery Charges"; |
||
45 | public function i18n_plural_name() |
||
49 | |||
50 | // ######################################## *** other (non) static variables (e.g. protected static $special_name_for_something, protected $order) |
||
51 | |||
52 | |||
53 | // ######################################## *** CRUD functions (e.g. canEdit) |
||
54 | // ######################################## *** init and update functions |
||
55 | |||
56 | /** |
||
57 | * For all modifers with their own database fields, we need to include this... |
||
58 | * It will update each of the fields. |
||
59 | * Within this method, we need to create the methods |
||
60 | * Live{functionName} |
||
61 | * e.g LiveMyField() and LiveMyReduction() in this case... |
||
62 | * The OrderModifier already updates the basic database fields. |
||
63 | * @param Bool $force - run it, even if it has run already |
||
64 | */ |
||
65 | public function runUpdate($force = false) |
||
72 | |||
73 | |||
74 | // ######################################## *** form functions (e. g. Showform and getform) |
||
75 | |||
76 | /** |
||
77 | * standard OrderModifier Method |
||
78 | * Should we show a form in the checkout page for this modifier? |
||
79 | */ |
||
80 | public function ShowForm() |
||
84 | |||
85 | /** |
||
86 | * Should the form be included in the editable form |
||
87 | * on the checkout page? |
||
88 | * @return Boolean |
||
89 | */ |
||
90 | public function ShowFormInEditableOrderTable() |
||
94 | |||
95 | /** |
||
96 | * Should the form be included in the editable form |
||
97 | * on the checkout page? |
||
98 | * @return Boolean |
||
99 | */ |
||
100 | public function ShowFormOutsideEditableOrderTable() |
||
104 | |||
105 | // ######################################## *** template functions (e.g. ShowInTable, TableTitle, etc...) ... USES DB VALUES |
||
106 | |||
107 | /** |
||
108 | * standard OrderModifer Method |
||
109 | * Tells us if the modifier should take up a row in the table on the checkout page. |
||
110 | * @return Boolean |
||
111 | */ |
||
112 | public function ShowInTable() |
||
116 | |||
117 | /** |
||
118 | * standard OrderModifer Method |
||
119 | * Tells us if the modifier can be removed (hidden / turned off) from the order. |
||
120 | * @return Boolean |
||
121 | */ |
||
122 | public function CanBeRemoved() |
||
126 | |||
127 | // ######################################## *** inner calculations.... USES CALCULATED VALUES |
||
128 | |||
129 | |||
130 | |||
131 | // ######################################## *** calculate database fields: protected function Live[field name] ... USES CALCULATED VALUES |
||
132 | |||
133 | /** |
||
134 | * if we want to change the default value for the Name field |
||
135 | * (defined in the OrderModifer class) then we can do this |
||
136 | * as shown in the method below. |
||
137 | * You may choose to return an empty string or just a standard message. |
||
138 | **/ |
||
139 | protected function LiveName() |
||
155 | |||
156 | protected function LiveCalculatedTotal() |
||
168 | |||
169 | |||
170 | |||
171 | // ######################################## *** Type Functions (IsChargeable, IsDeductable, IsNoChange, IsRemoved) |
||
172 | |||
173 | |||
174 | |||
175 | // ######################################## *** standard database related functions (e.g. onBeforeWrite, onAfterWrite, etc...) |
||
176 | |||
177 | public function onBeforeWrite() |
||
181 | |||
182 | // ######################################## *** debug functions |
||
183 | |||
184 | public function LiveNonSpecialProductCount() |
||
188 | |||
189 | public function LiveSpecialProductCount() |
||
193 | |||
194 | /** |
||
195 | * @return int |
||
196 | */ |
||
197 | protected function ProductCountForTotal($special = false) |
||
220 | |||
221 | /** |
||
222 | * |
||
223 | * @return String |
||
224 | */ |
||
225 | public function LivePostalCode() |
||
242 | |||
243 | |||
244 | /** |
||
245 | * |
||
246 | * @array |
||
247 | */ |
||
248 | private function SelectedProductsArray() |
||
253 | |||
254 | /** |
||
255 | * |
||
256 | * @return EcommerceCustomDeliveryPostalCode | null |
||
257 | */ |
||
258 | private function MyPostalCodeObject() |
||
270 | } |
||
271 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.