Complex classes like Order often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Order, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
31 | class Order extends DataObject implements EditableEcommerceObject |
||
|
|||
32 | { |
||
33 | /** |
||
34 | * API Control. |
||
35 | * |
||
36 | * @var array |
||
37 | */ |
||
38 | private static $api_access = array( |
||
39 | 'view' => array( |
||
40 | 'OrderEmail', |
||
41 | 'EmailLink', |
||
42 | 'PrintLink', |
||
43 | 'RetrieveLink', |
||
44 | 'ShareLink', |
||
45 | 'FeedbackLink', |
||
46 | 'Title', |
||
47 | 'Total', |
||
48 | 'SubTotal', |
||
49 | 'TotalPaid', |
||
50 | 'TotalOutstanding', |
||
51 | 'ExchangeRate', |
||
52 | 'CurrencyUsed', |
||
53 | 'TotalItems', |
||
54 | 'TotalItemsTimesQuantity', |
||
55 | 'IsCancelled', |
||
56 | 'Country', |
||
57 | 'FullNameCountry', |
||
58 | 'IsSubmitted', |
||
59 | 'CustomerStatus', |
||
60 | 'CanHaveShippingAddress', |
||
61 | 'CancelledBy', |
||
62 | 'CurrencyUsed', |
||
63 | 'BillingAddress', |
||
64 | 'UseShippingAddress', |
||
65 | 'ShippingAddress', |
||
66 | 'Status', |
||
67 | 'Attributes', |
||
68 | 'OrderStatusLogs', |
||
69 | 'MemberID', |
||
70 | ), |
||
71 | ); |
||
72 | |||
73 | /** |
||
74 | * standard SS variable. |
||
75 | * |
||
76 | * @var array |
||
77 | */ |
||
78 | private static $db = array( |
||
79 | 'SessionID' => 'Varchar(32)', //so that in the future we can link sessions with Orders.... One session can have several orders, but an order can onnly have one session |
||
80 | 'UseShippingAddress' => 'Boolean', |
||
81 | 'CustomerOrderNote' => 'Text', |
||
82 | 'ExchangeRate' => 'Double', |
||
83 | //'TotalItems_Saved' => 'Double', |
||
84 | //'TotalItemsTimesQuantity_Saved' => 'Double' |
||
85 | ); |
||
86 | |||
87 | private static $has_one = array( |
||
88 | 'Member' => 'Member', |
||
89 | 'BillingAddress' => 'BillingAddress', |
||
90 | 'ShippingAddress' => 'ShippingAddress', |
||
91 | 'Status' => 'OrderStep', |
||
92 | 'CancelledBy' => 'Member', |
||
93 | 'CurrencyUsed' => 'EcommerceCurrency', |
||
94 | ); |
||
95 | |||
96 | /** |
||
97 | * standard SS variable. |
||
98 | * |
||
99 | * @var array |
||
100 | */ |
||
101 | private static $has_many = array( |
||
102 | 'Attributes' => 'OrderAttribute', |
||
103 | 'OrderStatusLogs' => 'OrderStatusLog', |
||
104 | 'Payments' => 'EcommercePayment', |
||
105 | 'Emails' => 'OrderEmailRecord', |
||
106 | 'OrderProcessQueue' => 'OrderProcessQueue' //there is usually only one. |
||
107 | ); |
||
108 | |||
109 | /** |
||
110 | * standard SS variable. |
||
111 | * |
||
112 | * @var array |
||
113 | */ |
||
114 | private static $indexes = array( |
||
115 | 'SessionID' => true, |
||
116 | ); |
||
117 | |||
118 | /** |
||
119 | * standard SS variable. |
||
120 | * |
||
121 | * @var string |
||
122 | */ |
||
123 | private static $default_sort = '"LastEdited" DESC'; |
||
124 | |||
125 | /** |
||
126 | * standard SS variable. |
||
127 | * |
||
128 | * @var array |
||
129 | */ |
||
130 | private static $casting = array( |
||
131 | 'OrderEmail' => 'Varchar', |
||
132 | 'EmailLink' => 'Varchar', |
||
133 | 'PrintLink' => 'Varchar', |
||
134 | 'ShareLink' => 'Varchar', |
||
135 | 'FeedbackLink' => 'Varchar', |
||
136 | 'RetrieveLink' => 'Varchar', |
||
137 | 'Title' => 'Varchar', |
||
138 | 'Total' => 'Currency', |
||
139 | 'TotalAsMoney' => 'Money', |
||
140 | 'SubTotal' => 'Currency', |
||
141 | 'SubTotalAsMoney' => 'Money', |
||
142 | 'TotalPaid' => 'Currency', |
||
143 | 'TotalPaidAsMoney' => 'Money', |
||
144 | 'TotalOutstanding' => 'Currency', |
||
145 | 'TotalOutstandingAsMoney' => 'Money', |
||
146 | 'HasAlternativeCurrency' => 'Boolean', |
||
147 | 'TotalItems' => 'Double', |
||
148 | 'TotalItemsTimesQuantity' => 'Double', |
||
149 | 'IsCancelled' => 'Boolean', |
||
150 | 'IsPaidNice' => 'Boolean', |
||
151 | 'Country' => 'Varchar(3)', //This is the applicable country for the order - for tax purposes, etc.... |
||
152 | 'FullNameCountry' => 'Varchar', |
||
153 | 'IsSubmitted' => 'Boolean', |
||
154 | 'CustomerStatus' => 'Varchar', |
||
155 | 'CanHaveShippingAddress' => 'Boolean', |
||
156 | ); |
||
157 | |||
158 | /** |
||
159 | * standard SS variable. |
||
160 | * |
||
161 | * @var string |
||
162 | */ |
||
163 | private static $singular_name = 'Order'; |
||
164 | public function i18n_singular_name() |
||
168 | |||
169 | /** |
||
170 | * standard SS variable. |
||
171 | * |
||
172 | * @var string |
||
173 | */ |
||
174 | private static $plural_name = 'Orders'; |
||
175 | public function i18n_plural_name() |
||
179 | |||
180 | /** |
||
181 | * Standard SS variable. |
||
182 | * |
||
183 | * @var string |
||
184 | */ |
||
185 | private static $description = "A collection of items that together make up the 'Order'. An order can be placed."; |
||
186 | |||
187 | /** |
||
188 | * Tells us if an order needs to be recalculated |
||
189 | * can save one for each order... |
||
190 | * |
||
191 | * @var array |
||
192 | */ |
||
193 | private static $_needs_recalculating = array(); |
||
194 | |||
195 | /** |
||
196 | * @param bool (optional) $b |
||
197 | * @param int (optional) $orderID |
||
198 | * |
||
199 | * @return bool |
||
200 | */ |
||
201 | public static function set_needs_recalculating($b = true, $orderID = 0) |
||
205 | |||
206 | /** |
||
207 | * @param int (optional) $orderID |
||
208 | * |
||
209 | * @return bool |
||
210 | */ |
||
211 | public static function get_needs_recalculating($orderID = 0) |
||
215 | |||
216 | /** |
||
217 | * Total Items : total items in cart |
||
218 | * We start with -1 to easily identify if it has been run before. |
||
219 | * |
||
220 | * @var int |
||
221 | */ |
||
222 | protected $totalItems = null; |
||
223 | |||
224 | /** |
||
225 | * Total Items : total items in cart |
||
226 | * We start with -1 to easily identify if it has been run before. |
||
227 | * |
||
228 | * @var float |
||
229 | */ |
||
230 | protected $totalItemsTimesQuantity = null; |
||
231 | |||
232 | /** |
||
233 | * Returns a set of modifier forms for use in the checkout order form, |
||
234 | * Controller is optional, because the orderForm has its own default controller. |
||
235 | * |
||
236 | * This method only returns the Forms that should be included outside |
||
237 | * the editable table... Forms within it can be called |
||
238 | * from through the modifier itself. |
||
239 | * |
||
240 | * @param Controller $optionalController |
||
241 | * @param Validator $optionalValidator |
||
242 | * |
||
243 | * @return ArrayList (ModifierForms) | Null |
||
244 | **/ |
||
245 | public function getModifierForms(Controller $optionalController = null, Validator $optionalValidator = null) |
||
267 | |||
268 | /** |
||
269 | * This function returns the OrderSteps. |
||
270 | * |
||
271 | * @return ArrayList (OrderSteps) |
||
272 | **/ |
||
273 | public static function get_order_status_options() |
||
277 | |||
278 | /** |
||
279 | * Like the standard byID, but it checks whether we are allowed to view the order. |
||
280 | * |
||
281 | * @return: Order | Null |
||
282 | **/ |
||
283 | public static function get_by_id_if_can_view($id) |
||
297 | |||
298 | /** |
||
299 | * returns a Datalist with the submitted order log included |
||
300 | * this allows you to sort the orders by their submit dates. |
||
301 | * You can retrieve this list and then add more to it (e.g. additional filters, additional joins, etc...). |
||
302 | * |
||
303 | * @param bool $onlySubmittedOrders - only include Orders that have already been submitted. |
||
304 | * @param bool $includeCancelledOrders - only include Orders that have already been submitted. |
||
305 | * |
||
306 | * @return DataList (Orders) |
||
307 | */ |
||
308 | public static function get_datalist_of_orders_with_submit_record($onlySubmittedOrders = true, $includeCancelledOrders = false) |
||
330 | |||
331 | /******************************************************* |
||
332 | * 1. CMS STUFF |
||
333 | *******************************************************/ |
||
334 | |||
335 | /** |
||
336 | * fields that we remove from the parent::getCMSFields object set. |
||
337 | * |
||
338 | * @var array |
||
339 | */ |
||
340 | protected $fieldsAndTabsToBeRemoved = array( |
||
341 | 'MemberID', |
||
342 | 'Attributes', |
||
343 | 'SessionID', |
||
344 | 'Emails', |
||
345 | 'BillingAddressID', |
||
346 | 'ShippingAddressID', |
||
347 | 'UseShippingAddress', |
||
348 | 'OrderStatusLogs', |
||
349 | 'Payments', |
||
350 | 'OrderDate', |
||
351 | 'ExchangeRate', |
||
352 | 'CurrencyUsedID', |
||
353 | 'StatusID', |
||
354 | 'Currency', |
||
355 | ); |
||
356 | |||
357 | /** |
||
358 | * STANDARD SILVERSTRIPE STUFF. |
||
359 | **/ |
||
360 | private static $summary_fields = array( |
||
361 | 'Title' => 'Title', |
||
362 | 'Status.Title' => 'Next Step', |
||
363 | 'Member.Surname' => 'Name', |
||
364 | 'Member.Email' => 'Email', |
||
365 | 'TotalAsMoney.Nice' => 'Total', |
||
366 | 'TotalItemsTimesQuantity' => 'Units', |
||
367 | 'IsPaidNice' => 'Paid' |
||
368 | ); |
||
369 | |||
370 | /** |
||
371 | * STANDARD SILVERSTRIPE STUFF. |
||
372 | * |
||
373 | * @todo: how to translate this? |
||
374 | **/ |
||
375 | private static $searchable_fields = array( |
||
376 | 'ID' => array( |
||
377 | 'field' => 'NumericField', |
||
378 | 'title' => 'Order Number', |
||
379 | ), |
||
380 | 'MemberID' => array( |
||
381 | 'field' => 'TextField', |
||
382 | 'filter' => 'OrderFilters_MemberAndAddress', |
||
383 | 'title' => 'Customer Details', |
||
384 | ), |
||
385 | 'Created' => array( |
||
386 | 'field' => 'TextField', |
||
387 | 'filter' => 'OrderFilters_AroundDateFilter', |
||
388 | 'title' => 'Date (e.g. Today, 1 jan 2007, or last week)', |
||
389 | ), |
||
390 | //make sure to keep the items below, otherwise they do not show in form |
||
391 | 'StatusID' => array( |
||
392 | 'filter' => 'OrderFilters_MultiOptionsetStatusIDFilter', |
||
393 | ), |
||
394 | 'CancelledByID' => array( |
||
395 | 'filter' => 'OrderFilters_HasBeenCancelled', |
||
396 | 'title' => 'Cancelled by ...', |
||
397 | ), |
||
398 | ); |
||
399 | |||
400 | /** |
||
401 | * Determine which properties on the DataObject are |
||
402 | * searchable, and map them to their default {@link FormField} |
||
403 | * representations. Used for scaffolding a searchform for {@link ModelAdmin}. |
||
404 | * |
||
405 | * Some additional logic is included for switching field labels, based on |
||
406 | * how generic or specific the field type is. |
||
407 | * |
||
408 | * Used by {@link SearchContext}. |
||
409 | * |
||
410 | * @param array $_params |
||
411 | * 'fieldClasses': Associative array of field names as keys and FormField classes as values |
||
412 | * 'restrictFields': Numeric array of a field name whitelist |
||
413 | * |
||
414 | * @return FieldList |
||
415 | */ |
||
416 | public function scaffoldSearchFields($_params = null) |
||
465 | |||
466 | /** |
||
467 | * link to edit the record. |
||
468 | * |
||
469 | * @param string | Null $action - e.g. edit |
||
470 | * |
||
471 | * @return string |
||
472 | */ |
||
473 | public function CMSEditLink($action = null) |
||
481 | |||
482 | /** |
||
483 | * STANDARD SILVERSTRIPE STUFF |
||
484 | * broken up into submitted and not (yet) submitted. |
||
485 | **/ |
||
486 | public function getCMSFields() |
||
865 | |||
866 | /** |
||
867 | * Field to add and edit Order Items. |
||
868 | * |
||
869 | * @return GridField |
||
870 | */ |
||
871 | protected function getOrderItemsField() |
||
878 | |||
879 | /** |
||
880 | * Field to add and edit Modifiers. |
||
881 | * |
||
882 | * @return GridField |
||
883 | */ |
||
884 | public function getModifierTableField() |
||
891 | |||
892 | /** |
||
893 | *@return GridField |
||
894 | **/ |
||
895 | protected function getBillingAddressField() |
||
911 | |||
912 | /** |
||
913 | *@return GridField |
||
914 | **/ |
||
915 | protected function getShippingAddressField() |
||
931 | |||
932 | /** |
||
933 | * Needs to be public because the OrderStep::getCMSFIelds accesses it. |
||
934 | * |
||
935 | * @param string $sourceClass |
||
936 | * @param string $title |
||
937 | * |
||
938 | * @return GridField |
||
939 | **/ |
||
940 | public function getOrderStatusLogsTableField( |
||
955 | |||
956 | /** |
||
957 | * Needs to be public because the OrderStep::getCMSFIelds accesses it. |
||
958 | * |
||
959 | * @param string $sourceClass |
||
960 | * @param string $title |
||
961 | * |
||
962 | * @return GridField |
||
963 | **/ |
||
964 | public function getOrderStatusLogsTableFieldEditable( |
||
974 | |||
975 | /** |
||
976 | * @param string $sourceClass |
||
977 | * @param string $title |
||
978 | * @param FieldList $fieldList (Optional) |
||
979 | * @param FieldList $detailedFormFields (Optional) |
||
980 | * |
||
981 | * @return GridField |
||
982 | **/ |
||
983 | protected function getOrderStatusLogsTableField_Archived( |
||
1000 | |||
1001 | /** |
||
1002 | * @return GridField |
||
1003 | **/ |
||
1004 | public function getEmailsTableField() |
||
1012 | |||
1013 | /** |
||
1014 | * @return GridField |
||
1015 | */ |
||
1016 | protected function getPaymentsField() |
||
1025 | |||
1026 | /** |
||
1027 | * @return OrderStepField |
||
1028 | */ |
||
1029 | public function OrderStepField() |
||
1033 | |||
1034 | /******************************************************* |
||
1035 | * 2. MAIN TRANSITION FUNCTIONS |
||
1036 | *******************************************************/ |
||
1037 | |||
1038 | /** |
||
1039 | * init runs on start of a new Order (@see onAfterWrite) |
||
1040 | * it adds all the modifiers to the orders and the starting OrderStep. |
||
1041 | * |
||
1042 | * @param bool $recalculate |
||
1043 | * |
||
1044 | * @return DataObject (Order) |
||
1045 | **/ |
||
1046 | public function init($recalculate = false) |
||
1106 | |||
1107 | /** |
||
1108 | * @var array |
||
1109 | */ |
||
1110 | private static $_try_to_finalise_order_is_running = array(); |
||
1111 | |||
1112 | /** |
||
1113 | * Goes through the order steps and tries to "apply" the next status to the order. |
||
1114 | * |
||
1115 | * @param bool $runAgain |
||
1116 | * @param bool $fromOrderQueue - is it being called from the OrderProcessQueue (or similar) |
||
1117 | **/ |
||
1118 | public function tryToFinaliseOrder($runAgain = false, $fromOrderQueue = false) |
||
1170 | |||
1171 | /** |
||
1172 | * Goes through the order steps and tries to "apply" the next step |
||
1173 | * Step is updated after the other one is completed... |
||
1174 | * |
||
1175 | * @return int (StatusID or false if the next status can not be "applied") |
||
1176 | **/ |
||
1177 | public function doNextStatus() |
||
1192 | |||
1193 | /** |
||
1194 | * cancel an order. |
||
1195 | * |
||
1196 | * @param Member $member - (optional) the user cancelling the order |
||
1197 | * @param string $reason - (optional) the reason the order is cancelled |
||
1198 | * |
||
1199 | * @return OrderStatusLog_Cancel |
||
1200 | */ |
||
1201 | public function Cancel($member = null, $reason = '') |
||
1234 | |||
1235 | /** |
||
1236 | * returns true if successful. |
||
1237 | * |
||
1238 | * @param bool $avoidWrites |
||
1239 | * |
||
1240 | * @return bool |
||
1241 | */ |
||
1242 | public function Archive($avoidWrites = true) |
||
1265 | |||
1266 | /******************************************************* |
||
1267 | * 3. STATUS RELATED FUNCTIONS / SHORTCUTS |
||
1268 | *******************************************************/ |
||
1269 | |||
1270 | /** |
||
1271 | * Avoids caching of $this->Status(). |
||
1272 | * |
||
1273 | * @return DataObject (current OrderStep) |
||
1274 | */ |
||
1275 | public function MyStep() |
||
1293 | |||
1294 | /** |
||
1295 | * Return the OrderStatusLog that is relevant to the Order status. |
||
1296 | * |
||
1297 | * @return OrderStatusLog |
||
1298 | */ |
||
1299 | public function RelevantLogEntry() |
||
1303 | |||
1304 | /** |
||
1305 | * @return OrderStep (current OrderStep that can be seen by customer) |
||
1306 | */ |
||
1307 | public function CurrentStepVisibleToCustomer() |
||
1319 | |||
1320 | /** |
||
1321 | * works out if the order is still at the first OrderStep. |
||
1322 | * |
||
1323 | * @return bool |
||
1324 | */ |
||
1325 | public function IsFirstStep() |
||
1337 | |||
1338 | /** |
||
1339 | * Is the order still being "edited" by the customer? |
||
1340 | * |
||
1341 | * @return bool |
||
1342 | */ |
||
1343 | public function IsInCart() |
||
1347 | |||
1348 | /** |
||
1349 | * The order has "passed" the IsInCart phase. |
||
1350 | * |
||
1351 | * @return bool |
||
1352 | */ |
||
1353 | public function IsPastCart() |
||
1357 | |||
1358 | /** |
||
1359 | * Are there still steps the order needs to go through? |
||
1360 | * |
||
1361 | * @return bool |
||
1362 | */ |
||
1363 | public function IsUncomplete() |
||
1367 | |||
1368 | /** |
||
1369 | * Is the order in the :"processing" phaase.? |
||
1370 | * |
||
1371 | * @return bool |
||
1372 | */ |
||
1373 | public function IsProcessing() |
||
1377 | |||
1378 | /** |
||
1379 | * Is the order completed? |
||
1380 | * |
||
1381 | * @return bool |
||
1382 | */ |
||
1383 | public function IsCompleted() |
||
1387 | |||
1388 | /** |
||
1389 | * Has the order been paid? |
||
1390 | * TODO: why do we check if there is a total at all? |
||
1391 | * |
||
1392 | * @return bool |
||
1393 | */ |
||
1394 | public function IsPaid() |
||
1402 | /** |
||
1403 | * Has the order been paid? |
||
1404 | * TODO: why do we check if there is a total at all? |
||
1405 | * |
||
1406 | * @return Boolean (object) |
||
1407 | */ |
||
1408 | public function IsPaidNice() |
||
1412 | |||
1413 | /** |
||
1414 | * Has the order been paid? |
||
1415 | * TODO: why do we check if there is a total at all? |
||
1416 | * |
||
1417 | * @return bool |
||
1418 | */ |
||
1419 | public function PaymentIsPending() |
||
1435 | |||
1436 | /** |
||
1437 | * shows payments that are meaningfull |
||
1438 | * if the order has been paid then only show successful payments. |
||
1439 | * |
||
1440 | * @return DataList |
||
1441 | */ |
||
1442 | public function RelevantPayments() |
||
1452 | |||
1453 | /** |
||
1454 | * Has the order been cancelled? |
||
1455 | * |
||
1456 | * @return bool |
||
1457 | */ |
||
1458 | public function IsCancelled() |
||
1466 | |||
1467 | /** |
||
1468 | * Has the order been cancelled by the customer? |
||
1469 | * |
||
1470 | * @return bool |
||
1471 | */ |
||
1472 | public function IsCustomerCancelled() |
||
1480 | |||
1481 | /** |
||
1482 | * Has the order been cancelled by the administrator? |
||
1483 | * |
||
1484 | * @return bool |
||
1485 | */ |
||
1486 | public function IsAdminCancelled() |
||
1501 | |||
1502 | /** |
||
1503 | * Is the Shop Closed for business? |
||
1504 | * |
||
1505 | * @return bool |
||
1506 | */ |
||
1507 | public function ShopClosed() |
||
1511 | |||
1512 | /******************************************************* |
||
1513 | * 4. LINKING ORDER WITH MEMBER AND ADDRESS |
||
1514 | *******************************************************/ |
||
1515 | |||
1516 | /** |
||
1517 | * Returns a member linked to the order. |
||
1518 | * If a member is already linked, it will return the existing member. |
||
1519 | * Otherwise it will return a new Member. |
||
1520 | * |
||
1521 | * Any new member is NOT written, because we dont want to create a new member unless we have to! |
||
1522 | * We will not add a member to the order unless a new one is created in the checkout |
||
1523 | * OR the member is logged in / logs in. |
||
1524 | * |
||
1525 | * Also note that if a new member is created, it is not automatically written |
||
1526 | * |
||
1527 | * @param bool $forceCreation - if set to true then the member will always be saved in the database. |
||
1528 | * |
||
1529 | * @return Member |
||
1530 | **/ |
||
1531 | public function CreateOrReturnExistingMember($forceCreation = false) |
||
1554 | |||
1555 | /** |
||
1556 | * Returns either the existing one or a new Order Address... |
||
1557 | * All Orders will have a Shipping and Billing address attached to it. |
||
1558 | * Method used to retrieve object e.g. for $order->BillingAddress(); "BillingAddress" is the method name you can use. |
||
1559 | * If the method name is the same as the class name then dont worry about providing one. |
||
1560 | * |
||
1561 | * @param string $className - ClassName of the Address (e.g. BillingAddress or ShippingAddress) |
||
1562 | * @param string $alternativeMethodName - method to retrieve Address |
||
1563 | **/ |
||
1564 | public function CreateOrReturnExistingAddress($className = 'BillingAddress', $alternativeMethodName = '') |
||
1608 | |||
1609 | /** |
||
1610 | * Sets the country in the billing and shipping address. |
||
1611 | * |
||
1612 | * @param string $countryCode - code for the country e.g. NZ |
||
1613 | * @param bool $includeBillingAddress |
||
1614 | * @param bool $includeShippingAddress |
||
1615 | **/ |
||
1616 | public function SetCountryFields($countryCode, $includeBillingAddress = true, $includeShippingAddress = true) |
||
1635 | |||
1636 | /** |
||
1637 | * Sets the region in the billing and shipping address. |
||
1638 | * |
||
1639 | * @param int $regionID - ID for the region to be set |
||
1640 | **/ |
||
1641 | public function SetRegionFields($regionID) |
||
1656 | |||
1657 | /** |
||
1658 | * Stores the preferred currency of the order. |
||
1659 | * IMPORTANTLY we store the exchange rate for future reference... |
||
1660 | * |
||
1661 | * @param EcommerceCurrency $currency |
||
1662 | */ |
||
1663 | public function UpdateCurrency($newCurrency) |
||
1676 | |||
1677 | /** |
||
1678 | * alias for UpdateCurrency. |
||
1679 | * |
||
1680 | * @param EcommerceCurrency $currency |
||
1681 | */ |
||
1682 | public function SetCurrency($currency) |
||
1686 | |||
1687 | /******************************************************* |
||
1688 | * 5. CUSTOMER COMMUNICATION |
||
1689 | *******************************************************/ |
||
1690 | |||
1691 | /** |
||
1692 | * Send the invoice of the order by email. |
||
1693 | * |
||
1694 | * @param string $emailClassName (optional) class used to send email |
||
1695 | * @param string $subject (optional) subject for the email |
||
1696 | * @param string $message (optional) the main message in the email |
||
1697 | * @param bool $resend (optional) send the email even if it has been sent before |
||
1698 | * @param bool $adminOnlyOrToEmail (optional) sends the email to the ADMIN ONLY, if you provide an email, it will go to the email... |
||
1699 | * |
||
1700 | * @return bool TRUE on success, FALSE on failure |
||
1701 | */ |
||
1702 | public function sendEmail( |
||
1717 | |||
1718 | /** |
||
1719 | * Sends a message to the shop admin ONLY and not to the customer |
||
1720 | * This can be used by ordersteps and orderlogs to notify the admin of any potential problems. |
||
1721 | * |
||
1722 | * @param string $emailClassName - (optional) template to be used ... |
||
1723 | * @param string $subject - (optional) subject for the email |
||
1724 | * @param string $message - (optional) message to be added with the email |
||
1725 | * @param bool $resend - (optional) can it be sent twice? |
||
1726 | * @param bool | string $adminOnlyOrToEmail - (optional) sends the email to the ADMIN ONLY, if you provide an email, it will go to the email... |
||
1727 | * |
||
1728 | * @return bool TRUE for success, FALSE for failure (not tested) |
||
1729 | */ |
||
1730 | public function sendAdminNotification( |
||
1745 | |||
1746 | /** |
||
1747 | * returns the order formatted as an email. |
||
1748 | * |
||
1749 | * @param string $emailClassName - template to use. |
||
1750 | * @param string $subject - (optional) the subject (which can be used as title in email) |
||
1751 | * @param string $message - (optional) the additional message |
||
1752 | * |
||
1753 | * @return string (html) |
||
1754 | */ |
||
1755 | public function renderOrderInEmailFormat( |
||
1769 | |||
1770 | /** |
||
1771 | * Send a mail of the order to the client (and another to the admin). |
||
1772 | * |
||
1773 | * @param string $emailClassName - (optional) template to be used ... |
||
1774 | * @param string $subject - (optional) subject for the email |
||
1775 | * @param string $message - (optional) message to be added with the email |
||
1776 | * @param bool $resend - (optional) can it be sent twice? |
||
1777 | * @param bool | string $adminOnlyOrToEmail - (optional) sends the email to the ADMIN ONLY, if you provide an email, it will go to the email... |
||
1778 | * |
||
1779 | * @return bool TRUE for success, FALSE for failure (not tested) |
||
1780 | */ |
||
1781 | protected function prepareAndSendEmail( |
||
1838 | |||
1839 | /** |
||
1840 | * returns the Data that can be used in the body of an order Email |
||
1841 | * we add the subject here so that the subject, for example, can be added to the <title> |
||
1842 | * of the email template. |
||
1843 | * we add the subject here so that the subject, for example, can be added to the <title> |
||
1844 | * of the email template. |
||
1845 | * |
||
1846 | * @param string $subject - (optional) subject for email |
||
1847 | * @param string $message - (optional) the additional message |
||
1848 | * |
||
1849 | * @return ArrayData |
||
1850 | * - Subject - EmailSubject |
||
1851 | * - Message - specific message for this order |
||
1852 | * - Message - custom message |
||
1853 | * - OrderStepMessage - generic message for step |
||
1854 | * - Order |
||
1855 | * - EmailLogo |
||
1856 | * - ShopPhysicalAddress |
||
1857 | * - CurrentDateAndTime |
||
1858 | * - BaseURL |
||
1859 | * - CC |
||
1860 | * - BCC |
||
1861 | */ |
||
1862 | protected function createReplacementArrayForEmail($subject = '', $message = '') |
||
1891 | |||
1892 | /******************************************************* |
||
1893 | * 6. ITEM MANAGEMENT |
||
1894 | *******************************************************/ |
||
1895 | |||
1896 | /** |
||
1897 | * returns a list of Order Attributes by type. |
||
1898 | * |
||
1899 | * @param array | String $types |
||
1900 | * |
||
1901 | * @return ArrayList |
||
1902 | */ |
||
1903 | public function getOrderAttributesByType($types) |
||
1927 | |||
1928 | /** |
||
1929 | * Returns the items of the order. |
||
1930 | * Items are the order items (products) and NOT the modifiers (discount, tax, etc...). |
||
1931 | * |
||
1932 | * N. B. this method returns Order Items |
||
1933 | * also see Buaybles |
||
1934 | |||
1935 | * |
||
1936 | * @param string filter - where statement to exclude certain items OR ClassName (e.g. 'TaxModifier') |
||
1937 | * |
||
1938 | * @return DataList (OrderItems) |
||
1939 | */ |
||
1940 | public function Items($filterOrClassName = '') |
||
1948 | |||
1949 | /** |
||
1950 | * @alias function of Items |
||
1951 | * |
||
1952 | * N. B. this method returns Order Items |
||
1953 | * also see Buaybles |
||
1954 | * |
||
1955 | * @param string filter - where statement to exclude certain items. |
||
1956 | * @alias for Items |
||
1957 | * @return DataList (OrderItems) |
||
1958 | */ |
||
1959 | public function OrderItems($filterOrClassName = '') |
||
1963 | |||
1964 | /** |
||
1965 | * returns the buyables asscoiated with the order items. |
||
1966 | * |
||
1967 | * NB. this method retursn buyables |
||
1968 | * |
||
1969 | * @param string filter - where statement to exclude certain items. |
||
1970 | * |
||
1971 | * @return ArrayList (Buyables) |
||
1972 | */ |
||
1973 | public function Buyables($filterOrClassName = '') |
||
1983 | |||
1984 | /** |
||
1985 | * Return all the {@link OrderItem} instances that are |
||
1986 | * available as records in the database. |
||
1987 | * |
||
1988 | * @param string filter - where statement to exclude certain items, |
||
1989 | * you can also pass a classname (e.g. MyOrderItem), in which case only this class will be returned (and any class extending your given class) |
||
1990 | * |
||
1991 | * @return DataList (OrderItems) |
||
1992 | */ |
||
1993 | protected function itemsFromDatabase($filterOrClassName = '') |
||
2007 | |||
2008 | /** |
||
2009 | * @alias for Modifiers |
||
2010 | * |
||
2011 | * @return DataList (OrderModifiers) |
||
2012 | */ |
||
2013 | public function OrderModifiers() |
||
2017 | |||
2018 | /** |
||
2019 | * Returns the modifiers of the order, if it hasn't been saved yet |
||
2020 | * it returns the modifiers from session, if it has, it returns them |
||
2021 | * from the DB entry. ONLY USE OUTSIDE ORDER. |
||
2022 | * |
||
2023 | * @param string filter - where statement to exclude certain items OR ClassName (e.g. 'TaxModifier') |
||
2024 | * |
||
2025 | * @return DataList (OrderModifiers) |
||
2026 | */ |
||
2027 | public function Modifiers($filterOrClassName = '') |
||
2031 | |||
2032 | /** |
||
2033 | * Get all {@link OrderModifier} instances that are |
||
2034 | * available as records in the database. |
||
2035 | * NOTE: includes REMOVED Modifiers, so that they do not get added again... |
||
2036 | * |
||
2037 | * @param string filter - where statement to exclude certain items OR ClassName (e.g. 'TaxModifier') |
||
2038 | * |
||
2039 | * @return DataList (OrderModifiers) |
||
2040 | */ |
||
2041 | protected function modifiersFromDatabase($filterOrClassName = '') |
||
2055 | |||
2056 | /** |
||
2057 | * Calculates and updates all the order attributes. |
||
2058 | * |
||
2059 | * @param bool $recalculate - run it, even if it has run already |
||
2060 | */ |
||
2061 | public function calculateOrderAttributes($recalculate = false) |
||
2075 | |||
2076 | /** |
||
2077 | * Calculates and updates all the product items. |
||
2078 | * |
||
2079 | * @param bool $recalculate - run it, even if it has run already |
||
2080 | */ |
||
2081 | protected function calculateOrderItems($recalculate = false) |
||
2096 | |||
2097 | /** |
||
2098 | * Calculates and updates all the modifiers. |
||
2099 | * |
||
2100 | * @param bool $recalculate - run it, even if it has run already |
||
2101 | */ |
||
2102 | protected function calculateModifiers($recalculate = false) |
||
2114 | |||
2115 | /** |
||
2116 | * Returns the subtotal of the modifiers for this order. |
||
2117 | * If a modifier appears in the excludedModifiers array, it is not counted. |
||
2118 | * |
||
2119 | * @param string|array $excluded - Class(es) of modifier(s) to ignore in the calculation. |
||
2120 | * @param bool $stopAtExcludedModifier - when this flag is TRUE, we stop adding the modifiers when we reach an excluded modifier. |
||
2121 | * |
||
2122 | * @return float |
||
2123 | */ |
||
2124 | public function ModifiersSubTotal($excluded = null, $stopAtExcludedModifier = false) |
||
2151 | |||
2152 | /** |
||
2153 | * returns a modifier that is an instanceof the classname |
||
2154 | * it extends. |
||
2155 | * |
||
2156 | * @param string $className: class name for the modifier |
||
2157 | * |
||
2158 | * @return DataObject (OrderModifier) |
||
2159 | **/ |
||
2160 | public function RetrieveModifier($className) |
||
2171 | |||
2172 | /******************************************************* |
||
2173 | * 7. CRUD METHODS (e.g. canView, canEdit, canDelete, etc...) |
||
2174 | *******************************************************/ |
||
2175 | |||
2176 | /** |
||
2177 | * @param Member $member |
||
2178 | * |
||
2179 | * @return DataObject (Member) |
||
2180 | **/ |
||
2181 | //TODO: please comment why we make use of this function |
||
2182 | protected function getMemberForCanFunctions(Member $member = null) |
||
2194 | |||
2195 | /** |
||
2196 | * @param Member $member |
||
2197 | * |
||
2198 | * @return bool |
||
2199 | **/ |
||
2200 | public function canCreate($member = null) |
||
2211 | |||
2212 | /** |
||
2213 | * Standard SS method - can the current member view this order? |
||
2214 | * |
||
2215 | * @param Member $member |
||
2216 | * |
||
2217 | * @return bool |
||
2218 | **/ |
||
2219 | public function canView($member = null) |
||
2264 | |||
2265 | /** |
||
2266 | * @param Member $member optional |
||
2267 | * @return bool |
||
2268 | */ |
||
2269 | public function canOverrideCanView($member = null) |
||
2290 | |||
2291 | /** |
||
2292 | * @return bool |
||
2293 | */ |
||
2294 | public function IsInSession() |
||
2300 | |||
2301 | /** |
||
2302 | * returns a pseudo random part of the session id. |
||
2303 | * |
||
2304 | * @param int $size |
||
2305 | * |
||
2306 | * @return string |
||
2307 | */ |
||
2308 | public function LessSecureSessionID($size = 7, $start = null) |
||
2316 | /** |
||
2317 | * |
||
2318 | * @param Member (optional) $member |
||
2319 | * |
||
2320 | * @return bool |
||
2321 | **/ |
||
2322 | public function canViewAdminStuff($member = null) |
||
2333 | |||
2334 | /** |
||
2335 | * if we set canEdit to false then we |
||
2336 | * can not see the child records |
||
2337 | * Basically, you can edit when you can view and canEdit (even as a customer) |
||
2338 | * Or if you are a Shop Admin you can always edit. |
||
2339 | * Otherwise it is false... |
||
2340 | * |
||
2341 | * @param Member $member |
||
2342 | * |
||
2343 | * @return bool |
||
2344 | **/ |
||
2345 | public function canEdit($member = null) |
||
2364 | |||
2365 | /** |
||
2366 | * is the order ready to go through to the |
||
2367 | * checkout process. |
||
2368 | * |
||
2369 | * This method checks all the order items and order modifiers |
||
2370 | * If any of them need immediate attention then this is done |
||
2371 | * first after which it will go through to the checkout page. |
||
2372 | * |
||
2373 | * @param Member (optional) $member |
||
2374 | * |
||
2375 | * @return bool |
||
2376 | **/ |
||
2377 | public function canCheckout(Member $member = null) |
||
2391 | |||
2392 | /** |
||
2393 | * Can the order be submitted? |
||
2394 | * this method can be used to stop an order from being submitted |
||
2395 | * due to something not being completed or done. |
||
2396 | * |
||
2397 | * @see Order::SubmitErrors |
||
2398 | * |
||
2399 | * @param Member $member |
||
2400 | * |
||
2401 | * @return bool |
||
2402 | **/ |
||
2403 | public function canSubmit(Member $member = null) |
||
2420 | |||
2421 | /** |
||
2422 | * Can a payment be made for this Order? |
||
2423 | * |
||
2424 | * @param Member $member |
||
2425 | * |
||
2426 | * @return bool |
||
2427 | **/ |
||
2428 | public function canPay(Member $member = null) |
||
2441 | |||
2442 | /** |
||
2443 | * Can the given member cancel this order? |
||
2444 | * |
||
2445 | * @param Member $member |
||
2446 | * |
||
2447 | * @return bool |
||
2448 | **/ |
||
2449 | public function canCancel(Member $member = null) |
||
2466 | |||
2467 | /** |
||
2468 | * @param Member $member |
||
2469 | * |
||
2470 | * @return bool |
||
2471 | **/ |
||
2472 | public function canDelete($member = null) |
||
2488 | |||
2489 | /** |
||
2490 | * Returns all the order logs that the current member can view |
||
2491 | * i.e. some order logs can only be viewed by the admin (e.g. suspected fraud orderlog). |
||
2492 | * |
||
2493 | * @return ArrayList (OrderStatusLogs) |
||
2494 | **/ |
||
2495 | public function CanViewOrderStatusLogs() |
||
2507 | |||
2508 | /** |
||
2509 | * returns all the logs that can be viewed by the customer. |
||
2510 | * |
||
2511 | * @return ArrayList (OrderStausLogs) |
||
2512 | */ |
||
2513 | public function CustomerViewableOrderStatusLogs() |
||
2527 | |||
2528 | /******************************************************* |
||
2529 | * 8. GET METHODS (e.g. Total, SubTotal, Title, etc...) |
||
2530 | *******************************************************/ |
||
2531 | |||
2532 | /** |
||
2533 | * returns the email to be used for customer communication. |
||
2534 | * |
||
2535 | * @return string |
||
2536 | */ |
||
2537 | public function OrderEmail() |
||
2559 | |||
2560 | /** |
||
2561 | * Returns true if there is a prink or email link. |
||
2562 | * |
||
2563 | * @return bool |
||
2564 | */ |
||
2565 | public function HasPrintOrEmailLink() |
||
2569 | |||
2570 | /** |
||
2571 | * returns the absolute link to the order that can be used in the customer communication (email). |
||
2572 | * |
||
2573 | * @return string |
||
2574 | */ |
||
2575 | public function EmailLink($type = 'Order_StatusEmail') |
||
2587 | |||
2588 | /** |
||
2589 | * returns the absolute link to the order for printing. |
||
2590 | * |
||
2591 | * @return string |
||
2592 | */ |
||
2593 | public function PrintLink() |
||
2605 | |||
2606 | /** |
||
2607 | * returns the absolute link to the order for printing. |
||
2608 | * |
||
2609 | * @return string |
||
2610 | */ |
||
2611 | public function PackingSlipLink() |
||
2621 | |||
2622 | /** |
||
2623 | * returns the absolute link that the customer can use to retrieve the email WITHOUT logging in. |
||
2624 | * |
||
2625 | * @return string |
||
2626 | */ |
||
2627 | public function RetrieveLink() |
||
2631 | |||
2632 | public function getRetrieveLink() |
||
2646 | |||
2647 | public function ShareLink() |
||
2651 | |||
2652 | public function getShareLink() |
||
2670 | |||
2671 | /** |
||
2672 | * @alias for getFeedbackLink |
||
2673 | * @return string |
||
2674 | */ |
||
2675 | public function FeedbackLink() |
||
2679 | |||
2680 | /** |
||
2681 | * @return string |
||
2682 | */ |
||
2683 | public function getFeedbackLink() |
||
2691 | |||
2692 | /** |
||
2693 | * link to delete order. |
||
2694 | * |
||
2695 | * @return string |
||
2696 | */ |
||
2697 | public function DeleteLink() |
||
2709 | |||
2710 | /** |
||
2711 | * link to copy order. |
||
2712 | * |
||
2713 | * @return string |
||
2714 | */ |
||
2715 | public function CopyOrderLink() |
||
2727 | |||
2728 | /** |
||
2729 | * A "Title" for the order, which summarises the main details (date, and customer) in a string. |
||
2730 | * |
||
2731 | * @param string $dateFormat - e.g. "D j M Y, G:i T" |
||
2732 | * @param bool $includeName - e.g. by Mr Johnson |
||
2733 | * |
||
2734 | * @return string |
||
2735 | **/ |
||
2736 | public function Title($dateFormat = null, $includeName = false) |
||
2799 | |||
2800 | /** |
||
2801 | * Returns the subtotal of the items for this order. |
||
2802 | * |
||
2803 | * @return float |
||
2804 | */ |
||
2805 | public function SubTotal() |
||
2823 | |||
2824 | /** |
||
2825 | * @return Currency (DB Object) |
||
2826 | **/ |
||
2827 | public function SubTotalAsCurrencyObject() |
||
2831 | |||
2832 | /** |
||
2833 | * @return Money |
||
2834 | **/ |
||
2835 | public function SubTotalAsMoney() |
||
2843 | |||
2844 | /** |
||
2845 | * @param string|array $excluded - Class(es) of modifier(s) to ignore in the calculation. |
||
2846 | * @param bool $stopAtExcludedModifier - when this flag is TRUE, we stop adding the modifiers when we reach an excluded modifier. |
||
2847 | * |
||
2848 | * @return Currency (DB Object) |
||
2849 | **/ |
||
2850 | public function ModifiersSubTotalAsCurrencyObject($excluded = null, $stopAtExcludedModifier = false) |
||
2854 | |||
2855 | /** |
||
2856 | * @param string|array $excluded - Class(es) of modifier(s) to ignore in the calculation. |
||
2857 | * @param bool $stopAtExcludedModifier - when this flag is TRUE, we stop adding the modifiers when we reach an excluded modifier. |
||
2858 | * |
||
2859 | * @return Money (DB Object) |
||
2860 | **/ |
||
2861 | public function ModifiersSubTotalAsMoneyObject($excluded = null, $stopAtExcludedModifier = false) |
||
2865 | |||
2866 | /** |
||
2867 | * Returns the total cost of an order including the additional charges or deductions of its modifiers. |
||
2868 | * |
||
2869 | * @return float |
||
2870 | */ |
||
2871 | public function Total() |
||
2879 | |||
2880 | /** |
||
2881 | * @return Currency (DB Object) |
||
2882 | **/ |
||
2883 | public function TotalAsCurrencyObject() |
||
2887 | |||
2888 | /** |
||
2889 | * @return Money |
||
2890 | **/ |
||
2891 | public function TotalAsMoney() |
||
2899 | |||
2900 | /** |
||
2901 | * Checks to see if any payments have been made on this order |
||
2902 | * and if so, subracts the payment amount from the order. |
||
2903 | * |
||
2904 | * @return float |
||
2905 | **/ |
||
2906 | public function TotalOutstanding() |
||
2926 | |||
2927 | /** |
||
2928 | * @return Currency (DB Object) |
||
2929 | **/ |
||
2930 | public function TotalOutstandingAsCurrencyObject() |
||
2934 | |||
2935 | /** |
||
2936 | * @return Money |
||
2937 | **/ |
||
2938 | public function TotalOutstandingAsMoney() |
||
2946 | |||
2947 | /** |
||
2948 | * @return float |
||
2949 | */ |
||
2950 | public function TotalPaid() |
||
2971 | |||
2972 | /** |
||
2973 | * @return Currency (DB Object) |
||
2974 | **/ |
||
2975 | public function TotalPaidAsCurrencyObject() |
||
2979 | |||
2980 | /** |
||
2981 | * @return Money |
||
2982 | **/ |
||
2983 | public function TotalPaidAsMoney() |
||
2991 | |||
2992 | /** |
||
2993 | * returns the total number of OrderItems (not modifiers). |
||
2994 | * This is meant to run as fast as possible to quickly check |
||
2995 | * if there is anything in the cart. |
||
2996 | * |
||
2997 | * @param bool $recalculate - do we need to recalculate (value is retained during lifetime of Object) |
||
2998 | * |
||
2999 | * @return int |
||
3000 | **/ |
||
3001 | public function TotalItems($recalculate = false) |
||
3015 | |||
3016 | /** |
||
3017 | * Little shorthand. |
||
3018 | * |
||
3019 | * @param bool $recalculate |
||
3020 | * |
||
3021 | * @return bool |
||
3022 | **/ |
||
3023 | public function MoreThanOneItemInCart($recalculate = false) |
||
3027 | |||
3028 | /** |
||
3029 | * returns the total number of OrderItems (not modifiers) times their respectective quantities. |
||
3030 | * |
||
3031 | * @param bool $recalculate - force recalculation |
||
3032 | * |
||
3033 | * @return float |
||
3034 | **/ |
||
3035 | public function TotalItemsTimesQuantity($recalculate = false) |
||
3055 | |||
3056 | /** |
||
3057 | * |
||
3058 | * @return string (country code) |
||
3059 | **/ |
||
3060 | public function Country() |
||
3064 | |||
3065 | /** |
||
3066 | * Returns the country code for the country that applies to the order. |
||
3067 | * @alias for getCountry |
||
3068 | * |
||
3069 | * @return string - country code e.g. NZ |
||
3070 | */ |
||
3071 | public function getCountry() |
||
3108 | |||
3109 | /** |
||
3110 | * @alias for getFullNameCountry |
||
3111 | * |
||
3112 | * @return string - country name |
||
3113 | **/ |
||
3114 | public function FullNameCountry() |
||
3118 | |||
3119 | /** |
||
3120 | * returns name of coutry. |
||
3121 | * |
||
3122 | * @return string - country name |
||
3123 | **/ |
||
3124 | public function getFullNameCountry() |
||
3128 | |||
3129 | /** |
||
3130 | * @alis for getExpectedCountryName |
||
3131 | * @return string - country name |
||
3132 | **/ |
||
3133 | public function ExpectedCountryName() |
||
3137 | |||
3138 | /** |
||
3139 | * returns name of coutry that we expect the customer to have |
||
3140 | * This takes into consideration more than just what has been entered |
||
3141 | * for example, it looks at GEO IP. |
||
3142 | * |
||
3143 | * @todo: why do we dont return a string IF there is only one item. |
||
3144 | * |
||
3145 | * @return string - country name |
||
3146 | **/ |
||
3147 | public function getExpectedCountryName() |
||
3151 | |||
3152 | /** |
||
3153 | * return the title of the fixed country (if any). |
||
3154 | * |
||
3155 | * @return string | empty string |
||
3156 | **/ |
||
3157 | public function FixedCountry() |
||
3170 | |||
3171 | /** |
||
3172 | * Returns the region that applies to the order. |
||
3173 | * we check both billing and shipping, in case one of them is empty. |
||
3174 | * |
||
3175 | * @return DataObject | Null (EcommerceRegion) |
||
3176 | **/ |
||
3177 | public function Region() |
||
3214 | |||
3215 | /** |
||
3216 | * Casted variable |
||
3217 | * Currency is not the same as the standard one? |
||
3218 | * |
||
3219 | * @return bool |
||
3220 | **/ |
||
3221 | public function HasAlternativeCurrency() |
||
3237 | |||
3238 | /** |
||
3239 | * Makes sure exchange rate is updated and maintained before order is submitted |
||
3240 | * This method is public because it could be called from a shopping Cart Object. |
||
3241 | **/ |
||
3242 | public function EnsureCorrectExchangeRate() |
||
3260 | |||
3261 | /** |
||
3262 | * speeds up processing by storing the IsSubmitted value |
||
3263 | * we start with -1 to know if it has been requested before. |
||
3264 | * |
||
3265 | * @var bool |
||
3266 | */ |
||
3267 | protected $_isSubmittedTempVar = -1; |
||
3268 | |||
3269 | /** |
||
3270 | * Casted variable - has the order been submitted? |
||
3271 | * alias |
||
3272 | * @param bool $recalculate |
||
3273 | * |
||
3274 | * @return bool |
||
3275 | **/ |
||
3276 | public function IsSubmitted($recalculate = true) |
||
3280 | |||
3281 | /** |
||
3282 | * Casted variable - has the order been submitted? |
||
3283 | * |
||
3284 | * @param bool $recalculate |
||
3285 | * |
||
3286 | * @return bool |
||
3287 | **/ |
||
3288 | public function getIsSubmitted($recalculate = false) |
||
3300 | |||
3301 | /** |
||
3302 | * |
||
3303 | * |
||
3304 | * @return bool |
||
3305 | */ |
||
3306 | public function IsArchived() |
||
3316 | |||
3317 | /** |
||
3318 | * Submission Log for this Order (if any). |
||
3319 | * |
||
3320 | * @return Submission Log (OrderStatusLog_Submitted) | Null |
||
3321 | **/ |
||
3322 | public function SubmissionLog() |
||
3330 | |||
3331 | /** |
||
3332 | * @return int |
||
3333 | */ |
||
3334 | public function SecondsSinceBeingSubmitted() |
||
3342 | |||
3343 | /** |
||
3344 | * if the order can not be submitted, |
||
3345 | * then the reasons why it can not be submitted |
||
3346 | * will be returned by this method. |
||
3347 | * |
||
3348 | * @see Order::canSubmit |
||
3349 | * |
||
3350 | * @return ArrayList | null |
||
3351 | */ |
||
3352 | public function SubmitErrors() |
||
3368 | |||
3369 | /** |
||
3370 | * Casted variable - has the order been submitted? |
||
3371 | * |
||
3372 | * @param bool $withDetail |
||
3373 | * |
||
3374 | * @return string |
||
3375 | **/ |
||
3376 | public function CustomerStatus($withDetail = true) |
||
3398 | |||
3399 | /** |
||
3400 | * Casted variable - does the order have a potential shipping address? |
||
3401 | * |
||
3402 | * @return bool |
||
3403 | **/ |
||
3404 | public function CanHaveShippingAddress() |
||
3412 | |||
3413 | /** |
||
3414 | * returns the link to view the Order |
||
3415 | * WHY NOT CHECKOUT PAGE: first we check for cart page. |
||
3416 | * |
||
3417 | * @return CartPage | Null |
||
3418 | */ |
||
3419 | public function DisplayPage() |
||
3436 | |||
3437 | /** |
||
3438 | * returns the link to view the Order |
||
3439 | * WHY NOT CHECKOUT PAGE: first we check for cart page. |
||
3440 | * If a cart page has been created then we refer through to Cart Page. |
||
3441 | * Otherwise it will default to the checkout page. |
||
3442 | * |
||
3443 | * @param string $action - any action that should be added to the link. |
||
3444 | * |
||
3445 | * @return String(URLSegment) |
||
3446 | */ |
||
3447 | public function Link($action = null) |
||
3462 | |||
3463 | /** |
||
3464 | * Returns to link to access the Order's API. |
||
3465 | * |
||
3466 | * @param string $version |
||
3467 | * @param string $extension |
||
3468 | * |
||
3469 | * @return String(URL) |
||
3470 | */ |
||
3471 | public function APILink($version = 'v1', $extension = 'xml') |
||
3475 | |||
3476 | /** |
||
3477 | * returns the link to finalise the Order. |
||
3478 | * |
||
3479 | * @return String(URLSegment) |
||
3480 | */ |
||
3481 | public function CheckoutLink() |
||
3495 | |||
3496 | /** |
||
3497 | * Converts the Order into HTML, based on the Order Template. |
||
3498 | * |
||
3499 | * @return HTML Object |
||
3500 | **/ |
||
3501 | public function ConvertToHTML() |
||
3511 | |||
3512 | /** |
||
3513 | * Converts the Order into a serialized string |
||
3514 | * TO DO: check if this works and check if we need to use special sapphire serialization code. |
||
3515 | * |
||
3516 | * @return string - serialized object |
||
3517 | **/ |
||
3518 | public function ConvertToString() |
||
3522 | |||
3523 | /** |
||
3524 | * Converts the Order into a JSON object |
||
3525 | * TO DO: check if this works and check if we need to use special sapphire JSON code. |
||
3526 | * |
||
3527 | * @return string - JSON |
||
3528 | **/ |
||
3529 | public function ConvertToJSON() |
||
3533 | |||
3534 | /** |
||
3535 | * returns itself wtih more data added as variables. |
||
3536 | * We add has_one and has_many as variables like this: $this->MyHasOne_serialized = serialize($this->MyHasOne()). |
||
3537 | * |
||
3538 | * @return Order - with most important has one and has many items included as variables. |
||
3539 | **/ |
||
3540 | protected function addHasOneAndHasManyAsVariables() |
||
3553 | |||
3554 | /******************************************************* |
||
3555 | * 9. TEMPLATE RELATED STUFF |
||
3556 | *******************************************************/ |
||
3557 | |||
3558 | /** |
||
3559 | * returns the instance of EcommerceConfigAjax for use in templates. |
||
3560 | * In templates, it is used like this: |
||
3561 | * $EcommerceConfigAjax.TableID. |
||
3562 | * |
||
3563 | * @return EcommerceConfigAjax |
||
3564 | **/ |
||
3565 | public function AJAXDefinitions() |
||
3569 | |||
3570 | /** |
||
3571 | * returns the instance of EcommerceDBConfig. |
||
3572 | * |
||
3573 | * @return EcommerceDBConfig |
||
3574 | **/ |
||
3575 | public function EcomConfig() |
||
3579 | |||
3580 | /** |
||
3581 | * Collects the JSON data for an ajax return of the cart. |
||
3582 | * |
||
3583 | * @param array $js |
||
3584 | * |
||
3585 | * @return array (for use in AJAX for JSON) |
||
3586 | **/ |
||
3587 | public function updateForAjax(array $js) |
||
3640 | |||
3641 | /** |
||
3642 | * @ToDO: move to more appropriate class |
||
3643 | * |
||
3644 | * @return float |
||
3645 | **/ |
||
3646 | public function SubTotalCartValue() |
||
3650 | |||
3651 | /******************************************************* |
||
3652 | * 10. STANDARD SS METHODS (requireDefaultRecords, onBeforeDelete, etc...) |
||
3653 | *******************************************************/ |
||
3654 | |||
3655 | /** |
||
3656 | *standard SS method. |
||
3657 | **/ |
||
3658 | public function populateDefaults() |
||
3662 | |||
3663 | public function onBeforeWrite() |
||
3678 | |||
3679 | /** |
||
3680 | * standard SS method |
||
3681 | * adds the ability to update order after writing it. |
||
3682 | **/ |
||
3683 | public function onAfterWrite() |
||
3707 | |||
3708 | /** |
||
3709 | *standard SS method. |
||
3710 | * |
||
3711 | * delete attributes, statuslogs, and payments |
||
3712 | * THIS SHOULD NOT BE USED AS ORDERS SHOULD BE CANCELLED NOT DELETED |
||
3713 | */ |
||
3714 | public function onBeforeDelete() |
||
3759 | |||
3760 | /******************************************************* |
||
3761 | * 11. DEBUG |
||
3762 | *******************************************************/ |
||
3763 | |||
3764 | /** |
||
3765 | * Debug helper method. |
||
3766 | * Can be called from /shoppingcart/debug/. |
||
3767 | * |
||
3768 | * @return string |
||
3769 | */ |
||
3770 | public function debug() |
||
3776 | } |
||
3777 |
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.