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 | 'Title', |
||
46 | 'Total', |
||
47 | 'SubTotal', |
||
48 | 'TotalPaid', |
||
49 | 'TotalOutstanding', |
||
50 | 'ExchangeRate', |
||
51 | 'CurrencyUsed', |
||
52 | 'TotalItems', |
||
53 | 'TotalItemsTimesQuantity', |
||
54 | 'IsCancelled', |
||
55 | 'Country', |
||
56 | 'FullNameCountry', |
||
57 | 'IsSubmitted', |
||
58 | 'CustomerStatus', |
||
59 | 'CanHaveShippingAddress', |
||
60 | 'CancelledBy', |
||
61 | 'CurrencyUsed', |
||
62 | 'BillingAddress', |
||
63 | 'UseShippingAddress', |
||
64 | 'ShippingAddress', |
||
65 | 'Status', |
||
66 | 'Attributes', |
||
67 | 'OrderStatusLogs', |
||
68 | 'MemberID', |
||
69 | ), |
||
70 | ); |
||
71 | |||
72 | /** |
||
73 | * standard SS variable. |
||
74 | * |
||
75 | * @var array |
||
76 | */ |
||
77 | private static $db = array( |
||
78 | '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 |
||
79 | 'UseShippingAddress' => 'Boolean', |
||
80 | 'CustomerOrderNote' => 'Text', |
||
81 | 'ExchangeRate' => 'Double', |
||
82 | //'TotalItems_Saved' => 'Double', |
||
83 | //'TotalItemsTimesQuantity_Saved' => 'Double' |
||
84 | ); |
||
85 | |||
86 | private static $has_one = array( |
||
87 | 'Member' => 'Member', |
||
88 | 'BillingAddress' => 'BillingAddress', |
||
89 | 'ShippingAddress' => 'ShippingAddress', |
||
90 | 'Status' => 'OrderStep', |
||
91 | 'CancelledBy' => 'Member', |
||
92 | 'CurrencyUsed' => 'EcommerceCurrency', |
||
93 | ); |
||
94 | |||
95 | /** |
||
96 | * standard SS variable. |
||
97 | * |
||
98 | * @var array |
||
99 | */ |
||
100 | private static $has_many = array( |
||
101 | 'Attributes' => 'OrderAttribute', |
||
102 | 'OrderStatusLogs' => 'OrderStatusLog', |
||
103 | 'Payments' => 'EcommercePayment', |
||
104 | 'Emails' => 'OrderEmailRecord', |
||
105 | ); |
||
106 | |||
107 | /** |
||
108 | * standard SS variable. |
||
109 | * |
||
110 | * @var array |
||
111 | */ |
||
112 | private static $indexes = array( |
||
113 | 'SessionID' => true, |
||
114 | ); |
||
115 | |||
116 | /** |
||
117 | * standard SS variable. |
||
118 | * |
||
119 | * @var string |
||
120 | */ |
||
121 | private static $default_sort = '"LastEdited" DESC'; |
||
122 | |||
123 | /** |
||
124 | * standard SS variable. |
||
125 | * |
||
126 | * @var array |
||
127 | */ |
||
128 | private static $casting = array( |
||
129 | 'OrderEmail' => 'Text', |
||
130 | 'EmailLink' => 'Text', |
||
131 | 'PrintLink' => 'Text', |
||
132 | 'ShareLink' => 'Text', |
||
133 | 'RetrieveLink' => 'Text', |
||
134 | 'Title' => 'Text', |
||
135 | 'Total' => 'Currency', |
||
136 | 'TotalAsMoney' => 'Money', |
||
137 | 'SubTotal' => 'Currency', |
||
138 | 'SubTotalAsMoney' => 'Money', |
||
139 | 'TotalPaid' => 'Currency', |
||
140 | 'TotalPaidAsMoney' => 'Money', |
||
141 | 'TotalOutstanding' => 'Currency', |
||
142 | 'TotalOutstandingAsMoney' => 'Money', |
||
143 | 'HasAlternativeCurrency' => 'Boolean', |
||
144 | 'TotalItems' => 'Double', |
||
145 | 'TotalItemsTimesQuantity' => 'Double', |
||
146 | 'IsCancelled' => 'Boolean', |
||
147 | 'Country' => 'Varchar(3)', //This is the applicable country for the order - for tax purposes, etc.... |
||
148 | 'FullNameCountry' => 'Varchar', |
||
149 | 'IsSubmitted' => 'Boolean', |
||
150 | 'CustomerStatus' => 'Varchar', |
||
151 | 'CanHaveShippingAddress' => 'Boolean', |
||
152 | ); |
||
153 | |||
154 | /** |
||
155 | * standard SS variable. |
||
156 | * |
||
157 | * @var string |
||
158 | */ |
||
159 | private static $singular_name = 'Order'; |
||
160 | public function i18n_singular_name() |
||
164 | |||
165 | /** |
||
166 | * standard SS variable. |
||
167 | * |
||
168 | * @var string |
||
169 | */ |
||
170 | private static $plural_name = 'Orders'; |
||
171 | public function i18n_plural_name() |
||
175 | |||
176 | /** |
||
177 | * Standard SS variable. |
||
178 | * |
||
179 | * @var string |
||
180 | */ |
||
181 | private static $description = "A collection of items that together make up the 'Order'. An order can be placed."; |
||
182 | |||
183 | /** |
||
184 | * Tells us if an order needs to be recalculated |
||
185 | * can save one for each order... |
||
186 | * |
||
187 | * @var array |
||
188 | */ |
||
189 | private static $_needs_recalculating = array(); |
||
190 | |||
191 | /** |
||
192 | * @param bool (optional) $b |
||
193 | * @param int (optional) $orderID |
||
194 | * |
||
195 | * @return bool |
||
196 | */ |
||
197 | public static function set_needs_recalculating($b = true, $orderID = 0) |
||
201 | |||
202 | /** |
||
203 | * @param int (optional) $orderID |
||
204 | * |
||
205 | * @return bool |
||
206 | */ |
||
207 | public static function get_needs_recalculating($orderID = 0) |
||
211 | |||
212 | /** |
||
213 | * Total Items : total items in cart |
||
214 | * We start with -1 to easily identify if it has been run before. |
||
215 | * |
||
216 | * @var int |
||
217 | */ |
||
218 | protected $totalItems = null; |
||
219 | |||
220 | /** |
||
221 | * Total Items : total items in cart |
||
222 | * We start with -1 to easily identify if it has been run before. |
||
223 | * |
||
224 | * @var float |
||
225 | */ |
||
226 | protected $totalItemsTimesQuantity = null; |
||
227 | |||
228 | /** |
||
229 | * Returns a set of modifier forms for use in the checkout order form, |
||
230 | * Controller is optional, because the orderForm has its own default controller. |
||
231 | * |
||
232 | * This method only returns the Forms that should be included outside |
||
233 | * the editable table... Forms within it can be called |
||
234 | * from through the modifier itself. |
||
235 | * |
||
236 | * @param Controller $optionalController |
||
237 | * @param Validator $optionalValidator |
||
238 | * |
||
239 | * @return ArrayList (ModifierForms) | Null |
||
240 | **/ |
||
241 | public function getModifierForms(Controller $optionalController = null, Validator $optionalValidator = null) |
||
263 | |||
264 | /** |
||
265 | * This function returns the OrderSteps. |
||
266 | * |
||
267 | * @return ArrayList (OrderSteps) |
||
268 | **/ |
||
269 | public static function get_order_status_options() |
||
273 | |||
274 | /** |
||
275 | * Like the standard byID, but it checks whether we are allowed to view the order. |
||
276 | * |
||
277 | * @return: Order | Null |
||
278 | **/ |
||
279 | public static function get_by_id_if_can_view($id) |
||
293 | |||
294 | /** |
||
295 | * returns a Datalist with the submitted order log included |
||
296 | * this allows you to sort the orders by their submit dates. |
||
297 | * You can retrieve this list and then add more to it (e.g. additional filters, additional joins, etc...). |
||
298 | * |
||
299 | * @param bool $onlySubmittedOrders - only include Orders that have already been submitted. |
||
300 | * @param bool $includeCancelledOrders - only include Orders that have already been submitted. |
||
301 | * |
||
302 | * @return DataList (Orders) |
||
303 | */ |
||
304 | public static function get_datalist_of_orders_with_submit_record($onlySubmittedOrders = true, $includeCancelledOrders = false) |
||
326 | |||
327 | /******************************************************* |
||
328 | * 1. CMS STUFF |
||
329 | *******************************************************/ |
||
330 | |||
331 | /** |
||
332 | * fields that we remove from the parent::getCMSFields object set. |
||
333 | * |
||
334 | * @var array |
||
335 | */ |
||
336 | protected $fieldsAndTabsToBeRemoved = array( |
||
337 | 'MemberID', |
||
338 | 'Attributes', |
||
339 | 'SessionID', |
||
340 | 'Emails', |
||
341 | 'BillingAddressID', |
||
342 | 'ShippingAddressID', |
||
343 | 'UseShippingAddress', |
||
344 | 'OrderStatusLogs', |
||
345 | 'Payments', |
||
346 | 'OrderDate', |
||
347 | 'ExchangeRate', |
||
348 | 'CurrencyUsedID', |
||
349 | 'StatusID', |
||
350 | 'Currency', |
||
351 | ); |
||
352 | |||
353 | /** |
||
354 | * STANDARD SILVERSTRIPE STUFF. |
||
355 | **/ |
||
356 | private static $summary_fields = array( |
||
357 | 'Title' => 'Title', |
||
358 | 'Status.Title' => 'Next Step', |
||
359 | 'Member.Surname' => 'Name', |
||
360 | 'Member.Email' => 'Email', |
||
361 | 'TotalAsMoney.Nice' => 'Total', |
||
362 | 'TotalItemsTimesQuantity' => 'Units' |
||
363 | ); |
||
364 | |||
365 | /** |
||
366 | * STANDARD SILVERSTRIPE STUFF. |
||
367 | * |
||
368 | * @todo: how to translate this? |
||
369 | **/ |
||
370 | private static $searchable_fields = array( |
||
371 | 'ID' => array( |
||
372 | 'field' => 'NumericField', |
||
373 | 'title' => 'Order Number', |
||
374 | ), |
||
375 | 'MemberID' => array( |
||
376 | 'field' => 'TextField', |
||
377 | 'filter' => 'OrderFilters_MemberAndAddress', |
||
378 | 'title' => 'Customer Details', |
||
379 | ), |
||
380 | 'Created' => array( |
||
381 | 'field' => 'TextField', |
||
382 | 'filter' => 'OrderFilters_AroundDateFilter', |
||
383 | 'title' => 'Date (e.g. Today, 1 jan 2007, or last week)', |
||
384 | ), |
||
385 | //make sure to keep the items below, otherwise they do not show in form |
||
386 | 'StatusID' => array( |
||
387 | 'filter' => 'OrderFilters_MultiOptionsetStatusIDFilter', |
||
388 | ), |
||
389 | 'CancelledByID' => array( |
||
390 | 'filter' => 'OrderFilters_HasBeenCancelled', |
||
391 | 'title' => 'Cancelled by ...', |
||
392 | ), |
||
393 | ); |
||
394 | |||
395 | /** |
||
396 | * Determine which properties on the DataObject are |
||
397 | * searchable, and map them to their default {@link FormField} |
||
398 | * representations. Used for scaffolding a searchform for {@link ModelAdmin}. |
||
399 | * |
||
400 | * Some additional logic is included for switching field labels, based on |
||
401 | * how generic or specific the field type is. |
||
402 | * |
||
403 | * Used by {@link SearchContext}. |
||
404 | * |
||
405 | * @param array $_params |
||
406 | * 'fieldClasses': Associative array of field names as keys and FormField classes as values |
||
407 | * 'restrictFields': Numeric array of a field name whitelist |
||
408 | * |
||
409 | * @return FieldList |
||
410 | */ |
||
411 | public function scaffoldSearchFields($_params = null) |
||
451 | |||
452 | /** |
||
453 | * link to edit the record. |
||
454 | * |
||
455 | * @param string | Null $action - e.g. edit |
||
456 | * |
||
457 | * @return string |
||
458 | */ |
||
459 | public function CMSEditLink($action = null) |
||
467 | |||
468 | /** |
||
469 | * STANDARD SILVERSTRIPE STUFF |
||
470 | * broken up into submitted and not (yet) submitted. |
||
471 | **/ |
||
472 | public function getCMSFields() |
||
473 | { |
||
474 | $fields = $this->scaffoldFormFields(array( |
||
475 | // Don't allow has_many/many_many relationship editing before the record is first saved |
||
476 | 'includeRelations' => false, |
||
477 | 'tabbed' => true, |
||
478 | 'ajaxSafe' => true |
||
479 | )); |
||
480 | $fields->insertBefore( |
||
481 | Tab::create( |
||
482 | 'Next', |
||
483 | _t('Order.NEXT_TAB', 'Action') |
||
484 | ), |
||
485 | 'Main' |
||
486 | ); |
||
487 | $fields->addFieldsToTab( |
||
488 | 'Root', |
||
489 | array( |
||
490 | Tab::create( |
||
491 | "Items", |
||
492 | _t('Order.ITEMS_TAB', 'Items') |
||
493 | ), |
||
494 | Tab::create( |
||
495 | "Extras", |
||
496 | _t('Order.MODIFIERS_TAB', 'Adjustments') |
||
497 | ), |
||
498 | Tab::create( |
||
499 | 'Emails', |
||
500 | _t('Order.EMAILS_TAB', 'Emails') |
||
501 | ), |
||
502 | Tab::create( |
||
503 | 'Payments', |
||
504 | _t('Order.PAYMENTS_TAB', 'Payment') |
||
505 | ), |
||
506 | Tab::create( |
||
507 | 'Account', |
||
508 | _t('Order.ACCOUNT_TAB', 'Account') |
||
509 | ), |
||
510 | Tab::create( |
||
511 | 'Currency', |
||
512 | _t('Order.CURRENCY_TAB', 'Currency') |
||
513 | ), |
||
514 | Tab::create( |
||
515 | 'Addresses', |
||
516 | _t('Order.ADDRESSES_TAB', 'Addresses') |
||
517 | ), |
||
518 | Tab::create( |
||
519 | 'Log', |
||
520 | _t('Order.LOG_TAB', 'Notes') |
||
521 | ), |
||
522 | Tab::create( |
||
523 | 'Cancellations', |
||
524 | _t('Order.CANCELLATION_TAB', 'Cancel') |
||
525 | ), |
||
526 | ) |
||
527 | ); |
||
528 | //as we are no longer using the parent:;getCMSFields |
||
529 | // we had to add the updateCMSFields hook. |
||
530 | $this->extend('updateCMSFields', $fields); |
||
531 | $currentMember = Member::currentUser(); |
||
532 | if (!$this->exists() || !$this->StatusID) { |
||
533 | $firstStep = OrderStep::get()->First(); |
||
534 | $this->StatusID = $firstStep->ID; |
||
535 | $this->write(); |
||
536 | } |
||
537 | $submitted = $this->IsSubmitted() ? true : false; |
||
538 | if ($submitted) { |
||
539 | //TODO |
||
540 | //Having trouble here, as when you submit the form (for example, a payment confirmation) |
||
541 | //as the step moves forward, meaning the fields generated are incorrect, causing an error |
||
542 | //"I can't handle sub-URLs of a Form object." generated by the RequestHandler. |
||
543 | //Therefore we need to try reload the page so that it will be requesting the correct URL to generate the correct fields for the current step |
||
544 | //Or something similar. |
||
545 | //why not check if the URL == $this->CMSEditLink() |
||
546 | //and only tryToFinaliseOrder if this is true.... |
||
547 | if ($_SERVER['REQUEST_URI'] == $this->CMSEditLink() || $_SERVER['REQUEST_URI'] == $this->CMSEditLink('edit')) { |
||
548 | $this->tryToFinaliseOrder(); |
||
549 | } |
||
550 | } else { |
||
551 | $this->init(true); |
||
552 | $this->calculateOrderAttributes(true); |
||
553 | Session::set('EcommerceOrderGETCMSHack', $this->ID); |
||
554 | } |
||
555 | if ($submitted) { |
||
556 | $this->fieldsAndTabsToBeRemoved[] = 'CustomerOrderNote'; |
||
557 | } else { |
||
558 | $this->fieldsAndTabsToBeRemoved[] = 'Emails'; |
||
559 | } |
||
560 | foreach ($this->fieldsAndTabsToBeRemoved as $field) { |
||
561 | $fields->removeByName($field); |
||
562 | } |
||
563 | $orderSummaryConfig = GridFieldConfig_Base::create(); |
||
564 | $orderSummaryConfig->removeComponentsByType('GridFieldToolbarHeader'); |
||
565 | // $orderSummaryConfig->removeComponentsByType('GridFieldSortableHeader'); |
||
566 | $orderSummaryConfig->removeComponentsByType('GridFieldFilterHeader'); |
||
567 | $orderSummaryConfig->removeComponentsByType('GridFieldPageCount'); |
||
568 | $orderSummaryConfig->removeComponentsByType('GridFieldPaginator'); |
||
569 | $nextFieldArray = array( |
||
570 | LiteralField::create('CssFix', '<style>#Root_Next h2 {padding: 0!important; margin: 0!important; margin-top: 2em!important;}</style>'), |
||
571 | HeaderField::create('OrderSummaryHeader', _t('Order.THIS_ORDER_HEADER', 'Order Summary')), |
||
572 | GridField::create( |
||
573 | 'OrderSummary', |
||
574 | _t('Order.CURRENT_STATUS', 'Summary'), |
||
575 | ArrayList::create(array($this)), |
||
576 | $orderSummaryConfig |
||
577 | ), |
||
578 | ); |
||
579 | $keyNotes = OrderStatusLog::get()->filter( |
||
580 | array( |
||
581 | 'OrderID' => $this->ID, |
||
582 | 'ClassName' => 'OrderStatusLog' |
||
583 | ) |
||
584 | ); |
||
585 | if ($keyNotes->count()) { |
||
586 | $notesSummaryConfig = GridFieldConfig_RecordViewer::create(); |
||
587 | $notesSummaryConfig->removeComponentsByType('GridFieldToolbarHeader'); |
||
588 | $notesSummaryConfig->removeComponentsByType('GridFieldFilterHeader'); |
||
589 | // $orderSummaryConfig->removeComponentsByType('GridFieldSortableHeader'); |
||
590 | $notesSummaryConfig->removeComponentsByType('GridFieldPageCount'); |
||
591 | $notesSummaryConfig->removeComponentsByType('GridFieldPaginator'); |
||
592 | $nextFieldArray = array_merge( |
||
593 | $nextFieldArray, |
||
594 | array( |
||
595 | HeaderField::create('KeyNotesHeader', _t('Order.KEY_NOTES_HEADER', 'Key Notes')), |
||
596 | GridField::create( |
||
597 | 'OrderStatusLogSummary', |
||
598 | _t('Order.CURRENT_KEY_NOTES', 'Key Notes'), |
||
599 | $keyNotes, |
||
600 | $notesSummaryConfig |
||
601 | ) |
||
602 | ) |
||
603 | ); |
||
604 | } |
||
605 | $nextFieldArray = array_merge( |
||
606 | $nextFieldArray, |
||
607 | array( |
||
608 | HeaderField::create('MyOrderStepHeader', _t('Order.CURRENT_STATUS', '1. Current Status')), |
||
609 | $this->OrderStepField() |
||
610 | ) |
||
611 | ); |
||
612 | |||
613 | //is the member is a shop admin they can always view it |
||
614 | if (EcommerceRole::current_member_can_process_orders(Member::currentUser())) { |
||
615 | $nextFieldArray = array_merge( |
||
616 | $nextFieldArray, |
||
617 | array( |
||
618 | HeaderField::create('OrderStepNextStepHeader', _t('Order.ACTION_NEXT_STEP', '2. Action Next Step')), |
||
619 | HeaderField::create('ActionNextStepManually', _t('Order.MANUAL_STATUS_CHANGE', '3. Move Order Along')), |
||
620 | LiteralField::create('OrderStepNextStepHeaderExtra', '<p>'._t('Order.NEEDTOREFRESH', 'If you have made any changes to the order then you will have to refresh or save this record to move it along.').'</p>'), |
||
621 | EcommerceCMSButtonField::create( |
||
622 | 'StatusIDExplanation', |
||
623 | $this->CMSEditLink(), |
||
624 | _t('Order.REFRESH', 'refresh now') |
||
625 | ) |
||
626 | ) |
||
627 | ); |
||
628 | } |
||
629 | $nextFieldArray = array_merge( |
||
630 | $nextFieldArray, |
||
631 | array( |
||
632 | EcommerceCMSButtonField::create( |
||
633 | 'AddNoteButton', |
||
634 | $this->CMSEditLink('ItemEditForm/field/OrderStatusLog/item/new'), |
||
635 | _t('Order.ADD_NOTE', 'Add Note') |
||
636 | ) |
||
637 | ) |
||
638 | ); |
||
639 | $fields->addFieldsToTab( |
||
640 | 'Root.Next', |
||
641 | $nextFieldArray |
||
642 | ); |
||
643 | |||
644 | $this->MyStep()->addOrderStepFields($fields, $this); |
||
645 | |||
646 | if ($submitted) { |
||
647 | $permaLinkLabel = _t('Order.PERMANENT_LINK', 'Customer Link'); |
||
648 | $html = '<p>'.$permaLinkLabel.': <a href="'.$this->getRetrieveLink().'">'.$this->getRetrieveLink().'</a></p>'; |
||
649 | $shareLinkLabel = _t('Order.SHARE_LINK', 'Share Link'); |
||
650 | $html .= '<p>'.$shareLinkLabel.': <a href="'.$this->getShareLink().'">'.$this->getShareLink().'</a></p>'; |
||
651 | $js = "window.open(this.href, 'payment', 'toolbar=0,scrollbars=1,location=1,statusbar=1,menubar=0,resizable=1,width=800,height=600'); return false;"; |
||
652 | $link = $this->getPrintLink(); |
||
653 | $label = _t('Order.PRINT_INVOICE', 'invoice'); |
||
654 | $linkHTML = '<a href="'.$link.'" onclick="'.$js.'">'.$label.'</a>'; |
||
655 | $linkHTML .= ' | '; |
||
656 | $link = $this->getPackingSlipLink(); |
||
657 | $label = _t('Order.PRINT_PACKING_SLIP', 'packing slip'); |
||
658 | $labelPrint = _t('Order.PRINT', 'Print'); |
||
659 | $linkHTML .= '<a href="'.$link.'" onclick="'.$js.'">'.$label.'</a>'; |
||
660 | $html .= '<h3>'; |
||
661 | $html .= $labelPrint.': '.$linkHTML; |
||
662 | $html .= '</h3>'; |
||
663 | |||
664 | $fields->addFieldToTab( |
||
665 | 'Root.Main', |
||
666 | LiteralField::create('getPrintLinkANDgetPackingSlipLink', $html) |
||
667 | ); |
||
668 | |||
669 | //add order here as well. |
||
670 | $fields->addFieldToTab( |
||
671 | 'Root.Main', |
||
672 | new LiteralField( |
||
673 | 'MainDetails', |
||
674 | '<iframe src="'.$this->getPrintLink().'" width="100%" height="2500" style="border: 5px solid #2e7ead; border-radius: 2px;"></iframe>') |
||
675 | ); |
||
676 | $fields->addFieldsToTab( |
||
677 | 'Root.Items', |
||
678 | array( |
||
679 | GridField::create( |
||
680 | 'Items_Sold', |
||
681 | 'Items Sold', |
||
682 | $this->Items(), |
||
683 | new GridFieldConfig_RecordViewer |
||
684 | ) |
||
685 | ) |
||
686 | ); |
||
687 | $fields->addFieldsToTab( |
||
688 | 'Root.Extras', |
||
689 | array( |
||
690 | GridField::create( |
||
691 | 'Modifications', |
||
692 | 'Price (and other) adjustments', |
||
693 | $this->Modifiers(), |
||
694 | new GridFieldConfig_RecordViewer |
||
695 | ) |
||
696 | ) |
||
697 | ); |
||
698 | $fields->addFieldsToTab( |
||
699 | 'Root.Emails', |
||
700 | array( |
||
701 | $this->getEmailsTableField() |
||
702 | ) |
||
703 | ); |
||
704 | $fields->addFieldsToTab( |
||
705 | 'Root.Payments', |
||
706 | array( |
||
707 | $this->getPaymentsField(), |
||
708 | new ReadOnlyField('TotalPaidNice', _t('Order.TOTALPAID', 'Total Paid'), $this->TotalPaidAsCurrencyObject()->Nice()), |
||
709 | new ReadOnlyField('TotalOutstandingNice', _t('Order.TOTALOUTSTANDING', 'Total Outstanding'), $this->getTotalOutstandingAsMoney()->Nice()) |
||
710 | ) |
||
711 | ); |
||
712 | if ($this->canPay()) { |
||
713 | $link = EcommercePaymentController::make_payment_link($this->ID); |
||
714 | $js = "window.open(this.href, 'payment', 'toolbar=0,scrollbars=1,location=1,statusbar=1,menubar=0,resizable=1,width=800,height=600'); return false;"; |
||
715 | $header = _t('Order.MAKEPAYMENT', 'make payment'); |
||
716 | $label = _t('Order.MAKEADDITIONALPAYMENTNOW', 'make additional payment now'); |
||
717 | $linkHTML = '<a href="'.$link.'" onclick="'.$js.'">'.$label.'</a>'; |
||
718 | $fields->addFieldToTab('Root.Payments', new HeaderField('MakeAdditionalPaymentHeader', $header, 3)); |
||
719 | $fields->addFieldToTab('Root.Payments', new LiteralField('MakeAdditionalPayment', $linkHTML)); |
||
720 | } |
||
721 | //member |
||
722 | $member = $this->Member(); |
||
723 | if ($member && $member->exists()) { |
||
724 | $fields->addFieldToTab('Root.Account', new LiteralField('MemberDetails', $member->getEcommerceFieldsForCMS())); |
||
725 | } else { |
||
726 | $fields->addFieldToTab('Root.Account', new LiteralField('MemberDetails', |
||
727 | '<p>'._t('Order.NO_ACCOUNT', 'There is no --- account --- associated with this order').'</p>' |
||
728 | )); |
||
729 | } |
||
730 | $cancelledField = $fields->dataFieldByName('CancelledByID'); |
||
731 | $fields->removeByName('CancelledByID'); |
||
732 | $shopAdminAndCurrentCustomerArray = EcommerceRole::list_of_admins(true); |
||
733 | if ($member && $member->exists()) { |
||
734 | $shopAdminAndCurrentCustomerArray[$member->ID] = $member->getName(); |
||
735 | } |
||
736 | if ($this->CancelledByID) { |
||
737 | if ($cancellingMember = $this->CancelledBy()) { |
||
738 | $shopAdminAndCurrentCustomerArray[$this->CancelledByID] = $cancellingMember->getName(); |
||
739 | } |
||
740 | } |
||
741 | if ($this->canCancel()) { |
||
742 | $fields->addFieldsToTab( |
||
743 | 'Root.Cancellations', |
||
744 | array( |
||
745 | DropdownField::create( |
||
746 | 'CancelledByID', |
||
747 | $cancelledField->Title(), |
||
748 | $shopAdminAndCurrentCustomerArray |
||
749 | ) |
||
750 | ) |
||
751 | ); |
||
752 | } else { |
||
753 | $cancelledBy = isset($shopAdminAndCurrentCustomerArray[$this->CancelledByID]) && $this->CancelledByID ? $shopAdminAndCurrentCustomerArray[$this->CancelledByID] : _t('Order.NOT_CANCELLED', 'not cancelled'); |
||
754 | $fields->addFieldsToTab( |
||
755 | 'Root.Cancellations', |
||
756 | ReadonlyField::create( |
||
757 | 'CancelledByDisplay', |
||
758 | $cancelledField->Title(), |
||
759 | $cancelledBy |
||
760 | |||
761 | ) |
||
762 | ); |
||
763 | } |
||
764 | $fields->addFieldToTab('Root.Log', $this->getOrderStatusLogsTableField_Archived()); |
||
765 | $submissionLog = $this->SubmissionLog(); |
||
766 | if ($submissionLog) { |
||
767 | $fields->addFieldToTab('Root.Log', |
||
768 | ReadonlyField::create( |
||
769 | 'SequentialOrderNumber', |
||
770 | _t('Order.SEQUENTIALORDERNUMBER', 'Consecutive order number'), |
||
771 | $submissionLog->SequentialOrderNumber |
||
772 | )->setRightTitle('e.g. 1,2,3,4,5...') |
||
773 | ); |
||
774 | } |
||
775 | } else { |
||
776 | $linkText = _t( |
||
777 | 'Order.LOAD_THIS_ORDER', |
||
778 | 'load this order' |
||
779 | ); |
||
780 | $message = _t( |
||
781 | 'Order.NOSUBMITTEDYET', |
||
782 | 'No details are shown here as this order has not been submitted yet. You can {link} to submit it... NOTE: For this, you will be logged in as the customer and logged out as (shop)admin .', |
||
783 | array('link' => '<a href="'.$this->getRetrieveLink().'" data-popup="true">'.$linkText.'</a>') |
||
784 | ); |
||
785 | $fields->addFieldToTab('Root.Next', new LiteralField('MainDetails', '<p>'.$message.'</p>')); |
||
786 | $fields->addFieldToTab('Root.Items', $this->getOrderItemsField()); |
||
787 | $fields->addFieldToTab('Root.Extras', $this->getModifierTableField()); |
||
788 | |||
789 | //MEMBER STUFF |
||
790 | $specialOptionsArray = array(); |
||
791 | if ($this->MemberID) { |
||
792 | $specialOptionsArray[0] = _t('Order.SELECTCUSTOMER', '--- Remover Customer ---'); |
||
793 | $specialOptionsArray[$this->MemberID] = _t('Order.LEAVEWITHCURRENTCUSTOMER', '- Leave with current customer: ').$this->Member()->getTitle(); |
||
794 | } elseif ($currentMember) { |
||
795 | $specialOptionsArray[0] = _t('Order.SELECTCUSTOMER', '--- Select Customers ---'); |
||
796 | $currentMemberID = $currentMember->ID; |
||
797 | $specialOptionsArray[$currentMemberID] = _t('Order.ASSIGNTHISORDERTOME', '- Assign this order to me: ').$currentMember->getTitle(); |
||
798 | } |
||
799 | //MEMBER FIELD!!!!!!! |
||
800 | $memberArray = $specialOptionsArray + EcommerceRole::list_of_customers(true); |
||
801 | $fields->addFieldToTab('Root.Next', new DropdownField('MemberID', _t('Order.SELECTCUSTOMER', 'Select Customer'), $memberArray), 'CustomerOrderNote'); |
||
802 | $memberArray = null; |
||
803 | } |
||
804 | $fields->addFieldToTab('Root.Addresses', new HeaderField('BillingAddressHeader', _t('Order.BILLINGADDRESS', 'Billing Address'))); |
||
805 | |||
806 | $fields->addFieldToTab('Root.Addresses', $this->getBillingAddressField()); |
||
807 | |||
808 | if (EcommerceConfig::get('OrderAddress', 'use_separate_shipping_address')) { |
||
809 | $fields->addFieldToTab('Root.Addresses', new HeaderField('ShippingAddressHeader', _t('Order.SHIPPINGADDRESS', 'Shipping Address'))); |
||
810 | $fields->addFieldToTab('Root.Addresses', new CheckboxField('UseShippingAddress', _t('Order.USESEPERATEADDRESS', 'Use separate shipping address?'))); |
||
811 | if ($this->UseShippingAddress) { |
||
812 | $fields->addFieldToTab('Root.Addresses', $this->getShippingAddressField()); |
||
813 | } |
||
814 | } |
||
815 | $currencies = EcommerceCurrency::get_list(); |
||
816 | if ($currencies && $currencies->count()) { |
||
817 | $currencies = $currencies->map()->toArray(); |
||
818 | $fields->addFieldToTab('Root.Currency', new ReadOnlyField('ExchangeRate ', _t('Order.EXCHANGERATE', 'Exchange Rate'), $this->ExchangeRate)); |
||
819 | $fields->addFieldToTab('Root.Currency', $currencyField = new DropdownField('CurrencyUsedID', _t('Order.CurrencyUsed', 'Currency Used'), $currencies)); |
||
820 | if ($this->IsSubmitted()) { |
||
821 | $fields->replaceField('CurrencyUsedID', $fields->dataFieldByName('CurrencyUsedID')->performReadonlyTransformation()); |
||
822 | } |
||
823 | } else { |
||
824 | $fields->addFieldToTab('Root.Currency', new LiteralField('CurrencyInfo', '<p>You can not change currencies, because no currencies have been created.</p>')); |
||
825 | $fields->replaceField('CurrencyUsedID', $fields->dataFieldByName('CurrencyUsedID')->performReadonlyTransformation()); |
||
826 | } |
||
827 | $fields->addFieldToTab('Root.Log', new ReadonlyField('Created', _t('Root.CREATED', 'Created'))); |
||
828 | $fields->addFieldToTab('Root.Log', new ReadonlyField('LastEdited', _t('Root.LASTEDITED', 'Last saved'))); |
||
829 | $this->extend('updateCMSFields', $fields); |
||
830 | |||
831 | return $fields; |
||
832 | } |
||
833 | |||
834 | /** |
||
835 | * Field to add and edit Order Items. |
||
836 | * |
||
837 | * @return GridField |
||
838 | */ |
||
839 | protected function getOrderItemsField() |
||
846 | |||
847 | /** |
||
848 | * Field to add and edit Modifiers. |
||
849 | * |
||
850 | * @return GridField |
||
851 | */ |
||
852 | public function getModifierTableField() |
||
859 | |||
860 | /** |
||
861 | *@return GridField |
||
862 | **/ |
||
863 | protected function getBillingAddressField() |
||
879 | |||
880 | /** |
||
881 | *@return GridField |
||
882 | **/ |
||
883 | protected function getShippingAddressField() |
||
899 | |||
900 | /** |
||
901 | * Needs to be public because the OrderStep::getCMSFIelds accesses it. |
||
902 | * |
||
903 | * @param string $sourceClass |
||
904 | * @param string $title |
||
905 | * |
||
906 | * @return GridField |
||
907 | **/ |
||
908 | public function getOrderStatusLogsTableField( |
||
923 | |||
924 | /** |
||
925 | * Needs to be public because the OrderStep::getCMSFIelds accesses it. |
||
926 | * |
||
927 | * @param string $sourceClass |
||
928 | * @param string $title |
||
929 | * |
||
930 | * @return GridField |
||
931 | **/ |
||
932 | public function getOrderStatusLogsTableFieldEditable( |
||
942 | |||
943 | /** |
||
944 | * @param string $sourceClass |
||
945 | * @param string $title |
||
946 | * @param FieldList $fieldList (Optional) |
||
947 | * @param FieldList $detailedFormFields (Optional) |
||
948 | * |
||
949 | * @return GridField |
||
950 | **/ |
||
951 | protected function getOrderStatusLogsTableField_Archived( |
||
968 | |||
969 | /** |
||
970 | * @return GridField |
||
971 | **/ |
||
972 | public function getEmailsTableField() |
||
980 | |||
981 | /** |
||
982 | * @return GridField |
||
983 | */ |
||
984 | protected function getPaymentsField() |
||
993 | |||
994 | /** |
||
995 | * @return OrderStepField |
||
996 | */ |
||
997 | public function OrderStepField() |
||
1001 | |||
1002 | /******************************************************* |
||
1003 | * 2. MAIN TRANSITION FUNCTIONS |
||
1004 | *******************************************************/ |
||
1005 | |||
1006 | /** |
||
1007 | * init runs on start of a new Order (@see onAfterWrite) |
||
1008 | * it adds all the modifiers to the orders and the starting OrderStep. |
||
1009 | * |
||
1010 | * @param bool $recalculate |
||
1011 | * |
||
1012 | * @return DataObject (Order) |
||
1013 | **/ |
||
1014 | public function init($recalculate = false) |
||
1074 | |||
1075 | /** |
||
1076 | * @var array |
||
1077 | */ |
||
1078 | private static $_try_to_finalise_order_is_running = array(); |
||
1079 | |||
1080 | /** |
||
1081 | * Goes through the order steps and tries to "apply" the next status to the order. |
||
1082 | * |
||
1083 | * @param bool $runAgain |
||
1084 | * @param bool $fromOrderQueue - is it being called from the OrderProcessQueue (or similar) |
||
1085 | **/ |
||
1086 | public function tryToFinaliseOrder($runAgain = false, $fromOrderQueue = false) |
||
1133 | |||
1134 | /** |
||
1135 | * Goes through the order steps and tries to "apply" the next step |
||
1136 | * Step is updated after the other one is completed... |
||
1137 | * |
||
1138 | * @return int (StatusID or false if the next status can not be "applied") |
||
1139 | **/ |
||
1140 | public function doNextStatus() |
||
1155 | |||
1156 | /** |
||
1157 | * cancel an order. |
||
1158 | * |
||
1159 | * @param Member $member - the user cancelling the order |
||
1160 | * @param string $reason - the reason the order is cancelled |
||
1161 | * |
||
1162 | * @return OrderStatusLog_Cancel |
||
1163 | */ |
||
1164 | public function Cancel(Member $member, $reason = '') |
||
1180 | |||
1181 | /** |
||
1182 | * returns true if successful. |
||
1183 | * |
||
1184 | * @param bool $avoidWrites |
||
1185 | * |
||
1186 | * @return bool |
||
1187 | */ |
||
1188 | public function Archive($avoidWrites = true) |
||
1211 | |||
1212 | /******************************************************* |
||
1213 | * 3. STATUS RELATED FUNCTIONS / SHORTCUTS |
||
1214 | *******************************************************/ |
||
1215 | |||
1216 | /** |
||
1217 | * Avoids caching of $this->Status(). |
||
1218 | * |
||
1219 | * @return DataObject (current OrderStep) |
||
1220 | */ |
||
1221 | public function MyStep() |
||
1239 | |||
1240 | /** |
||
1241 | * Return the OrderStatusLog that is relevant to the Order status. |
||
1242 | * |
||
1243 | * @return OrderStatusLog |
||
1244 | */ |
||
1245 | public function RelevantLogEntry() |
||
1249 | |||
1250 | /** |
||
1251 | * @return OrderStep (current OrderStep that can be seen by customer) |
||
1252 | */ |
||
1253 | public function CurrentStepVisibleToCustomer() |
||
1265 | |||
1266 | /** |
||
1267 | * works out if the order is still at the first OrderStep. |
||
1268 | * |
||
1269 | * @return bool |
||
1270 | */ |
||
1271 | public function IsFirstStep() |
||
1283 | |||
1284 | /** |
||
1285 | * Is the order still being "edited" by the customer? |
||
1286 | * |
||
1287 | * @return bool |
||
1288 | */ |
||
1289 | public function IsInCart() |
||
1293 | |||
1294 | /** |
||
1295 | * The order has "passed" the IsInCart phase. |
||
1296 | * |
||
1297 | * @return bool |
||
1298 | */ |
||
1299 | public function IsPastCart() |
||
1303 | |||
1304 | /** |
||
1305 | * Are there still steps the order needs to go through? |
||
1306 | * |
||
1307 | * @return bool |
||
1308 | */ |
||
1309 | public function IsUncomplete() |
||
1313 | |||
1314 | /** |
||
1315 | * Is the order in the :"processing" phaase.? |
||
1316 | * |
||
1317 | * @return bool |
||
1318 | */ |
||
1319 | public function IsProcessing() |
||
1323 | |||
1324 | /** |
||
1325 | * Is the order completed? |
||
1326 | * |
||
1327 | * @return bool |
||
1328 | */ |
||
1329 | public function IsCompleted() |
||
1333 | |||
1334 | /** |
||
1335 | * Has the order been paid? |
||
1336 | * TODO: why do we check if there is a total at all? |
||
1337 | * |
||
1338 | * @return bool |
||
1339 | */ |
||
1340 | public function IsPaid() |
||
1348 | |||
1349 | /** |
||
1350 | * Has the order been paid? |
||
1351 | * TODO: why do we check if there is a total at all? |
||
1352 | * |
||
1353 | * @return bool |
||
1354 | */ |
||
1355 | public function PaymentIsPending() |
||
1371 | |||
1372 | /** |
||
1373 | * shows payments that are meaningfull |
||
1374 | * if the order has been paid then only show successful payments. |
||
1375 | * |
||
1376 | * @return DataList |
||
1377 | */ |
||
1378 | public function RelevantPayments() |
||
1388 | |||
1389 | /** |
||
1390 | * Has the order been cancelled? |
||
1391 | * |
||
1392 | * @return bool |
||
1393 | */ |
||
1394 | public function IsCancelled() |
||
1402 | |||
1403 | /** |
||
1404 | * Has the order been cancelled by the customer? |
||
1405 | * |
||
1406 | * @return bool |
||
1407 | */ |
||
1408 | public function IsCustomerCancelled() |
||
1416 | |||
1417 | /** |
||
1418 | * Has the order been cancelled by the administrator? |
||
1419 | * |
||
1420 | * @return bool |
||
1421 | */ |
||
1422 | public function IsAdminCancelled() |
||
1437 | |||
1438 | /** |
||
1439 | * Is the Shop Closed for business? |
||
1440 | * |
||
1441 | * @return bool |
||
1442 | */ |
||
1443 | public function ShopClosed() |
||
1447 | |||
1448 | /******************************************************* |
||
1449 | * 4. LINKING ORDER WITH MEMBER AND ADDRESS |
||
1450 | *******************************************************/ |
||
1451 | |||
1452 | /** |
||
1453 | * Returns a member linked to the order. |
||
1454 | * If a member is already linked, it will return the existing member. |
||
1455 | * Otherwise it will return a new Member. |
||
1456 | * |
||
1457 | * Any new member is NOT written, because we dont want to create a new member unless we have to! |
||
1458 | * We will not add a member to the order unless a new one is created in the checkout |
||
1459 | * OR the member is logged in / logs in. |
||
1460 | * |
||
1461 | * Also note that if a new member is created, it is not automatically written |
||
1462 | * |
||
1463 | * @param bool $forceCreation - if set to true then the member will always be saved in the database. |
||
1464 | * |
||
1465 | * @return Member |
||
1466 | **/ |
||
1467 | public function CreateOrReturnExistingMember($forceCreation = false) |
||
1490 | |||
1491 | /** |
||
1492 | * Returns either the existing one or a new Order Address... |
||
1493 | * All Orders will have a Shipping and Billing address attached to it. |
||
1494 | * Method used to retrieve object e.g. for $order->BillingAddress(); "BillingAddress" is the method name you can use. |
||
1495 | * If the method name is the same as the class name then dont worry about providing one. |
||
1496 | * |
||
1497 | * @param string $className - ClassName of the Address (e.g. BillingAddress or ShippingAddress) |
||
1498 | * @param string $alternativeMethodName - method to retrieve Address |
||
1499 | **/ |
||
1500 | public function CreateOrReturnExistingAddress($className = 'BillingAddress', $alternativeMethodName = '') |
||
1544 | |||
1545 | /** |
||
1546 | * Sets the country in the billing and shipping address. |
||
1547 | * |
||
1548 | * @param string $countryCode - code for the country e.g. NZ |
||
1549 | * @param bool $includeBillingAddress |
||
1550 | * @param bool $includeShippingAddress |
||
1551 | **/ |
||
1552 | public function SetCountryFields($countryCode, $includeBillingAddress = true, $includeShippingAddress = true) |
||
1571 | |||
1572 | /** |
||
1573 | * Sets the region in the billing and shipping address. |
||
1574 | * |
||
1575 | * @param int $regionID - ID for the region to be set |
||
1576 | **/ |
||
1577 | public function SetRegionFields($regionID) |
||
1592 | |||
1593 | /** |
||
1594 | * Stores the preferred currency of the order. |
||
1595 | * IMPORTANTLY we store the exchange rate for future reference... |
||
1596 | * |
||
1597 | * @param EcommerceCurrency $currency |
||
1598 | */ |
||
1599 | public function UpdateCurrency($newCurrency) |
||
1612 | |||
1613 | /** |
||
1614 | * alias for UpdateCurrency. |
||
1615 | * |
||
1616 | * @param EcommerceCurrency $currency |
||
1617 | */ |
||
1618 | public function SetCurrency($currency) |
||
1622 | |||
1623 | /******************************************************* |
||
1624 | * 5. CUSTOMER COMMUNICATION |
||
1625 | *******************************************************/ |
||
1626 | |||
1627 | /** |
||
1628 | * Send the invoice of the order by email. |
||
1629 | * |
||
1630 | * @param string $emailClassName (optional) class used to send email |
||
1631 | * @param string $subject (optional) subject for the email |
||
1632 | * @param string $message (optional) the main message in the email |
||
1633 | * @param bool $resend (optional) send the email even if it has been sent before |
||
1634 | * @param bool $adminOnlyOrToEmail (optional) sends the email to the ADMIN ONLY, if you provide an email, it will go to the email... |
||
1635 | * |
||
1636 | * @return bool TRUE on success, FALSE on failure |
||
1637 | */ |
||
1638 | public function sendEmail( |
||
1653 | |||
1654 | /** |
||
1655 | * Sends a message to the shop admin ONLY and not to the customer |
||
1656 | * This can be used by ordersteps and orderlogs to notify the admin of any potential problems. |
||
1657 | * |
||
1658 | * @param string $emailClassName - (optional) template to be used ... |
||
1659 | * @param string $subject - (optional) subject for the email |
||
1660 | * @param string $message - (optional) message to be added with the email |
||
1661 | * @param bool $resend - (optional) can it be sent twice? |
||
1662 | * @param bool | string $adminOnlyOrToEmail - (optional) sends the email to the ADMIN ONLY, if you provide an email, it will go to the email... |
||
1663 | * |
||
1664 | * @return bool TRUE for success, FALSE for failure (not tested) |
||
1665 | */ |
||
1666 | public function sendAdminNotification( |
||
1681 | |||
1682 | /** |
||
1683 | * returns the order formatted as an email. |
||
1684 | * |
||
1685 | * @param string $emailClassName - template to use. |
||
1686 | * @param string $subject - (optional) the subject (which can be used as title in email) |
||
1687 | * @param string $message - (optional) the additional message |
||
1688 | * |
||
1689 | * @return string (html) |
||
1690 | */ |
||
1691 | public function renderOrderInEmailFormat( |
||
1705 | |||
1706 | /** |
||
1707 | * Send a mail of the order to the client (and another to the admin). |
||
1708 | * |
||
1709 | * @param string $emailClassName - (optional) template to be used ... |
||
1710 | * @param string $subject - (optional) subject for the email |
||
1711 | * @param string $message - (optional) message to be added with the email |
||
1712 | * @param bool $resend - (optional) can it be sent twice? |
||
1713 | * @param bool | string $adminOnlyOrToEmail - (optional) sends the email to the ADMIN ONLY, if you provide an email, it will go to the email... |
||
1714 | * |
||
1715 | * @return bool TRUE for success, FALSE for failure (not tested) |
||
1716 | */ |
||
1717 | protected function prepareAndSendEmail( |
||
1774 | |||
1775 | /** |
||
1776 | * returns the Data that can be used in the body of an order Email |
||
1777 | * we add the subject here so that the subject, for example, can be added to the <title> |
||
1778 | * of the email template. |
||
1779 | * we add the subject here so that the subject, for example, can be added to the <title> |
||
1780 | * of the email template. |
||
1781 | * |
||
1782 | * @param string $subject - (optional) subject for email |
||
1783 | * @param string $message - (optional) the additional message |
||
1784 | * |
||
1785 | * @return ArrayData |
||
1786 | * - Subject - EmailSubject |
||
1787 | * - Message - specific message for this order |
||
1788 | * - Message - custom message |
||
1789 | * - OrderStepMessage - generic message for step |
||
1790 | * - Order |
||
1791 | * - EmailLogo |
||
1792 | * - ShopPhysicalAddress |
||
1793 | * - CurrentDateAndTime |
||
1794 | * - BaseURL |
||
1795 | * - CC |
||
1796 | * - BCC |
||
1797 | */ |
||
1798 | protected function createReplacementArrayForEmail($subject = '', $message = '') |
||
1827 | |||
1828 | /******************************************************* |
||
1829 | * 6. ITEM MANAGEMENT |
||
1830 | *******************************************************/ |
||
1831 | |||
1832 | /** |
||
1833 | * returns a list of Order Attributes by type. |
||
1834 | * |
||
1835 | * @param array | String $types |
||
1836 | * |
||
1837 | * @return ArrayList |
||
1838 | */ |
||
1839 | public function getOrderAttributesByType($types) |
||
1863 | |||
1864 | /** |
||
1865 | * Returns the items of the order. |
||
1866 | * Items are the order items (products) and NOT the modifiers (discount, tax, etc...). |
||
1867 | * |
||
1868 | * N. B. this method returns Order Items |
||
1869 | * also see Buaybles |
||
1870 | |||
1871 | * |
||
1872 | * @param string filter - where statement to exclude certain items OR ClassName (e.g. 'TaxModifier') |
||
1873 | * |
||
1874 | * @return DataList (OrderItems) |
||
1875 | */ |
||
1876 | public function Items($filterOrClassName = '') |
||
1884 | |||
1885 | /** |
||
1886 | * @alias function of Items |
||
1887 | * |
||
1888 | * N. B. this method returns Order Items |
||
1889 | * also see Buaybles |
||
1890 | * |
||
1891 | * @param string filter - where statement to exclude certain items. |
||
1892 | * @alias for Items |
||
1893 | * @return DataList (OrderItems) |
||
1894 | */ |
||
1895 | public function OrderItems($filterOrClassName = '') |
||
1899 | |||
1900 | /** |
||
1901 | * returns the buyables asscoiated with the order items. |
||
1902 | * |
||
1903 | * NB. this method retursn buyables |
||
1904 | * |
||
1905 | * @param string filter - where statement to exclude certain items. |
||
1906 | * |
||
1907 | * @return ArrayList (Buyables) |
||
1908 | */ |
||
1909 | public function Buyables($filterOrClassName = '') |
||
1919 | |||
1920 | /** |
||
1921 | * Return all the {@link OrderItem} instances that are |
||
1922 | * available as records in the database. |
||
1923 | * |
||
1924 | * @param string filter - where statement to exclude certain items, |
||
1925 | * 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) |
||
1926 | * |
||
1927 | * @return DataList (OrderItems) |
||
1928 | */ |
||
1929 | protected function itemsFromDatabase($filterOrClassName = '') |
||
1943 | |||
1944 | /** |
||
1945 | * @alias for Modifiers |
||
1946 | * |
||
1947 | * @return DataList (OrderModifiers) |
||
1948 | */ |
||
1949 | public function OrderModifiers() |
||
1953 | |||
1954 | /** |
||
1955 | * Returns the modifiers of the order, if it hasn't been saved yet |
||
1956 | * it returns the modifiers from session, if it has, it returns them |
||
1957 | * from the DB entry. ONLY USE OUTSIDE ORDER. |
||
1958 | * |
||
1959 | * @param string filter - where statement to exclude certain items OR ClassName (e.g. 'TaxModifier') |
||
1960 | * |
||
1961 | * @return DataList (OrderModifiers) |
||
1962 | */ |
||
1963 | public function Modifiers($filterOrClassName = '') |
||
1967 | |||
1968 | /** |
||
1969 | * Get all {@link OrderModifier} instances that are |
||
1970 | * available as records in the database. |
||
1971 | * NOTE: includes REMOVED Modifiers, so that they do not get added again... |
||
1972 | * |
||
1973 | * @param string filter - where statement to exclude certain items OR ClassName (e.g. 'TaxModifier') |
||
1974 | * |
||
1975 | * @return DataList (OrderModifiers) |
||
1976 | */ |
||
1977 | protected function modifiersFromDatabase($filterOrClassName = '') |
||
1991 | |||
1992 | /** |
||
1993 | * Calculates and updates all the order attributes. |
||
1994 | * |
||
1995 | * @param bool $recalculate - run it, even if it has run already |
||
1996 | */ |
||
1997 | public function calculateOrderAttributes($recalculate = false) |
||
2011 | |||
2012 | /** |
||
2013 | * Calculates and updates all the product items. |
||
2014 | * |
||
2015 | * @param bool $recalculate - run it, even if it has run already |
||
2016 | */ |
||
2017 | protected function calculateOrderItems($recalculate = false) |
||
2032 | |||
2033 | /** |
||
2034 | * Calculates and updates all the modifiers. |
||
2035 | * |
||
2036 | * @param bool $recalculate - run it, even if it has run already |
||
2037 | */ |
||
2038 | protected function calculateModifiers($recalculate = false) |
||
2050 | |||
2051 | /** |
||
2052 | * Returns the subtotal of the modifiers for this order. |
||
2053 | * If a modifier appears in the excludedModifiers array, it is not counted. |
||
2054 | * |
||
2055 | * @param string|array $excluded - Class(es) of modifier(s) to ignore in the calculation. |
||
2056 | * @param bool $stopAtExcludedModifier - when this flag is TRUE, we stop adding the modifiers when we reach an excluded modifier. |
||
2057 | * |
||
2058 | * @return float |
||
2059 | */ |
||
2060 | public function ModifiersSubTotal($excluded = null, $stopAtExcludedModifier = false) |
||
2087 | |||
2088 | /** |
||
2089 | * returns a modifier that is an instanceof the classname |
||
2090 | * it extends. |
||
2091 | * |
||
2092 | * @param string $className: class name for the modifier |
||
2093 | * |
||
2094 | * @return DataObject (OrderModifier) |
||
2095 | **/ |
||
2096 | public function RetrieveModifier($className) |
||
2107 | |||
2108 | /******************************************************* |
||
2109 | * 7. CRUD METHODS (e.g. canView, canEdit, canDelete, etc...) |
||
2110 | *******************************************************/ |
||
2111 | |||
2112 | /** |
||
2113 | * @param Member $member |
||
2114 | * |
||
2115 | * @return DataObject (Member) |
||
2116 | **/ |
||
2117 | //TODO: please comment why we make use of this function |
||
2118 | protected function getMemberForCanFunctions(Member $member = null) |
||
2130 | |||
2131 | /** |
||
2132 | * @param Member $member |
||
2133 | * |
||
2134 | * @return bool |
||
2135 | **/ |
||
2136 | public function canCreate($member = null) |
||
2147 | |||
2148 | /** |
||
2149 | * Standard SS method - can the current member view this order? |
||
2150 | * |
||
2151 | * @param Member $member |
||
2152 | * |
||
2153 | * @return bool |
||
2154 | **/ |
||
2155 | public function canView($member = null) |
||
2200 | |||
2201 | /** |
||
2202 | * @param Member $member optional |
||
2203 | * @return bool |
||
2204 | */ |
||
2205 | public function canOverrideCanView($member = null) |
||
2226 | |||
2227 | /** |
||
2228 | * @return bool |
||
2229 | */ |
||
2230 | public function IsInSession() |
||
2236 | |||
2237 | /** |
||
2238 | * returns a pseudo random part of the session id. |
||
2239 | * |
||
2240 | * @param int $size |
||
2241 | * |
||
2242 | * @return string |
||
2243 | */ |
||
2244 | public function LessSecureSessionID($size = 7, $start = null) |
||
2252 | /** |
||
2253 | * |
||
2254 | * @param Member (optional) $member |
||
2255 | * |
||
2256 | * @return bool |
||
2257 | **/ |
||
2258 | public function canViewAdminStuff($member = null) |
||
2269 | |||
2270 | /** |
||
2271 | * if we set canEdit to false then we |
||
2272 | * can not see the child records |
||
2273 | * Basically, you can edit when you can view and canEdit (even as a customer) |
||
2274 | * Or if you are a Shop Admin you can always edit. |
||
2275 | * Otherwise it is false... |
||
2276 | * |
||
2277 | * @param Member $member |
||
2278 | * |
||
2279 | * @return bool |
||
2280 | **/ |
||
2281 | public function canEdit($member = null) |
||
2300 | |||
2301 | /** |
||
2302 | * is the order ready to go through to the |
||
2303 | * checkout process. |
||
2304 | * |
||
2305 | * This method checks all the order items and order modifiers |
||
2306 | * If any of them need immediate attention then this is done |
||
2307 | * first after which it will go through to the checkout page. |
||
2308 | * |
||
2309 | * @param Member (optional) $member |
||
2310 | * |
||
2311 | * @return bool |
||
2312 | **/ |
||
2313 | public function canCheckout(Member $member = null) |
||
2327 | |||
2328 | /** |
||
2329 | * Can the order be submitted? |
||
2330 | * this method can be used to stop an order from being submitted |
||
2331 | * due to something not being completed or done. |
||
2332 | * |
||
2333 | * @see Order::SubmitErrors |
||
2334 | * |
||
2335 | * @param Member $member |
||
2336 | * |
||
2337 | * @return bool |
||
2338 | **/ |
||
2339 | public function canSubmit(Member $member = null) |
||
2356 | |||
2357 | /** |
||
2358 | * Can a payment be made for this Order? |
||
2359 | * |
||
2360 | * @param Member $member |
||
2361 | * |
||
2362 | * @return bool |
||
2363 | **/ |
||
2364 | public function canPay(Member $member = null) |
||
2377 | |||
2378 | /** |
||
2379 | * Can the given member cancel this order? |
||
2380 | * |
||
2381 | * @param Member $member |
||
2382 | * |
||
2383 | * @return bool |
||
2384 | **/ |
||
2385 | public function canCancel(Member $member = null) |
||
2402 | |||
2403 | /** |
||
2404 | * @param Member $member |
||
2405 | * |
||
2406 | * @return bool |
||
2407 | **/ |
||
2408 | public function canDelete($member = null) |
||
2424 | |||
2425 | /** |
||
2426 | * Returns all the order logs that the current member can view |
||
2427 | * i.e. some order logs can only be viewed by the admin (e.g. suspected fraud orderlog). |
||
2428 | * |
||
2429 | * @return ArrayList (OrderStatusLogs) |
||
2430 | **/ |
||
2431 | public function CanViewOrderStatusLogs() |
||
2443 | |||
2444 | /** |
||
2445 | * returns all the logs that can be viewed by the customer. |
||
2446 | * |
||
2447 | * @return ArrayList (OrderStausLogs) |
||
2448 | */ |
||
2449 | public function CustomerViewableOrderStatusLogs() |
||
2463 | |||
2464 | /******************************************************* |
||
2465 | * 8. GET METHODS (e.g. Total, SubTotal, Title, etc...) |
||
2466 | *******************************************************/ |
||
2467 | |||
2468 | /** |
||
2469 | * returns the email to be used for customer communication. |
||
2470 | * |
||
2471 | * @return string |
||
2472 | */ |
||
2473 | public function OrderEmail() |
||
2495 | |||
2496 | /** |
||
2497 | * Returns true if there is a prink or email link. |
||
2498 | * |
||
2499 | * @return bool |
||
2500 | */ |
||
2501 | public function HasPrintOrEmailLink() |
||
2505 | |||
2506 | /** |
||
2507 | * returns the absolute link to the order that can be used in the customer communication (email). |
||
2508 | * |
||
2509 | * @return string |
||
2510 | */ |
||
2511 | public function EmailLink($type = 'Order_StatusEmail') |
||
2523 | |||
2524 | /** |
||
2525 | * returns the absolute link to the order for printing. |
||
2526 | * |
||
2527 | * @return string |
||
2528 | */ |
||
2529 | public function PrintLink() |
||
2541 | |||
2542 | /** |
||
2543 | * returns the absolute link to the order for printing. |
||
2544 | * |
||
2545 | * @return string |
||
2546 | */ |
||
2547 | public function PackingSlipLink() |
||
2557 | |||
2558 | /** |
||
2559 | * returns the absolute link that the customer can use to retrieve the email WITHOUT logging in. |
||
2560 | * |
||
2561 | * @return string |
||
2562 | */ |
||
2563 | public function RetrieveLink() |
||
2567 | |||
2568 | public function getRetrieveLink() |
||
2582 | |||
2583 | public function ShareLink() |
||
2587 | |||
2588 | public function getShareLink() |
||
2606 | |||
2607 | /** |
||
2608 | * link to delete order. |
||
2609 | * |
||
2610 | * @return string |
||
2611 | */ |
||
2612 | public function DeleteLink() |
||
2624 | |||
2625 | /** |
||
2626 | * link to copy order. |
||
2627 | * |
||
2628 | * @return string |
||
2629 | */ |
||
2630 | public function CopyOrderLink() |
||
2642 | |||
2643 | /** |
||
2644 | * A "Title" for the order, which summarises the main details (date, and customer) in a string. |
||
2645 | * |
||
2646 | * @param string $dateFormat - e.g. "D j M Y, G:i T" |
||
2647 | * @param bool $includeName - e.g. by Mr Johnson |
||
2648 | * |
||
2649 | * @return string |
||
2650 | **/ |
||
2651 | public function Title($dateFormat = null, $includeName = false) |
||
2714 | |||
2715 | /** |
||
2716 | * Returns the subtotal of the items for this order. |
||
2717 | * |
||
2718 | * @return float |
||
2719 | */ |
||
2720 | public function SubTotal() |
||
2738 | |||
2739 | /** |
||
2740 | * @return Currency (DB Object) |
||
2741 | **/ |
||
2742 | public function SubTotalAsCurrencyObject() |
||
2746 | |||
2747 | /** |
||
2748 | * @return Money |
||
2749 | **/ |
||
2750 | public function SubTotalAsMoney() |
||
2758 | |||
2759 | /** |
||
2760 | * @param string|array $excluded - Class(es) of modifier(s) to ignore in the calculation. |
||
2761 | * @param bool $stopAtExcludedModifier - when this flag is TRUE, we stop adding the modifiers when we reach an excluded modifier. |
||
2762 | * |
||
2763 | * @return Currency (DB Object) |
||
2764 | **/ |
||
2765 | public function ModifiersSubTotalAsCurrencyObject($excluded = null, $stopAtExcludedModifier = false) |
||
2769 | |||
2770 | /** |
||
2771 | * @param string|array $excluded - Class(es) of modifier(s) to ignore in the calculation. |
||
2772 | * @param bool $stopAtExcludedModifier - when this flag is TRUE, we stop adding the modifiers when we reach an excluded modifier. |
||
2773 | * |
||
2774 | * @return Money (DB Object) |
||
2775 | **/ |
||
2776 | public function ModifiersSubTotalAsMoneyObject($excluded = null, $stopAtExcludedModifier = false) |
||
2780 | |||
2781 | /** |
||
2782 | * Returns the total cost of an order including the additional charges or deductions of its modifiers. |
||
2783 | * |
||
2784 | * @return float |
||
2785 | */ |
||
2786 | public function Total() |
||
2794 | |||
2795 | /** |
||
2796 | * @return Currency (DB Object) |
||
2797 | **/ |
||
2798 | public function TotalAsCurrencyObject() |
||
2802 | |||
2803 | /** |
||
2804 | * @return Money |
||
2805 | **/ |
||
2806 | public function TotalAsMoney() |
||
2814 | |||
2815 | /** |
||
2816 | * Checks to see if any payments have been made on this order |
||
2817 | * and if so, subracts the payment amount from the order. |
||
2818 | * |
||
2819 | * @return float |
||
2820 | **/ |
||
2821 | public function TotalOutstanding() |
||
2841 | |||
2842 | /** |
||
2843 | * @return Currency (DB Object) |
||
2844 | **/ |
||
2845 | public function TotalOutstandingAsCurrencyObject() |
||
2849 | |||
2850 | /** |
||
2851 | * @return Money |
||
2852 | **/ |
||
2853 | public function TotalOutstandingAsMoney() |
||
2861 | |||
2862 | /** |
||
2863 | * @return float |
||
2864 | */ |
||
2865 | public function TotalPaid() |
||
2886 | |||
2887 | /** |
||
2888 | * @return Currency (DB Object) |
||
2889 | **/ |
||
2890 | public function TotalPaidAsCurrencyObject() |
||
2894 | |||
2895 | /** |
||
2896 | * @return Money |
||
2897 | **/ |
||
2898 | public function TotalPaidAsMoney() |
||
2906 | |||
2907 | /** |
||
2908 | * returns the total number of OrderItems (not modifiers). |
||
2909 | * This is meant to run as fast as possible to quickly check |
||
2910 | * if there is anything in the cart. |
||
2911 | * |
||
2912 | * @param bool $recalculate - do we need to recalculate (value is retained during lifetime of Object) |
||
2913 | * |
||
2914 | * @return int |
||
2915 | **/ |
||
2916 | public function TotalItems($recalculate = false) |
||
2930 | |||
2931 | /** |
||
2932 | * Little shorthand. |
||
2933 | * |
||
2934 | * @param bool $recalculate |
||
2935 | * |
||
2936 | * @return bool |
||
2937 | **/ |
||
2938 | public function MoreThanOneItemInCart($recalculate = false) |
||
2942 | |||
2943 | /** |
||
2944 | * returns the total number of OrderItems (not modifiers) times their respectective quantities. |
||
2945 | * |
||
2946 | * @param bool $recalculate - force recalculation |
||
2947 | * |
||
2948 | * @return float |
||
2949 | **/ |
||
2950 | public function TotalItemsTimesQuantity($recalculate = false) |
||
2970 | |||
2971 | /** |
||
2972 | * |
||
2973 | * @return string (country code) |
||
2974 | **/ |
||
2975 | public function Country() |
||
2979 | |||
2980 | /** |
||
2981 | * Returns the country code for the country that applies to the order. |
||
2982 | * @alias for getCountry |
||
2983 | * |
||
2984 | * @return string - country code e.g. NZ |
||
2985 | */ |
||
2986 | public function getCountry() |
||
3023 | |||
3024 | /** |
||
3025 | * @alias for getFullNameCountry |
||
3026 | * |
||
3027 | * @return string - country name |
||
3028 | **/ |
||
3029 | public function FullNameCountry() |
||
3033 | |||
3034 | /** |
||
3035 | * returns name of coutry. |
||
3036 | * |
||
3037 | * @return string - country name |
||
3038 | **/ |
||
3039 | public function getFullNameCountry() |
||
3043 | |||
3044 | /** |
||
3045 | * @alis for getExpectedCountryName |
||
3046 | * @return string - country name |
||
3047 | **/ |
||
3048 | public function ExpectedCountryName() |
||
3052 | |||
3053 | /** |
||
3054 | * returns name of coutry that we expect the customer to have |
||
3055 | * This takes into consideration more than just what has been entered |
||
3056 | * for example, it looks at GEO IP. |
||
3057 | * |
||
3058 | * @todo: why do we dont return a string IF there is only one item. |
||
3059 | * |
||
3060 | * @return string - country name |
||
3061 | **/ |
||
3062 | public function getExpectedCountryName() |
||
3066 | |||
3067 | /** |
||
3068 | * return the title of the fixed country (if any). |
||
3069 | * |
||
3070 | * @return string | empty string |
||
3071 | **/ |
||
3072 | public function FixedCountry() |
||
3085 | |||
3086 | /** |
||
3087 | * Returns the region that applies to the order. |
||
3088 | * we check both billing and shipping, in case one of them is empty. |
||
3089 | * |
||
3090 | * @return DataObject | Null (EcommerceRegion) |
||
3091 | **/ |
||
3092 | public function Region() |
||
3129 | |||
3130 | /** |
||
3131 | * Casted variable |
||
3132 | * Currency is not the same as the standard one? |
||
3133 | * |
||
3134 | * @return bool |
||
3135 | **/ |
||
3136 | public function HasAlternativeCurrency() |
||
3152 | |||
3153 | /** |
||
3154 | * Makes sure exchange rate is updated and maintained before order is submitted |
||
3155 | * This method is public because it could be called from a shopping Cart Object. |
||
3156 | **/ |
||
3157 | public function EnsureCorrectExchangeRate() |
||
3175 | |||
3176 | /** |
||
3177 | * speeds up processing by storing the IsSubmitted value |
||
3178 | * we start with -1 to know if it has been requested before. |
||
3179 | * |
||
3180 | * @var bool |
||
3181 | */ |
||
3182 | protected $_isSubmittedTempVar = -1; |
||
3183 | |||
3184 | /** |
||
3185 | * Casted variable - has the order been submitted? |
||
3186 | * alias |
||
3187 | * @param bool $recalculate |
||
3188 | * |
||
3189 | * @return bool |
||
3190 | **/ |
||
3191 | public function IsSubmitted($recalculate = true) |
||
3195 | |||
3196 | /** |
||
3197 | * Casted variable - has the order been submitted? |
||
3198 | * |
||
3199 | * @param bool $recalculate |
||
3200 | * |
||
3201 | * @return bool |
||
3202 | **/ |
||
3203 | public function getIsSubmitted($recalculate = false) |
||
3215 | |||
3216 | /** |
||
3217 | * |
||
3218 | * |
||
3219 | * @return bool |
||
3220 | */ |
||
3221 | public function IsArchived() |
||
3231 | |||
3232 | /** |
||
3233 | * Submission Log for this Order (if any). |
||
3234 | * |
||
3235 | * @return Submission Log (OrderStatusLog_Submitted) | Null |
||
3236 | **/ |
||
3237 | public function SubmissionLog() |
||
3245 | |||
3246 | /** |
||
3247 | * @return int |
||
3248 | */ |
||
3249 | public function SecondsSinceBeingSubmitted() |
||
3257 | |||
3258 | /** |
||
3259 | * if the order can not be submitted, |
||
3260 | * then the reasons why it can not be submitted |
||
3261 | * will be returned by this method. |
||
3262 | * |
||
3263 | * @see Order::canSubmit |
||
3264 | * |
||
3265 | * @return ArrayList | null |
||
3266 | */ |
||
3267 | public function SubmitErrors() |
||
3283 | |||
3284 | /** |
||
3285 | * Casted variable - has the order been submitted? |
||
3286 | * |
||
3287 | * @param bool $withDetail |
||
3288 | * |
||
3289 | * @return string |
||
3290 | **/ |
||
3291 | public function CustomerStatus($withDetail = true) |
||
3313 | |||
3314 | /** |
||
3315 | * Casted variable - does the order have a potential shipping address? |
||
3316 | * |
||
3317 | * @return bool |
||
3318 | **/ |
||
3319 | public function CanHaveShippingAddress() |
||
3327 | |||
3328 | /** |
||
3329 | * returns the link to view the Order |
||
3330 | * WHY NOT CHECKOUT PAGE: first we check for cart page. |
||
3331 | * |
||
3332 | * @return CartPage | Null |
||
3333 | */ |
||
3334 | public function DisplayPage() |
||
3351 | |||
3352 | /** |
||
3353 | * returns the link to view the Order |
||
3354 | * WHY NOT CHECKOUT PAGE: first we check for cart page. |
||
3355 | * If a cart page has been created then we refer through to Cart Page. |
||
3356 | * Otherwise it will default to the checkout page. |
||
3357 | * |
||
3358 | * @param string $action - any action that should be added to the link. |
||
3359 | * |
||
3360 | * @return String(URLSegment) |
||
3361 | */ |
||
3362 | public function Link($action = null) |
||
3377 | |||
3378 | /** |
||
3379 | * Returns to link to access the Order's API. |
||
3380 | * |
||
3381 | * @param string $version |
||
3382 | * @param string $extension |
||
3383 | * |
||
3384 | * @return String(URL) |
||
3385 | */ |
||
3386 | public function APILink($version = 'v1', $extension = 'xml') |
||
3390 | |||
3391 | /** |
||
3392 | * returns the link to finalise the Order. |
||
3393 | * |
||
3394 | * @return String(URLSegment) |
||
3395 | */ |
||
3396 | public function CheckoutLink() |
||
3410 | |||
3411 | /** |
||
3412 | * Converts the Order into HTML, based on the Order Template. |
||
3413 | * |
||
3414 | * @return HTML Object |
||
3415 | **/ |
||
3416 | public function ConvertToHTML() |
||
3426 | |||
3427 | /** |
||
3428 | * Converts the Order into a serialized string |
||
3429 | * TO DO: check if this works and check if we need to use special sapphire serialization code. |
||
3430 | * |
||
3431 | * @return string - serialized object |
||
3432 | **/ |
||
3433 | public function ConvertToString() |
||
3437 | |||
3438 | /** |
||
3439 | * Converts the Order into a JSON object |
||
3440 | * TO DO: check if this works and check if we need to use special sapphire JSON code. |
||
3441 | * |
||
3442 | * @return string - JSON |
||
3443 | **/ |
||
3444 | public function ConvertToJSON() |
||
3448 | |||
3449 | /** |
||
3450 | * returns itself wtih more data added as variables. |
||
3451 | * We add has_one and has_many as variables like this: $this->MyHasOne_serialized = serialize($this->MyHasOne()). |
||
3452 | * |
||
3453 | * @return Order - with most important has one and has many items included as variables. |
||
3454 | **/ |
||
3455 | protected function addHasOneAndHasManyAsVariables() |
||
3468 | |||
3469 | /******************************************************* |
||
3470 | * 9. TEMPLATE RELATED STUFF |
||
3471 | *******************************************************/ |
||
3472 | |||
3473 | /** |
||
3474 | * returns the instance of EcommerceConfigAjax for use in templates. |
||
3475 | * In templates, it is used like this: |
||
3476 | * $EcommerceConfigAjax.TableID. |
||
3477 | * |
||
3478 | * @return EcommerceConfigAjax |
||
3479 | **/ |
||
3480 | public function AJAXDefinitions() |
||
3484 | |||
3485 | /** |
||
3486 | * returns the instance of EcommerceDBConfig. |
||
3487 | * |
||
3488 | * @return EcommerceDBConfig |
||
3489 | **/ |
||
3490 | public function EcomConfig() |
||
3494 | |||
3495 | /** |
||
3496 | * Collects the JSON data for an ajax return of the cart. |
||
3497 | * |
||
3498 | * @param array $js |
||
3499 | * |
||
3500 | * @return array (for use in AJAX for JSON) |
||
3501 | **/ |
||
3502 | public function updateForAjax(array $js) |
||
3555 | |||
3556 | /** |
||
3557 | * @ToDO: move to more appropriate class |
||
3558 | * |
||
3559 | * @return float |
||
3560 | **/ |
||
3561 | public function SubTotalCartValue() |
||
3565 | |||
3566 | /******************************************************* |
||
3567 | * 10. STANDARD SS METHODS (requireDefaultRecords, onBeforeDelete, etc...) |
||
3568 | *******************************************************/ |
||
3569 | |||
3570 | /** |
||
3571 | *standard SS method. |
||
3572 | **/ |
||
3573 | public function populateDefaults() |
||
3577 | |||
3578 | public function onBeforeWrite() |
||
3593 | |||
3594 | /** |
||
3595 | * standard SS method |
||
3596 | * adds the ability to update order after writing it. |
||
3597 | **/ |
||
3598 | public function onAfterWrite() |
||
3622 | |||
3623 | /** |
||
3624 | *standard SS method. |
||
3625 | * |
||
3626 | * delete attributes, statuslogs, and payments |
||
3627 | * THIS SHOULD NOT BE USED AS ORDERS SHOULD BE CANCELLED NOT DELETED |
||
3628 | */ |
||
3629 | public function onBeforeDelete() |
||
3674 | |||
3675 | /******************************************************* |
||
3676 | * 11. DEBUG |
||
3677 | *******************************************************/ |
||
3678 | |||
3679 | /** |
||
3680 | * Debug helper method. |
||
3681 | * Can be called from /shoppingcart/debug/. |
||
3682 | * |
||
3683 | * @return string |
||
3684 | */ |
||
3685 | public function debug() |
||
3691 | } |
||
3692 |
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.