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) |
||
477 | |||
478 | /** |
||
479 | * STANDARD SILVERSTRIPE STUFF |
||
480 | * broken up into submitted and not (yet) submitted. |
||
481 | **/ |
||
482 | public function getCMSFields() |
||
872 | |||
873 | /** |
||
874 | * Field to add and edit Order Items. |
||
875 | * |
||
876 | * @return GridField |
||
877 | */ |
||
878 | protected function getOrderItemsField() |
||
885 | |||
886 | /** |
||
887 | * Field to add and edit Modifiers. |
||
888 | * |
||
889 | * @return GridField |
||
890 | */ |
||
891 | public function getModifierTableField() |
||
898 | |||
899 | /** |
||
900 | *@return GridField |
||
901 | **/ |
||
902 | protected function getBillingAddressField() |
||
918 | |||
919 | /** |
||
920 | *@return GridField |
||
921 | **/ |
||
922 | protected function getShippingAddressField() |
||
938 | |||
939 | /** |
||
940 | * Needs to be public because the OrderStep::getCMSFIelds accesses it. |
||
941 | * |
||
942 | * @param string $sourceClass |
||
943 | * @param string $title |
||
944 | * |
||
945 | * @return GridField |
||
946 | **/ |
||
947 | public function getOrderStatusLogsTableField( |
||
962 | |||
963 | /** |
||
964 | * Needs to be public because the OrderStep::getCMSFIelds accesses it. |
||
965 | * |
||
966 | * @param string $sourceClass |
||
967 | * @param string $title |
||
968 | * |
||
969 | * @return GridField |
||
970 | **/ |
||
971 | public function getOrderStatusLogsTableFieldEditable( |
||
981 | |||
982 | /** |
||
983 | * @param string $sourceClass |
||
984 | * @param string $title |
||
985 | * @param FieldList $fieldList (Optional) |
||
986 | * @param FieldList $detailedFormFields (Optional) |
||
987 | * |
||
988 | * @return GridField |
||
989 | **/ |
||
990 | protected function getOrderStatusLogsTableField_Archived( |
||
1007 | |||
1008 | /** |
||
1009 | * @return GridField |
||
1010 | **/ |
||
1011 | public function getEmailsTableField() |
||
1019 | |||
1020 | /** |
||
1021 | * @return GridField |
||
1022 | */ |
||
1023 | protected function getPaymentsField() |
||
1032 | |||
1033 | /** |
||
1034 | * @return OrderStepField |
||
1035 | */ |
||
1036 | public function OrderStepField() |
||
1040 | |||
1041 | /******************************************************* |
||
1042 | * 2. MAIN TRANSITION FUNCTIONS |
||
1043 | *******************************************************/ |
||
1044 | |||
1045 | /** |
||
1046 | * init runs on start of a new Order (@see onAfterWrite) |
||
1047 | * it adds all the modifiers to the orders and the starting OrderStep. |
||
1048 | * |
||
1049 | * @param bool $recalculate |
||
1050 | * |
||
1051 | * @return DataObject (Order) |
||
1052 | **/ |
||
1053 | public function init($recalculate = false) |
||
1113 | |||
1114 | /** |
||
1115 | * @var array |
||
1116 | */ |
||
1117 | private static $_try_to_finalise_order_is_running = array(); |
||
1118 | |||
1119 | /** |
||
1120 | * Goes through the order steps and tries to "apply" the next status to the order. |
||
1121 | * |
||
1122 | * @param bool $runAgain |
||
1123 | * @param bool $fromOrderQueue - is it being called from the OrderProcessQueue (or similar) |
||
1124 | **/ |
||
1125 | public function tryToFinaliseOrder($runAgain = false, $fromOrderQueue = false) |
||
1177 | |||
1178 | /** |
||
1179 | * Goes through the order steps and tries to "apply" the next step |
||
1180 | * Step is updated after the other one is completed... |
||
1181 | * |
||
1182 | * @return int (StatusID or false if the next status can not be "applied") |
||
1183 | **/ |
||
1184 | public function doNextStatus() |
||
1199 | |||
1200 | /** |
||
1201 | * cancel an order. |
||
1202 | * |
||
1203 | * @param Member $member - (optional) the user cancelling the order |
||
1204 | * @param string $reason - (optional) the reason the order is cancelled |
||
1205 | * |
||
1206 | * @return OrderStatusLog_Cancel |
||
1207 | */ |
||
1208 | public function Cancel($member = null, $reason = '') |
||
1241 | |||
1242 | /** |
||
1243 | * returns true if successful. |
||
1244 | * |
||
1245 | * @param bool $avoidWrites |
||
1246 | * |
||
1247 | * @return bool |
||
1248 | */ |
||
1249 | public function Archive($avoidWrites = true) |
||
1272 | |||
1273 | /******************************************************* |
||
1274 | * 3. STATUS RELATED FUNCTIONS / SHORTCUTS |
||
1275 | *******************************************************/ |
||
1276 | |||
1277 | /** |
||
1278 | * Avoids caching of $this->Status(). |
||
1279 | * |
||
1280 | * @return DataObject (current OrderStep) |
||
1281 | */ |
||
1282 | public function MyStep() |
||
1300 | |||
1301 | /** |
||
1302 | * Return the OrderStatusLog that is relevant to the Order status. |
||
1303 | * |
||
1304 | * @return OrderStatusLog |
||
1305 | */ |
||
1306 | public function RelevantLogEntry() |
||
1310 | |||
1311 | /** |
||
1312 | * @return OrderStep (current OrderStep that can be seen by customer) |
||
1313 | */ |
||
1314 | public function CurrentStepVisibleToCustomer() |
||
1326 | |||
1327 | /** |
||
1328 | * works out if the order is still at the first OrderStep. |
||
1329 | * |
||
1330 | * @return bool |
||
1331 | */ |
||
1332 | public function IsFirstStep() |
||
1344 | |||
1345 | /** |
||
1346 | * Is the order still being "edited" by the customer? |
||
1347 | * |
||
1348 | * @return bool |
||
1349 | */ |
||
1350 | public function IsInCart() |
||
1354 | |||
1355 | /** |
||
1356 | * The order has "passed" the IsInCart phase. |
||
1357 | * |
||
1358 | * @return bool |
||
1359 | */ |
||
1360 | public function IsPastCart() |
||
1364 | |||
1365 | /** |
||
1366 | * Are there still steps the order needs to go through? |
||
1367 | * |
||
1368 | * @return bool |
||
1369 | */ |
||
1370 | public function IsUncomplete() |
||
1374 | |||
1375 | /** |
||
1376 | * Is the order in the :"processing" phaase.? |
||
1377 | * |
||
1378 | * @return bool |
||
1379 | */ |
||
1380 | public function IsProcessing() |
||
1384 | |||
1385 | /** |
||
1386 | * Is the order completed? |
||
1387 | * |
||
1388 | * @return bool |
||
1389 | */ |
||
1390 | public function IsCompleted() |
||
1394 | |||
1395 | /** |
||
1396 | * Has the order been paid? |
||
1397 | * TODO: why do we check if there is a total at all? |
||
1398 | * |
||
1399 | * @return bool |
||
1400 | */ |
||
1401 | public function IsPaid() |
||
1409 | /** |
||
1410 | * Has the order been paid? |
||
1411 | * TODO: why do we check if there is a total at all? |
||
1412 | * |
||
1413 | * @return Boolean (object) |
||
1414 | */ |
||
1415 | public function IsPaidNice() |
||
1419 | |||
1420 | /** |
||
1421 | * Has the order been paid? |
||
1422 | * TODO: why do we check if there is a total at all? |
||
1423 | * |
||
1424 | * @return bool |
||
1425 | */ |
||
1426 | public function PaymentIsPending() |
||
1442 | |||
1443 | /** |
||
1444 | * shows payments that are meaningfull |
||
1445 | * if the order has been paid then only show successful payments. |
||
1446 | * |
||
1447 | * @return DataList |
||
1448 | */ |
||
1449 | public function RelevantPayments() |
||
1459 | |||
1460 | /** |
||
1461 | * Has the order been cancelled? |
||
1462 | * |
||
1463 | * @return bool |
||
1464 | */ |
||
1465 | public function IsCancelled() |
||
1473 | |||
1474 | /** |
||
1475 | * Has the order been cancelled by the customer? |
||
1476 | * |
||
1477 | * @return bool |
||
1478 | */ |
||
1479 | public function IsCustomerCancelled() |
||
1487 | |||
1488 | /** |
||
1489 | * Has the order been cancelled by the administrator? |
||
1490 | * |
||
1491 | * @return bool |
||
1492 | */ |
||
1493 | public function IsAdminCancelled() |
||
1508 | |||
1509 | /** |
||
1510 | * Is the Shop Closed for business? |
||
1511 | * |
||
1512 | * @return bool |
||
1513 | */ |
||
1514 | public function ShopClosed() |
||
1518 | |||
1519 | /******************************************************* |
||
1520 | * 4. LINKING ORDER WITH MEMBER AND ADDRESS |
||
1521 | *******************************************************/ |
||
1522 | |||
1523 | /** |
||
1524 | * Returns a member linked to the order. |
||
1525 | * If a member is already linked, it will return the existing member. |
||
1526 | * Otherwise it will return a new Member. |
||
1527 | * |
||
1528 | * Any new member is NOT written, because we dont want to create a new member unless we have to! |
||
1529 | * We will not add a member to the order unless a new one is created in the checkout |
||
1530 | * OR the member is logged in / logs in. |
||
1531 | * |
||
1532 | * Also note that if a new member is created, it is not automatically written |
||
1533 | * |
||
1534 | * @param bool $forceCreation - if set to true then the member will always be saved in the database. |
||
1535 | * |
||
1536 | * @return Member |
||
1537 | **/ |
||
1538 | public function CreateOrReturnExistingMember($forceCreation = false) |
||
1561 | |||
1562 | /** |
||
1563 | * Returns either the existing one or a new Order Address... |
||
1564 | * All Orders will have a Shipping and Billing address attached to it. |
||
1565 | * Method used to retrieve object e.g. for $order->BillingAddress(); "BillingAddress" is the method name you can use. |
||
1566 | * If the method name is the same as the class name then dont worry about providing one. |
||
1567 | * |
||
1568 | * @param string $className - ClassName of the Address (e.g. BillingAddress or ShippingAddress) |
||
1569 | * @param string $alternativeMethodName - method to retrieve Address |
||
1570 | **/ |
||
1571 | public function CreateOrReturnExistingAddress($className = 'BillingAddress', $alternativeMethodName = '') |
||
1615 | |||
1616 | /** |
||
1617 | * Sets the country in the billing and shipping address. |
||
1618 | * |
||
1619 | * @param string $countryCode - code for the country e.g. NZ |
||
1620 | * @param bool $includeBillingAddress |
||
1621 | * @param bool $includeShippingAddress |
||
1622 | **/ |
||
1623 | public function SetCountryFields($countryCode, $includeBillingAddress = true, $includeShippingAddress = true) |
||
1642 | |||
1643 | /** |
||
1644 | * Sets the region in the billing and shipping address. |
||
1645 | * |
||
1646 | * @param int $regionID - ID for the region to be set |
||
1647 | **/ |
||
1648 | public function SetRegionFields($regionID) |
||
1663 | |||
1664 | /** |
||
1665 | * Stores the preferred currency of the order. |
||
1666 | * IMPORTANTLY we store the exchange rate for future reference... |
||
1667 | * |
||
1668 | * @param EcommerceCurrency $currency |
||
1669 | */ |
||
1670 | public function UpdateCurrency($newCurrency) |
||
1683 | |||
1684 | /** |
||
1685 | * alias for UpdateCurrency. |
||
1686 | * |
||
1687 | * @param EcommerceCurrency $currency |
||
1688 | */ |
||
1689 | public function SetCurrency($currency) |
||
1693 | |||
1694 | /******************************************************* |
||
1695 | * 5. CUSTOMER COMMUNICATION |
||
1696 | *******************************************************/ |
||
1697 | |||
1698 | /** |
||
1699 | * Send the invoice of the order by email. |
||
1700 | * |
||
1701 | * @param string $emailClassName (optional) class used to send email |
||
1702 | * @param string $subject (optional) subject for the email |
||
1703 | * @param string $message (optional) the main message in the email |
||
1704 | * @param bool $resend (optional) send the email even if it has been sent before |
||
1705 | * @param bool $adminOnlyOrToEmail (optional) sends the email to the ADMIN ONLY, if you provide an email, it will go to the email... |
||
1706 | * |
||
1707 | * @return bool TRUE on success, FALSE on failure |
||
1708 | */ |
||
1709 | public function sendEmail( |
||
1724 | |||
1725 | /** |
||
1726 | * Sends a message to the shop admin ONLY and not to the customer |
||
1727 | * This can be used by ordersteps and orderlogs to notify the admin of any potential problems. |
||
1728 | * |
||
1729 | * @param string $emailClassName - (optional) template to be used ... |
||
1730 | * @param string $subject - (optional) subject for the email |
||
1731 | * @param string $message - (optional) message to be added with the email |
||
1732 | * @param bool $resend - (optional) can it be sent twice? |
||
1733 | * @param bool | string $adminOnlyOrToEmail - (optional) sends the email to the ADMIN ONLY, if you provide an email, it will go to the email... |
||
1734 | * |
||
1735 | * @return bool TRUE for success, FALSE for failure (not tested) |
||
1736 | */ |
||
1737 | public function sendAdminNotification( |
||
1752 | |||
1753 | /** |
||
1754 | * returns the order formatted as an email. |
||
1755 | * |
||
1756 | * @param string $emailClassName - template to use. |
||
1757 | * @param string $subject - (optional) the subject (which can be used as title in email) |
||
1758 | * @param string $message - (optional) the additional message |
||
1759 | * |
||
1760 | * @return string (html) |
||
1761 | */ |
||
1762 | public function renderOrderInEmailFormat( |
||
1776 | |||
1777 | /** |
||
1778 | * Send a mail of the order to the client (and another to the admin). |
||
1779 | * |
||
1780 | * @param string $emailClassName - (optional) template to be used ... |
||
1781 | * @param string $subject - (optional) subject for the email |
||
1782 | * @param string $message - (optional) message to be added with the email |
||
1783 | * @param bool $resend - (optional) can it be sent twice? |
||
1784 | * @param bool | string $adminOnlyOrToEmail - (optional) sends the email to the ADMIN ONLY, if you provide an email, it will go to the email... |
||
1785 | * |
||
1786 | * @return bool TRUE for success, FALSE for failure (not tested) |
||
1787 | */ |
||
1788 | protected function prepareAndSendEmail( |
||
1845 | |||
1846 | /** |
||
1847 | * returns the Data that can be used in the body of an order Email |
||
1848 | * we add the subject here so that the subject, for example, can be added to the <title> |
||
1849 | * of the email template. |
||
1850 | * we add the subject here so that the subject, for example, can be added to the <title> |
||
1851 | * of the email template. |
||
1852 | * |
||
1853 | * @param string $subject - (optional) subject for email |
||
1854 | * @param string $message - (optional) the additional message |
||
1855 | * |
||
1856 | * @return ArrayData |
||
1857 | * - Subject - EmailSubject |
||
1858 | * - Message - specific message for this order |
||
1859 | * - Message - custom message |
||
1860 | * - OrderStepMessage - generic message for step |
||
1861 | * - Order |
||
1862 | * - EmailLogo |
||
1863 | * - ShopPhysicalAddress |
||
1864 | * - CurrentDateAndTime |
||
1865 | * - BaseURL |
||
1866 | * - CC |
||
1867 | * - BCC |
||
1868 | */ |
||
1869 | protected function createReplacementArrayForEmail($subject = '', $message = '') |
||
1898 | |||
1899 | /******************************************************* |
||
1900 | * 6. ITEM MANAGEMENT |
||
1901 | *******************************************************/ |
||
1902 | |||
1903 | /** |
||
1904 | * returns a list of Order Attributes by type. |
||
1905 | * |
||
1906 | * @param array | String $types |
||
1907 | * |
||
1908 | * @return ArrayList |
||
1909 | */ |
||
1910 | public function getOrderAttributesByType($types) |
||
1934 | |||
1935 | /** |
||
1936 | * Returns the items of the order. |
||
1937 | * Items are the order items (products) and NOT the modifiers (discount, tax, etc...). |
||
1938 | * |
||
1939 | * N. B. this method returns Order Items |
||
1940 | * also see Buaybles |
||
1941 | |||
1942 | * |
||
1943 | * @param string filter - where statement to exclude certain items OR ClassName (e.g. 'TaxModifier') |
||
1944 | * |
||
1945 | * @return DataList (OrderItems) |
||
1946 | */ |
||
1947 | public function Items($filterOrClassName = '') |
||
1955 | |||
1956 | /** |
||
1957 | * @alias function of Items |
||
1958 | * |
||
1959 | * N. B. this method returns Order Items |
||
1960 | * also see Buaybles |
||
1961 | * |
||
1962 | * @param string filter - where statement to exclude certain items. |
||
1963 | * @alias for Items |
||
1964 | * @return DataList (OrderItems) |
||
1965 | */ |
||
1966 | public function OrderItems($filterOrClassName = '') |
||
1970 | |||
1971 | /** |
||
1972 | * returns the buyables asscoiated with the order items. |
||
1973 | * |
||
1974 | * NB. this method retursn buyables |
||
1975 | * |
||
1976 | * @param string filter - where statement to exclude certain items. |
||
1977 | * |
||
1978 | * @return ArrayList (Buyables) |
||
1979 | */ |
||
1980 | public function Buyables($filterOrClassName = '') |
||
1990 | |||
1991 | /** |
||
1992 | * Return all the {@link OrderItem} instances that are |
||
1993 | * available as records in the database. |
||
1994 | * |
||
1995 | * @param string filter - where statement to exclude certain items, |
||
1996 | * 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) |
||
1997 | * |
||
1998 | * @return DataList (OrderItems) |
||
1999 | */ |
||
2000 | protected function itemsFromDatabase($filterOrClassName = '') |
||
2014 | |||
2015 | /** |
||
2016 | * @alias for Modifiers |
||
2017 | * |
||
2018 | * @return DataList (OrderModifiers) |
||
2019 | */ |
||
2020 | public function OrderModifiers() |
||
2024 | |||
2025 | /** |
||
2026 | * Returns the modifiers of the order, if it hasn't been saved yet |
||
2027 | * it returns the modifiers from session, if it has, it returns them |
||
2028 | * from the DB entry. ONLY USE OUTSIDE ORDER. |
||
2029 | * |
||
2030 | * @param string filter - where statement to exclude certain items OR ClassName (e.g. 'TaxModifier') |
||
2031 | * |
||
2032 | * @return DataList (OrderModifiers) |
||
2033 | */ |
||
2034 | public function Modifiers($filterOrClassName = '') |
||
2038 | |||
2039 | /** |
||
2040 | * Get all {@link OrderModifier} instances that are |
||
2041 | * available as records in the database. |
||
2042 | * NOTE: includes REMOVED Modifiers, so that they do not get added again... |
||
2043 | * |
||
2044 | * @param string filter - where statement to exclude certain items OR ClassName (e.g. 'TaxModifier') |
||
2045 | * |
||
2046 | * @return DataList (OrderModifiers) |
||
2047 | */ |
||
2048 | protected function modifiersFromDatabase($filterOrClassName = '') |
||
2062 | |||
2063 | /** |
||
2064 | * Calculates and updates all the order attributes. |
||
2065 | * |
||
2066 | * @param bool $recalculate - run it, even if it has run already |
||
2067 | */ |
||
2068 | public function calculateOrderAttributes($recalculate = false) |
||
2082 | |||
2083 | /** |
||
2084 | * Calculates and updates all the product items. |
||
2085 | * |
||
2086 | * @param bool $recalculate - run it, even if it has run already |
||
2087 | */ |
||
2088 | protected function calculateOrderItems($recalculate = false) |
||
2103 | |||
2104 | /** |
||
2105 | * Calculates and updates all the modifiers. |
||
2106 | * |
||
2107 | * @param bool $recalculate - run it, even if it has run already |
||
2108 | */ |
||
2109 | protected function calculateModifiers($recalculate = false) |
||
2121 | |||
2122 | /** |
||
2123 | * Returns the subtotal of the modifiers for this order. |
||
2124 | * If a modifier appears in the excludedModifiers array, it is not counted. |
||
2125 | * |
||
2126 | * @param string|array $excluded - Class(es) of modifier(s) to ignore in the calculation. |
||
2127 | * @param bool $stopAtExcludedModifier - when this flag is TRUE, we stop adding the modifiers when we reach an excluded modifier. |
||
2128 | * |
||
2129 | * @return float |
||
2130 | */ |
||
2131 | public function ModifiersSubTotal($excluded = null, $stopAtExcludedModifier = false) |
||
2158 | |||
2159 | /** |
||
2160 | * returns a modifier that is an instanceof the classname |
||
2161 | * it extends. |
||
2162 | * |
||
2163 | * @param string $className: class name for the modifier |
||
2164 | * |
||
2165 | * @return DataObject (OrderModifier) |
||
2166 | **/ |
||
2167 | public function RetrieveModifier($className) |
||
2178 | |||
2179 | /******************************************************* |
||
2180 | * 7. CRUD METHODS (e.g. canView, canEdit, canDelete, etc...) |
||
2181 | *******************************************************/ |
||
2182 | |||
2183 | /** |
||
2184 | * @param Member $member |
||
2185 | * |
||
2186 | * @return DataObject (Member) |
||
2187 | **/ |
||
2188 | //TODO: please comment why we make use of this function |
||
2189 | protected function getMemberForCanFunctions(Member $member = null) |
||
2201 | |||
2202 | /** |
||
2203 | * @param Member $member |
||
2204 | * |
||
2205 | * @return bool |
||
2206 | **/ |
||
2207 | public function canCreate($member = null) |
||
2218 | |||
2219 | /** |
||
2220 | * Standard SS method - can the current member view this order? |
||
2221 | * |
||
2222 | * @param Member $member |
||
2223 | * |
||
2224 | * @return bool |
||
2225 | **/ |
||
2226 | public function canView($member = null) |
||
2271 | |||
2272 | /** |
||
2273 | * @param Member $member optional |
||
2274 | * @return bool |
||
2275 | */ |
||
2276 | public function canOverrideCanView($member = null) |
||
2297 | |||
2298 | /** |
||
2299 | * @return bool |
||
2300 | */ |
||
2301 | public function IsInSession() |
||
2307 | |||
2308 | /** |
||
2309 | * returns a pseudo random part of the session id. |
||
2310 | * |
||
2311 | * @param int $size |
||
2312 | * |
||
2313 | * @return string |
||
2314 | */ |
||
2315 | public function LessSecureSessionID($size = 7, $start = null) |
||
2323 | /** |
||
2324 | * |
||
2325 | * @param Member (optional) $member |
||
2326 | * |
||
2327 | * @return bool |
||
2328 | **/ |
||
2329 | public function canViewAdminStuff($member = null) |
||
2340 | |||
2341 | /** |
||
2342 | * if we set canEdit to false then we |
||
2343 | * can not see the child records |
||
2344 | * Basically, you can edit when you can view and canEdit (even as a customer) |
||
2345 | * Or if you are a Shop Admin you can always edit. |
||
2346 | * Otherwise it is false... |
||
2347 | * |
||
2348 | * @param Member $member |
||
2349 | * |
||
2350 | * @return bool |
||
2351 | **/ |
||
2352 | public function canEdit($member = null) |
||
2371 | |||
2372 | /** |
||
2373 | * is the order ready to go through to the |
||
2374 | * checkout process. |
||
2375 | * |
||
2376 | * This method checks all the order items and order modifiers |
||
2377 | * If any of them need immediate attention then this is done |
||
2378 | * first after which it will go through to the checkout page. |
||
2379 | * |
||
2380 | * @param Member (optional) $member |
||
2381 | * |
||
2382 | * @return bool |
||
2383 | **/ |
||
2384 | public function canCheckout(Member $member = null) |
||
2398 | |||
2399 | /** |
||
2400 | * Can the order be submitted? |
||
2401 | * this method can be used to stop an order from being submitted |
||
2402 | * due to something not being completed or done. |
||
2403 | * |
||
2404 | * @see Order::SubmitErrors |
||
2405 | * |
||
2406 | * @param Member $member |
||
2407 | * |
||
2408 | * @return bool |
||
2409 | **/ |
||
2410 | public function canSubmit(Member $member = null) |
||
2427 | |||
2428 | /** |
||
2429 | * Can a payment be made for this Order? |
||
2430 | * |
||
2431 | * @param Member $member |
||
2432 | * |
||
2433 | * @return bool |
||
2434 | **/ |
||
2435 | public function canPay(Member $member = null) |
||
2448 | |||
2449 | /** |
||
2450 | * Can the given member cancel this order? |
||
2451 | * |
||
2452 | * @param Member $member |
||
2453 | * |
||
2454 | * @return bool |
||
2455 | **/ |
||
2456 | public function canCancel(Member $member = null) |
||
2473 | |||
2474 | /** |
||
2475 | * @param Member $member |
||
2476 | * |
||
2477 | * @return bool |
||
2478 | **/ |
||
2479 | public function canDelete($member = null) |
||
2495 | |||
2496 | /** |
||
2497 | * Returns all the order logs that the current member can view |
||
2498 | * i.e. some order logs can only be viewed by the admin (e.g. suspected fraud orderlog). |
||
2499 | * |
||
2500 | * @return ArrayList (OrderStatusLogs) |
||
2501 | **/ |
||
2502 | public function CanViewOrderStatusLogs() |
||
2514 | |||
2515 | /** |
||
2516 | * returns all the logs that can be viewed by the customer. |
||
2517 | * |
||
2518 | * @return ArrayList (OrderStausLogs) |
||
2519 | */ |
||
2520 | public function CustomerViewableOrderStatusLogs() |
||
2534 | |||
2535 | /******************************************************* |
||
2536 | * 8. GET METHODS (e.g. Total, SubTotal, Title, etc...) |
||
2537 | *******************************************************/ |
||
2538 | |||
2539 | /** |
||
2540 | * returns the email to be used for customer communication. |
||
2541 | * |
||
2542 | * @return string |
||
2543 | */ |
||
2544 | public function OrderEmail() |
||
2566 | |||
2567 | /** |
||
2568 | * Returns true if there is a prink or email link. |
||
2569 | * |
||
2570 | * @return bool |
||
2571 | */ |
||
2572 | public function HasPrintOrEmailLink() |
||
2576 | |||
2577 | /** |
||
2578 | * returns the absolute link to the order that can be used in the customer communication (email). |
||
2579 | * |
||
2580 | * @return string |
||
2581 | */ |
||
2582 | public function EmailLink($type = 'Order_StatusEmail') |
||
2594 | |||
2595 | /** |
||
2596 | * returns the absolute link to the order for printing. |
||
2597 | * |
||
2598 | * @return string |
||
2599 | */ |
||
2600 | public function PrintLink() |
||
2612 | |||
2613 | /** |
||
2614 | * returns the absolute link to the order for printing. |
||
2615 | * |
||
2616 | * @return string |
||
2617 | */ |
||
2618 | public function PackingSlipLink() |
||
2628 | |||
2629 | /** |
||
2630 | * returns the absolute link that the customer can use to retrieve the email WITHOUT logging in. |
||
2631 | * |
||
2632 | * @return string |
||
2633 | */ |
||
2634 | public function RetrieveLink() |
||
2638 | |||
2639 | public function getRetrieveLink() |
||
2653 | |||
2654 | public function ShareLink() |
||
2658 | |||
2659 | public function getShareLink() |
||
2677 | |||
2678 | /** |
||
2679 | * @alias for getFeedbackLink |
||
2680 | * @return string |
||
2681 | */ |
||
2682 | public function FeedbackLink() |
||
2686 | |||
2687 | /** |
||
2688 | * @return string | null |
||
2689 | */ |
||
2690 | public function getFeedbackLink() |
||
2698 | |||
2699 | /** |
||
2700 | * link to delete order. |
||
2701 | * |
||
2702 | * @return string |
||
2703 | */ |
||
2704 | public function DeleteLink() |
||
2716 | |||
2717 | /** |
||
2718 | * link to copy order. |
||
2719 | * |
||
2720 | * @return string |
||
2721 | */ |
||
2722 | public function CopyOrderLink() |
||
2734 | |||
2735 | /** |
||
2736 | * A "Title" for the order, which summarises the main details (date, and customer) in a string. |
||
2737 | * |
||
2738 | * @param string $dateFormat - e.g. "D j M Y, G:i T" |
||
2739 | * @param bool $includeName - e.g. by Mr Johnson |
||
2740 | * |
||
2741 | * @return string |
||
2742 | **/ |
||
2743 | public function Title($dateFormat = null, $includeName = false) |
||
2806 | |||
2807 | /** |
||
2808 | * Returns the subtotal of the items for this order. |
||
2809 | * |
||
2810 | * @return float |
||
2811 | */ |
||
2812 | public function SubTotal() |
||
2830 | |||
2831 | /** |
||
2832 | * @return Currency (DB Object) |
||
2833 | **/ |
||
2834 | public function SubTotalAsCurrencyObject() |
||
2838 | |||
2839 | /** |
||
2840 | * @return Money |
||
2841 | **/ |
||
2842 | public function SubTotalAsMoney() |
||
2850 | |||
2851 | /** |
||
2852 | * @param string|array $excluded - Class(es) of modifier(s) to ignore in the calculation. |
||
2853 | * @param bool $stopAtExcludedModifier - when this flag is TRUE, we stop adding the modifiers when we reach an excluded modifier. |
||
2854 | * |
||
2855 | * @return Currency (DB Object) |
||
2856 | **/ |
||
2857 | public function ModifiersSubTotalAsCurrencyObject($excluded = null, $stopAtExcludedModifier = false) |
||
2861 | |||
2862 | /** |
||
2863 | * @param string|array $excluded - Class(es) of modifier(s) to ignore in the calculation. |
||
2864 | * @param bool $stopAtExcludedModifier - when this flag is TRUE, we stop adding the modifiers when we reach an excluded modifier. |
||
2865 | * |
||
2866 | * @return Money (DB Object) |
||
2867 | **/ |
||
2868 | public function ModifiersSubTotalAsMoneyObject($excluded = null, $stopAtExcludedModifier = false) |
||
2872 | |||
2873 | /** |
||
2874 | * Returns the total cost of an order including the additional charges or deductions of its modifiers. |
||
2875 | * |
||
2876 | * @return float |
||
2877 | */ |
||
2878 | public function Total() |
||
2886 | |||
2887 | /** |
||
2888 | * @return Currency (DB Object) |
||
2889 | **/ |
||
2890 | public function TotalAsCurrencyObject() |
||
2894 | |||
2895 | /** |
||
2896 | * @return Money |
||
2897 | **/ |
||
2898 | public function TotalAsMoney() |
||
2906 | |||
2907 | /** |
||
2908 | * Checks to see if any payments have been made on this order |
||
2909 | * and if so, subracts the payment amount from the order. |
||
2910 | * |
||
2911 | * @return float |
||
2912 | **/ |
||
2913 | public function TotalOutstanding() |
||
2933 | |||
2934 | /** |
||
2935 | * @return Currency (DB Object) |
||
2936 | **/ |
||
2937 | public function TotalOutstandingAsCurrencyObject() |
||
2941 | |||
2942 | /** |
||
2943 | * @return Money |
||
2944 | **/ |
||
2945 | public function TotalOutstandingAsMoney() |
||
2953 | |||
2954 | /** |
||
2955 | * @return float |
||
2956 | */ |
||
2957 | public function TotalPaid() |
||
2978 | |||
2979 | /** |
||
2980 | * @return Currency (DB Object) |
||
2981 | **/ |
||
2982 | public function TotalPaidAsCurrencyObject() |
||
2986 | |||
2987 | /** |
||
2988 | * @return Money |
||
2989 | **/ |
||
2990 | public function TotalPaidAsMoney() |
||
2998 | |||
2999 | /** |
||
3000 | * returns the total number of OrderItems (not modifiers). |
||
3001 | * This is meant to run as fast as possible to quickly check |
||
3002 | * if there is anything in the cart. |
||
3003 | * |
||
3004 | * @param bool $recalculate - do we need to recalculate (value is retained during lifetime of Object) |
||
3005 | * |
||
3006 | * @return int |
||
3007 | **/ |
||
3008 | public function TotalItems($recalculate = false) |
||
3022 | |||
3023 | /** |
||
3024 | * Little shorthand. |
||
3025 | * |
||
3026 | * @param bool $recalculate |
||
3027 | * |
||
3028 | * @return bool |
||
3029 | **/ |
||
3030 | public function MoreThanOneItemInCart($recalculate = false) |
||
3034 | |||
3035 | /** |
||
3036 | * returns the total number of OrderItems (not modifiers) times their respectective quantities. |
||
3037 | * |
||
3038 | * @param bool $recalculate - force recalculation |
||
3039 | * |
||
3040 | * @return float |
||
3041 | **/ |
||
3042 | public function TotalItemsTimesQuantity($recalculate = false) |
||
3062 | |||
3063 | /** |
||
3064 | * |
||
3065 | * @return string (country code) |
||
3066 | **/ |
||
3067 | public function Country() |
||
3071 | |||
3072 | /** |
||
3073 | * Returns the country code for the country that applies to the order. |
||
3074 | * @alias for getCountry |
||
3075 | * |
||
3076 | * @return string - country code e.g. NZ |
||
3077 | */ |
||
3078 | public function getCountry() |
||
3115 | |||
3116 | /** |
||
3117 | * @alias for getFullNameCountry |
||
3118 | * |
||
3119 | * @return string - country name |
||
3120 | **/ |
||
3121 | public function FullNameCountry() |
||
3125 | |||
3126 | /** |
||
3127 | * returns name of coutry. |
||
3128 | * |
||
3129 | * @return string - country name |
||
3130 | **/ |
||
3131 | public function getFullNameCountry() |
||
3135 | |||
3136 | /** |
||
3137 | * @alis for getExpectedCountryName |
||
3138 | * @return string - country name |
||
3139 | **/ |
||
3140 | public function ExpectedCountryName() |
||
3144 | |||
3145 | /** |
||
3146 | * returns name of coutry that we expect the customer to have |
||
3147 | * This takes into consideration more than just what has been entered |
||
3148 | * for example, it looks at GEO IP. |
||
3149 | * |
||
3150 | * @todo: why do we dont return a string IF there is only one item. |
||
3151 | * |
||
3152 | * @return string - country name |
||
3153 | **/ |
||
3154 | public function getExpectedCountryName() |
||
3158 | |||
3159 | /** |
||
3160 | * return the title of the fixed country (if any). |
||
3161 | * |
||
3162 | * @return string | empty string |
||
3163 | **/ |
||
3164 | public function FixedCountry() |
||
3177 | |||
3178 | /** |
||
3179 | * Returns the region that applies to the order. |
||
3180 | * we check both billing and shipping, in case one of them is empty. |
||
3181 | * |
||
3182 | * @return DataObject | Null (EcommerceRegion) |
||
3183 | **/ |
||
3184 | public function Region() |
||
3221 | |||
3222 | /** |
||
3223 | * Casted variable |
||
3224 | * Currency is not the same as the standard one? |
||
3225 | * |
||
3226 | * @return bool |
||
3227 | **/ |
||
3228 | public function HasAlternativeCurrency() |
||
3244 | |||
3245 | /** |
||
3246 | * Makes sure exchange rate is updated and maintained before order is submitted |
||
3247 | * This method is public because it could be called from a shopping Cart Object. |
||
3248 | **/ |
||
3249 | public function EnsureCorrectExchangeRate() |
||
3267 | |||
3268 | /** |
||
3269 | * speeds up processing by storing the IsSubmitted value |
||
3270 | * we start with -1 to know if it has been requested before. |
||
3271 | * |
||
3272 | * @var bool |
||
3273 | */ |
||
3274 | protected $_isSubmittedTempVar = -1; |
||
3275 | |||
3276 | /** |
||
3277 | * Casted variable - has the order been submitted? |
||
3278 | * alias |
||
3279 | * @param bool $recalculate |
||
3280 | * |
||
3281 | * @return bool |
||
3282 | **/ |
||
3283 | public function IsSubmitted($recalculate = true) |
||
3287 | |||
3288 | /** |
||
3289 | * Casted variable - has the order been submitted? |
||
3290 | * |
||
3291 | * @param bool $recalculate |
||
3292 | * |
||
3293 | * @return bool |
||
3294 | **/ |
||
3295 | public function getIsSubmitted($recalculate = false) |
||
3307 | |||
3308 | /** |
||
3309 | * |
||
3310 | * |
||
3311 | * @return bool |
||
3312 | */ |
||
3313 | public function IsArchived() |
||
3323 | |||
3324 | /** |
||
3325 | * Submission Log for this Order (if any). |
||
3326 | * |
||
3327 | * @return Submission Log (OrderStatusLog_Submitted) | Null |
||
3328 | **/ |
||
3329 | public function SubmissionLog() |
||
3337 | |||
3338 | /** |
||
3339 | * Submission Log for this Order (if any). |
||
3340 | * |
||
3341 | * @return DateTime |
||
3342 | **/ |
||
3343 | public function OrderDate() |
||
3354 | |||
3355 | /** |
||
3356 | * @return int |
||
3357 | */ |
||
3358 | public function SecondsSinceBeingSubmitted() |
||
3366 | |||
3367 | /** |
||
3368 | * if the order can not be submitted, |
||
3369 | * then the reasons why it can not be submitted |
||
3370 | * will be returned by this method. |
||
3371 | * |
||
3372 | * @see Order::canSubmit |
||
3373 | * |
||
3374 | * @return ArrayList | null |
||
3375 | */ |
||
3376 | public function SubmitErrors() |
||
3392 | |||
3393 | /** |
||
3394 | * Casted variable - has the order been submitted? |
||
3395 | * |
||
3396 | * @param bool $withDetail |
||
3397 | * |
||
3398 | * @return string |
||
3399 | **/ |
||
3400 | public function CustomerStatus($withDetail = true) |
||
3422 | |||
3423 | /** |
||
3424 | * Casted variable - does the order have a potential shipping address? |
||
3425 | * |
||
3426 | * @return bool |
||
3427 | **/ |
||
3428 | public function CanHaveShippingAddress() |
||
3436 | |||
3437 | /** |
||
3438 | * returns the link to view the Order |
||
3439 | * WHY NOT CHECKOUT PAGE: first we check for cart page. |
||
3440 | * |
||
3441 | * @return CartPage | Null |
||
3442 | */ |
||
3443 | public function DisplayPage() |
||
3460 | |||
3461 | /** |
||
3462 | * returns the link to view the Order |
||
3463 | * WHY NOT CHECKOUT PAGE: first we check for cart page. |
||
3464 | * If a cart page has been created then we refer through to Cart Page. |
||
3465 | * Otherwise it will default to the checkout page. |
||
3466 | * |
||
3467 | * @param string $action - any action that should be added to the link. |
||
3468 | * |
||
3469 | * @return String(URLSegment) |
||
3470 | */ |
||
3471 | public function Link($action = null) |
||
3486 | |||
3487 | /** |
||
3488 | * Returns to link to access the Order's API. |
||
3489 | * |
||
3490 | * @param string $version |
||
3491 | * @param string $extension |
||
3492 | * |
||
3493 | * @return String(URL) |
||
3494 | */ |
||
3495 | public function APILink($version = 'v1', $extension = 'xml') |
||
3499 | |||
3500 | /** |
||
3501 | * returns the link to finalise the Order. |
||
3502 | * |
||
3503 | * @return String(URLSegment) |
||
3504 | */ |
||
3505 | public function CheckoutLink() |
||
3519 | |||
3520 | /** |
||
3521 | * Converts the Order into HTML, based on the Order Template. |
||
3522 | * |
||
3523 | * @return HTML Object |
||
3524 | **/ |
||
3525 | public function ConvertToHTML() |
||
3535 | |||
3536 | /** |
||
3537 | * Converts the Order into a serialized string |
||
3538 | * TO DO: check if this works and check if we need to use special sapphire serialization code. |
||
3539 | * |
||
3540 | * @return string - serialized object |
||
3541 | **/ |
||
3542 | public function ConvertToString() |
||
3546 | |||
3547 | /** |
||
3548 | * Converts the Order into a JSON object |
||
3549 | * TO DO: check if this works and check if we need to use special sapphire JSON code. |
||
3550 | * |
||
3551 | * @return string - JSON |
||
3552 | **/ |
||
3553 | public function ConvertToJSON() |
||
3557 | |||
3558 | /** |
||
3559 | * returns itself wtih more data added as variables. |
||
3560 | * We add has_one and has_many as variables like this: $this->MyHasOne_serialized = serialize($this->MyHasOne()). |
||
3561 | * |
||
3562 | * @return Order - with most important has one and has many items included as variables. |
||
3563 | **/ |
||
3564 | protected function addHasOneAndHasManyAsVariables() |
||
3577 | |||
3578 | /******************************************************* |
||
3579 | * 9. TEMPLATE RELATED STUFF |
||
3580 | *******************************************************/ |
||
3581 | |||
3582 | /** |
||
3583 | * returns the instance of EcommerceConfigAjax for use in templates. |
||
3584 | * In templates, it is used like this: |
||
3585 | * $EcommerceConfigAjax.TableID. |
||
3586 | * |
||
3587 | * @return EcommerceConfigAjax |
||
3588 | **/ |
||
3589 | public function AJAXDefinitions() |
||
3593 | |||
3594 | /** |
||
3595 | * returns the instance of EcommerceDBConfig. |
||
3596 | * |
||
3597 | * @return EcommerceDBConfig |
||
3598 | **/ |
||
3599 | public function EcomConfig() |
||
3603 | |||
3604 | /** |
||
3605 | * Collects the JSON data for an ajax return of the cart. |
||
3606 | * |
||
3607 | * @param array $js |
||
3608 | * |
||
3609 | * @return array (for use in AJAX for JSON) |
||
3610 | **/ |
||
3611 | public function updateForAjax(array $js) |
||
3664 | |||
3665 | /** |
||
3666 | * @ToDO: move to more appropriate class |
||
3667 | * |
||
3668 | * @return float |
||
3669 | **/ |
||
3670 | public function SubTotalCartValue() |
||
3674 | |||
3675 | /******************************************************* |
||
3676 | * 10. STANDARD SS METHODS (requireDefaultRecords, onBeforeDelete, etc...) |
||
3677 | *******************************************************/ |
||
3678 | |||
3679 | /** |
||
3680 | *standard SS method. |
||
3681 | **/ |
||
3682 | public function populateDefaults() |
||
3686 | |||
3687 | public function onBeforeWrite() |
||
3702 | |||
3703 | /** |
||
3704 | * standard SS method |
||
3705 | * adds the ability to update order after writing it. |
||
3706 | **/ |
||
3707 | public function onAfterWrite() |
||
3731 | |||
3732 | /** |
||
3733 | *standard SS method. |
||
3734 | * |
||
3735 | * delete attributes, statuslogs, and payments |
||
3736 | * THIS SHOULD NOT BE USED AS ORDERS SHOULD BE CANCELLED NOT DELETED |
||
3737 | */ |
||
3738 | public function onBeforeDelete() |
||
3783 | |||
3784 | /******************************************************* |
||
3785 | * 11. DEBUG |
||
3786 | *******************************************************/ |
||
3787 | |||
3788 | /** |
||
3789 | * Debug helper method. |
||
3790 | * Can be called from /shoppingcart/debug/. |
||
3791 | * |
||
3792 | * @return string |
||
3793 | */ |
||
3794 | public function debug() |
||
3800 | } |
||
3801 |
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.