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' => 'Varchar',  | 
            ||
| 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 | * @return null  | 
            ||
| 1126 | **/  | 
            ||
| 1127 | public function tryToFinaliseOrder($runAgain = false, $fromOrderQueue = false)  | 
            ||
| 1182 | |||
| 1183 | /**  | 
            ||
| 1184 | * Goes through the order steps and tries to "apply" the next step  | 
            ||
| 1185 | * Step is updated after the other one is completed...  | 
            ||
| 1186 | *  | 
            ||
| 1187 | * @return int (StatusID or false if the next status can not be "applied")  | 
            ||
| 1188 | **/  | 
            ||
| 1189 | public function doNextStatus()  | 
            ||
| 1204 | |||
| 1205 | /**  | 
            ||
| 1206 | * cancel an order.  | 
            ||
| 1207 | *  | 
            ||
| 1208 | * @param Member $member - (optional) the user cancelling the order  | 
            ||
| 1209 | * @param string $reason - (optional) the reason the order is cancelled  | 
            ||
| 1210 | *  | 
            ||
| 1211 | * @return OrderStatusLog_Cancel  | 
            ||
| 1212 | */  | 
            ||
| 1213 | public function Cancel($member = null, $reason = '')  | 
            ||
| 1246 | |||
| 1247 | /**  | 
            ||
| 1248 | * returns true if successful.  | 
            ||
| 1249 | *  | 
            ||
| 1250 | * @param bool $avoidWrites  | 
            ||
| 1251 | *  | 
            ||
| 1252 | * @return bool  | 
            ||
| 1253 | */  | 
            ||
| 1254 | public function Archive($avoidWrites = true)  | 
            ||
| 1277 | |||
| 1278 | /*******************************************************  | 
            ||
| 1279 | * 3. STATUS RELATED FUNCTIONS / SHORTCUTS  | 
            ||
| 1280 | *******************************************************/  | 
            ||
| 1281 | |||
| 1282 | /**  | 
            ||
| 1283 | * Avoids caching of $this->Status().  | 
            ||
| 1284 | *  | 
            ||
| 1285 | * @return DataObject (current OrderStep)  | 
            ||
| 1286 | */  | 
            ||
| 1287 | public function MyStep()  | 
            ||
| 1309 | |||
| 1310 | /**  | 
            ||
| 1311 | * Return the OrderStatusLog that is relevant to the Order status.  | 
            ||
| 1312 | *  | 
            ||
| 1313 | * @return OrderStatusLog  | 
            ||
| 1314 | */  | 
            ||
| 1315 | public function RelevantLogEntry()  | 
            ||
| 1319 | |||
| 1320 | /**  | 
            ||
| 1321 | * @return OrderStep (current OrderStep that can be seen by customer)  | 
            ||
| 1322 | */  | 
            ||
| 1323 | public function CurrentStepVisibleToCustomer()  | 
            ||
| 1335 | |||
| 1336 | /**  | 
            ||
| 1337 | * works out if the order is still at the first OrderStep.  | 
            ||
| 1338 | *  | 
            ||
| 1339 | * @return bool  | 
            ||
| 1340 | */  | 
            ||
| 1341 | public function IsFirstStep()  | 
            ||
| 1353 | |||
| 1354 | /**  | 
            ||
| 1355 | * Is the order still being "edited" by the customer?  | 
            ||
| 1356 | *  | 
            ||
| 1357 | * @return bool  | 
            ||
| 1358 | */  | 
            ||
| 1359 | public function IsInCart()  | 
            ||
| 1363 | |||
| 1364 | /**  | 
            ||
| 1365 | * The order has "passed" the IsInCart phase.  | 
            ||
| 1366 | *  | 
            ||
| 1367 | * @return bool  | 
            ||
| 1368 | */  | 
            ||
| 1369 | public function IsPastCart()  | 
            ||
| 1373 | |||
| 1374 | /**  | 
            ||
| 1375 | * Are there still steps the order needs to go through?  | 
            ||
| 1376 | *  | 
            ||
| 1377 | * @return bool  | 
            ||
| 1378 | */  | 
            ||
| 1379 | public function IsUncomplete()  | 
            ||
| 1383 | |||
| 1384 | /**  | 
            ||
| 1385 | * Is the order in the :"processing" phaase.?  | 
            ||
| 1386 | *  | 
            ||
| 1387 | * @return bool  | 
            ||
| 1388 | */  | 
            ||
| 1389 | public function IsProcessing()  | 
            ||
| 1393 | |||
| 1394 | /**  | 
            ||
| 1395 | * Is the order completed?  | 
            ||
| 1396 | *  | 
            ||
| 1397 | * @return bool  | 
            ||
| 1398 | */  | 
            ||
| 1399 | public function IsCompleted()  | 
            ||
| 1403 | |||
| 1404 | /**  | 
            ||
| 1405 | * Has the order been paid?  | 
            ||
| 1406 | * TODO: why do we check if there is a total at all?  | 
            ||
| 1407 | *  | 
            ||
| 1408 | * @return bool  | 
            ||
| 1409 | */  | 
            ||
| 1410 | public function IsPaid()  | 
            ||
| 1418 | |||
| 1419 | /**  | 
            ||
| 1420 | * @alias for getIsPaidNice  | 
            ||
| 1421 | * @return string  | 
            ||
| 1422 | */  | 
            ||
| 1423 | public function IsPaidNice()  | 
            ||
| 1424 |     { | 
            ||
| 1425 | return $this->getIsPaidNice();  | 
            ||
| 1426 | }  | 
            ||
| 1427 | |||
| 1428 | |||
| 1429 | public function getIsPaidNice()  | 
            ||
| 1430 |     { | 
            ||
| 1431 | return $this->IsPaid() ? 'yes' : 'no';  | 
            ||
| 1432 | }  | 
            ||
| 1433 | |||
| 1434 | |||
| 1435 | /**  | 
            ||
| 1436 | * Has the order been paid?  | 
            ||
| 1437 | * TODO: why do we check if there is a total at all?  | 
            ||
| 1438 | *  | 
            ||
| 1439 | * @return bool  | 
            ||
| 1440 | */  | 
            ||
| 1441 | public function PaymentIsPending()  | 
            ||
| 1457 | |||
| 1458 | /**  | 
            ||
| 1459 | * shows payments that are meaningfull  | 
            ||
| 1460 | * if the order has been paid then only show successful payments.  | 
            ||
| 1461 | *  | 
            ||
| 1462 | * @return DataList  | 
            ||
| 1463 | */  | 
            ||
| 1464 | public function RelevantPayments()  | 
            ||
| 1474 | |||
| 1475 | |||
| 1476 | /**  | 
            ||
| 1477 | * Has the order been cancelled?  | 
            ||
| 1478 | *  | 
            ||
| 1479 | * @return bool  | 
            ||
| 1480 | */  | 
            ||
| 1481 | public function IsCancelled()  | 
            ||
| 1489 | |||
| 1490 | /**  | 
            ||
| 1491 | * Has the order been cancelled by the customer?  | 
            ||
| 1492 | *  | 
            ||
| 1493 | * @return bool  | 
            ||
| 1494 | */  | 
            ||
| 1495 | public function IsCustomerCancelled()  | 
            ||
| 1503 | |||
| 1504 | /**  | 
            ||
| 1505 | * Has the order been cancelled by the administrator?  | 
            ||
| 1506 | *  | 
            ||
| 1507 | * @return bool  | 
            ||
| 1508 | */  | 
            ||
| 1509 | public function IsAdminCancelled()  | 
            ||
| 1524 | |||
| 1525 | /**  | 
            ||
| 1526 | * Is the Shop Closed for business?  | 
            ||
| 1527 | *  | 
            ||
| 1528 | * @return bool  | 
            ||
| 1529 | */  | 
            ||
| 1530 | public function ShopClosed()  | 
            ||
| 1534 | |||
| 1535 | /*******************************************************  | 
            ||
| 1536 | * 4. LINKING ORDER WITH MEMBER AND ADDRESS  | 
            ||
| 1537 | *******************************************************/  | 
            ||
| 1538 | |||
| 1539 | /**  | 
            ||
| 1540 | * Returns a member linked to the order.  | 
            ||
| 1541 | * If a member is already linked, it will return the existing member.  | 
            ||
| 1542 | * Otherwise it will return a new Member.  | 
            ||
| 1543 | *  | 
            ||
| 1544 | * Any new member is NOT written, because we dont want to create a new member unless we have to!  | 
            ||
| 1545 | * We will not add a member to the order unless a new one is created in the checkout  | 
            ||
| 1546 | * OR the member is logged in / logs in.  | 
            ||
| 1547 | *  | 
            ||
| 1548 | * Also note that if a new member is created, it is not automatically written  | 
            ||
| 1549 | *  | 
            ||
| 1550 | * @param bool $forceCreation - if set to true then the member will always be saved in the database.  | 
            ||
| 1551 | *  | 
            ||
| 1552 | * @return Member  | 
            ||
| 1553 | **/  | 
            ||
| 1554 | public function CreateOrReturnExistingMember($forceCreation = false)  | 
            ||
| 1577 | |||
| 1578 | /**  | 
            ||
| 1579 | * Returns either the existing one or a new Order Address...  | 
            ||
| 1580 | * All Orders will have a Shipping and Billing address attached to it.  | 
            ||
| 1581 | * Method used to retrieve object e.g. for $order->BillingAddress(); "BillingAddress" is the method name you can use.  | 
            ||
| 1582 | * If the method name is the same as the class name then dont worry about providing one.  | 
            ||
| 1583 | *  | 
            ||
| 1584 | * @param string $className - ClassName of the Address (e.g. BillingAddress or ShippingAddress)  | 
            ||
| 1585 | * @param string $alternativeMethodName - method to retrieve Address  | 
            ||
| 1586 | **/  | 
            ||
| 1587 | public function CreateOrReturnExistingAddress($className = 'BillingAddress', $alternativeMethodName = '')  | 
            ||
| 1631 | |||
| 1632 | /**  | 
            ||
| 1633 | * Sets the country in the billing and shipping address.  | 
            ||
| 1634 | *  | 
            ||
| 1635 | * @param string $countryCode - code for the country e.g. NZ  | 
            ||
| 1636 | * @param bool $includeBillingAddress  | 
            ||
| 1637 | * @param bool $includeShippingAddress  | 
            ||
| 1638 | **/  | 
            ||
| 1639 | public function SetCountryFields($countryCode, $includeBillingAddress = true, $includeShippingAddress = true)  | 
            ||
| 1658 | |||
| 1659 | /**  | 
            ||
| 1660 | * Sets the region in the billing and shipping address.  | 
            ||
| 1661 | *  | 
            ||
| 1662 | * @param int $regionID - ID for the region to be set  | 
            ||
| 1663 | **/  | 
            ||
| 1664 | public function SetRegionFields($regionID)  | 
            ||
| 1679 | |||
| 1680 | /**  | 
            ||
| 1681 | * Stores the preferred currency of the order.  | 
            ||
| 1682 | * IMPORTANTLY we store the exchange rate for future reference...  | 
            ||
| 1683 | *  | 
            ||
| 1684 | * @param EcommerceCurrency $currency  | 
            ||
| 1685 | */  | 
            ||
| 1686 | public function UpdateCurrency($newCurrency)  | 
            ||
| 1699 | |||
| 1700 | /**  | 
            ||
| 1701 | * alias for UpdateCurrency.  | 
            ||
| 1702 | *  | 
            ||
| 1703 | * @param EcommerceCurrency $currency  | 
            ||
| 1704 | */  | 
            ||
| 1705 | public function SetCurrency($currency)  | 
            ||
| 1709 | |||
| 1710 | /*******************************************************  | 
            ||
| 1711 | * 5. CUSTOMER COMMUNICATION  | 
            ||
| 1712 | *******************************************************/  | 
            ||
| 1713 | |||
| 1714 | /**  | 
            ||
| 1715 | * Send the invoice of the order by email.  | 
            ||
| 1716 | *  | 
            ||
| 1717 | * @param string $emailClassName (optional) class used to send email  | 
            ||
| 1718 | * @param string $subject (optional) subject for the email  | 
            ||
| 1719 | * @param string $message (optional) the main message in the email  | 
            ||
| 1720 | * @param bool $resend (optional) send the email even if it has been sent before  | 
            ||
| 1721 | * @param bool $adminOnlyOrToEmail (optional) sends the email to the ADMIN ONLY, if you provide an email, it will go to the email...  | 
            ||
| 1722 | *  | 
            ||
| 1723 | * @return bool TRUE on success, FALSE on failure  | 
            ||
| 1724 | */  | 
            ||
| 1725 | public function sendEmail(  | 
            ||
| 1740 | |||
| 1741 | /**  | 
            ||
| 1742 | * Sends a message to the shop admin ONLY and not to the customer  | 
            ||
| 1743 | * This can be used by ordersteps and orderlogs to notify the admin of any potential problems.  | 
            ||
| 1744 | *  | 
            ||
| 1745 | * @param string $emailClassName - (optional) template to be used ...  | 
            ||
| 1746 | * @param string $subject - (optional) subject for the email  | 
            ||
| 1747 | * @param string $message - (optional) message to be added with the email  | 
            ||
| 1748 | * @param bool $resend - (optional) can it be sent twice?  | 
            ||
| 1749 | * @param bool | string $adminOnlyOrToEmail - (optional) sends the email to the ADMIN ONLY, if you provide an email, it will go to the email...  | 
            ||
| 1750 | *  | 
            ||
| 1751 | * @return bool TRUE for success, FALSE for failure (not tested)  | 
            ||
| 1752 | */  | 
            ||
| 1753 | public function sendAdminNotification(  | 
            ||
| 1768 | |||
| 1769 | /**  | 
            ||
| 1770 | * returns the order formatted as an email.  | 
            ||
| 1771 | *  | 
            ||
| 1772 | * @param string $emailClassName - template to use.  | 
            ||
| 1773 | * @param string $subject - (optional) the subject (which can be used as title in email)  | 
            ||
| 1774 | * @param string $message - (optional) the additional message  | 
            ||
| 1775 | *  | 
            ||
| 1776 | * @return string (html)  | 
            ||
| 1777 | */  | 
            ||
| 1778 | public function renderOrderInEmailFormat(  | 
            ||
| 1792 | |||
| 1793 | /**  | 
            ||
| 1794 | * Send a mail of the order to the client (and another to the admin).  | 
            ||
| 1795 | *  | 
            ||
| 1796 | * @param string $emailClassName - (optional) template to be used ...  | 
            ||
| 1797 | * @param string $subject - (optional) subject for the email  | 
            ||
| 1798 | * @param string $message - (optional) message to be added with the email  | 
            ||
| 1799 | * @param bool $resend - (optional) can it be sent twice?  | 
            ||
| 1800 | * @param bool | string $adminOnlyOrToEmail - (optional) sends the email to the ADMIN ONLY, if you provide an email, it will go to the email...  | 
            ||
| 1801 | *  | 
            ||
| 1802 | * @return bool TRUE for success, FALSE for failure (not tested)  | 
            ||
| 1803 | */  | 
            ||
| 1804 | protected function prepareAndSendEmail(  | 
            ||
| 1864 | |||
| 1865 | /**  | 
            ||
| 1866 | * returns the Data that can be used in the body of an order Email  | 
            ||
| 1867 | * we add the subject here so that the subject, for example, can be added to the <title>  | 
            ||
| 1868 | * of the email template.  | 
            ||
| 1869 | * we add the subject here so that the subject, for example, can be added to the <title>  | 
            ||
| 1870 | * of the email template.  | 
            ||
| 1871 | *  | 
            ||
| 1872 | * @param string $subject - (optional) subject for email  | 
            ||
| 1873 | * @param string $message - (optional) the additional message  | 
            ||
| 1874 | *  | 
            ||
| 1875 | * @return ArrayData  | 
            ||
| 1876 | * - Subject - EmailSubject  | 
            ||
| 1877 | * - Message - specific message for this order  | 
            ||
| 1878 | * - Message - custom message  | 
            ||
| 1879 | * - OrderStepMessage - generic message for step  | 
            ||
| 1880 | * - Order  | 
            ||
| 1881 | * - EmailLogo  | 
            ||
| 1882 | * - ShopPhysicalAddress  | 
            ||
| 1883 | * - CurrentDateAndTime  | 
            ||
| 1884 | * - BaseURL  | 
            ||
| 1885 | * - CC  | 
            ||
| 1886 | * - BCC  | 
            ||
| 1887 | */  | 
            ||
| 1888 | protected function createReplacementArrayForEmail($subject = '', $message = '')  | 
            ||
| 1917 | |||
| 1918 | /*******************************************************  | 
            ||
| 1919 | * 6. ITEM MANAGEMENT  | 
            ||
| 1920 | *******************************************************/  | 
            ||
| 1921 | |||
| 1922 | /**  | 
            ||
| 1923 | * returns a list of Order Attributes by type.  | 
            ||
| 1924 | *  | 
            ||
| 1925 | * @param array | String $types  | 
            ||
| 1926 | *  | 
            ||
| 1927 | * @return ArrayList  | 
            ||
| 1928 | */  | 
            ||
| 1929 | public function getOrderAttributesByType($types)  | 
            ||
| 1953 | |||
| 1954 | /**  | 
            ||
| 1955 | * Returns the items of the order.  | 
            ||
| 1956 | * Items are the order items (products) and NOT the modifiers (discount, tax, etc...).  | 
            ||
| 1957 | *  | 
            ||
| 1958 | * N. B. this method returns Order Items  | 
            ||
| 1959 | * also see Buaybles  | 
            ||
| 1960 | |||
| 1961 | *  | 
            ||
| 1962 | * @param string filter - where statement to exclude certain items OR ClassName (e.g. 'TaxModifier')  | 
            ||
| 1963 | *  | 
            ||
| 1964 | * @return DataList (OrderItems)  | 
            ||
| 1965 | */  | 
            ||
| 1966 | public function Items($filterOrClassName = '')  | 
            ||
| 1974 | |||
| 1975 | /**  | 
            ||
| 1976 | * @alias function of Items  | 
            ||
| 1977 | *  | 
            ||
| 1978 | * N. B. this method returns Order Items  | 
            ||
| 1979 | * also see Buaybles  | 
            ||
| 1980 | *  | 
            ||
| 1981 | * @param string filter - where statement to exclude certain items.  | 
            ||
| 1982 | * @alias for Items  | 
            ||
| 1983 | * @return DataList (OrderItems)  | 
            ||
| 1984 | */  | 
            ||
| 1985 | public function OrderItems($filterOrClassName = '')  | 
            ||
| 1989 | |||
| 1990 | /**  | 
            ||
| 1991 | * returns the buyables asscoiated with the order items.  | 
            ||
| 1992 | *  | 
            ||
| 1993 | * NB. this method retursn buyables  | 
            ||
| 1994 | *  | 
            ||
| 1995 | * @param string filter - where statement to exclude certain items.  | 
            ||
| 1996 | *  | 
            ||
| 1997 | * @return ArrayList (Buyables)  | 
            ||
| 1998 | */  | 
            ||
| 1999 | public function Buyables($filterOrClassName = '')  | 
            ||
| 2009 | |||
| 2010 | /**  | 
            ||
| 2011 |      * Return all the {@link OrderItem} instances that are | 
            ||
| 2012 | * available as records in the database.  | 
            ||
| 2013 | *  | 
            ||
| 2014 | * @param string filter - where statement to exclude certain items,  | 
            ||
| 2015 | * 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)  | 
            ||
| 2016 | *  | 
            ||
| 2017 | * @return DataList (OrderItems)  | 
            ||
| 2018 | */  | 
            ||
| 2019 | protected function itemsFromDatabase($filterOrClassName = '')  | 
            ||
| 2033 | |||
| 2034 | /**  | 
            ||
| 2035 | * @alias for Modifiers  | 
            ||
| 2036 | *  | 
            ||
| 2037 | * @return DataList (OrderModifiers)  | 
            ||
| 2038 | */  | 
            ||
| 2039 | public function OrderModifiers()  | 
            ||
| 2043 | |||
| 2044 | /**  | 
            ||
| 2045 | * Returns the modifiers of the order, if it hasn't been saved yet  | 
            ||
| 2046 | * it returns the modifiers from session, if it has, it returns them  | 
            ||
| 2047 | * from the DB entry. ONLY USE OUTSIDE ORDER.  | 
            ||
| 2048 | *  | 
            ||
| 2049 | * @param string filter - where statement to exclude certain items OR ClassName (e.g. 'TaxModifier')  | 
            ||
| 2050 | *  | 
            ||
| 2051 | * @return DataList (OrderModifiers)  | 
            ||
| 2052 | */  | 
            ||
| 2053 | public function Modifiers($filterOrClassName = '')  | 
            ||
| 2057 | |||
| 2058 | /**  | 
            ||
| 2059 |      * Get all {@link OrderModifier} instances that are | 
            ||
| 2060 | * available as records in the database.  | 
            ||
| 2061 | * NOTE: includes REMOVED Modifiers, so that they do not get added again...  | 
            ||
| 2062 | *  | 
            ||
| 2063 | * @param string filter - where statement to exclude certain items OR ClassName (e.g. 'TaxModifier')  | 
            ||
| 2064 | *  | 
            ||
| 2065 | * @return DataList (OrderModifiers)  | 
            ||
| 2066 | */  | 
            ||
| 2067 | protected function modifiersFromDatabase($filterOrClassName = '')  | 
            ||
| 2081 | |||
| 2082 | /**  | 
            ||
| 2083 | * Calculates and updates all the order attributes.  | 
            ||
| 2084 | *  | 
            ||
| 2085 | * @param bool $recalculate - run it, even if it has run already  | 
            ||
| 2086 | */  | 
            ||
| 2087 | public function calculateOrderAttributes($recalculate = false)  | 
            ||
| 2101 | |||
| 2102 | /**  | 
            ||
| 2103 | * Calculates and updates all the product items.  | 
            ||
| 2104 | *  | 
            ||
| 2105 | * @param bool $recalculate - run it, even if it has run already  | 
            ||
| 2106 | */  | 
            ||
| 2107 | protected function calculateOrderItems($recalculate = false)  | 
            ||
| 2122 | |||
| 2123 | /**  | 
            ||
| 2124 | * Calculates and updates all the modifiers.  | 
            ||
| 2125 | *  | 
            ||
| 2126 | * @param bool $recalculate - run it, even if it has run already  | 
            ||
| 2127 | */  | 
            ||
| 2128 | protected function calculateModifiers($recalculate = false)  | 
            ||
| 2140 | |||
| 2141 | /**  | 
            ||
| 2142 | * Returns the subtotal of the modifiers for this order.  | 
            ||
| 2143 | * If a modifier appears in the excludedModifiers array, it is not counted.  | 
            ||
| 2144 | *  | 
            ||
| 2145 | * @param string|array $excluded - Class(es) of modifier(s) to ignore in the calculation.  | 
            ||
| 2146 | * @param bool $stopAtExcludedModifier - when this flag is TRUE, we stop adding the modifiers when we reach an excluded modifier.  | 
            ||
| 2147 | *  | 
            ||
| 2148 | * @return float  | 
            ||
| 2149 | */  | 
            ||
| 2150 | public function ModifiersSubTotal($excluded = null, $stopAtExcludedModifier = false)  | 
            ||
| 2177 | |||
| 2178 | /**  | 
            ||
| 2179 | * returns a modifier that is an instanceof the classname  | 
            ||
| 2180 | * it extends.  | 
            ||
| 2181 | *  | 
            ||
| 2182 | * @param string $className: class name for the modifier  | 
            ||
| 2183 | *  | 
            ||
| 2184 | * @return DataObject (OrderModifier)  | 
            ||
| 2185 | **/  | 
            ||
| 2186 | public function RetrieveModifier($className)  | 
            ||
| 2197 | |||
| 2198 | /*******************************************************  | 
            ||
| 2199 | * 7. CRUD METHODS (e.g. canView, canEdit, canDelete, etc...)  | 
            ||
| 2200 | *******************************************************/  | 
            ||
| 2201 | |||
| 2202 | /**  | 
            ||
| 2203 | * @param Member $member  | 
            ||
| 2204 | *  | 
            ||
| 2205 | * @return DataObject (Member)  | 
            ||
| 2206 | **/  | 
            ||
| 2207 | //TODO: please comment why we make use of this function  | 
            ||
| 2208 | protected function getMemberForCanFunctions(Member $member = null)  | 
            ||
| 2220 | |||
| 2221 | /**  | 
            ||
| 2222 | * @param Member $member  | 
            ||
| 2223 | *  | 
            ||
| 2224 | * @return bool  | 
            ||
| 2225 | **/  | 
            ||
| 2226 | public function canCreate($member = null)  | 
            ||
| 2237 | |||
| 2238 | /**  | 
            ||
| 2239 | * Standard SS method - can the current member view this order?  | 
            ||
| 2240 | *  | 
            ||
| 2241 | * @param Member $member  | 
            ||
| 2242 | *  | 
            ||
| 2243 | * @return bool  | 
            ||
| 2244 | **/  | 
            ||
| 2245 | public function canView($member = null)  | 
            ||
| 2290 | |||
| 2291 | /**  | 
            ||
| 2292 | * @param Member $member optional  | 
            ||
| 2293 | * @return bool  | 
            ||
| 2294 | */  | 
            ||
| 2295 | public function canOverrideCanView($member = null)  | 
            ||
| 2316 | |||
| 2317 | /**  | 
            ||
| 2318 | * @return bool  | 
            ||
| 2319 | */  | 
            ||
| 2320 | public function IsInSession()  | 
            ||
| 2326 | |||
| 2327 | /**  | 
            ||
| 2328 | * returns a pseudo random part of the session id.  | 
            ||
| 2329 | *  | 
            ||
| 2330 | * @param int $size  | 
            ||
| 2331 | *  | 
            ||
| 2332 | * @return string  | 
            ||
| 2333 | */  | 
            ||
| 2334 | public function LessSecureSessionID($size = 7, $start = null)  | 
            ||
| 2342 | /**  | 
            ||
| 2343 | *  | 
            ||
| 2344 | * @param Member (optional) $member  | 
            ||
| 2345 | *  | 
            ||
| 2346 | * @return bool  | 
            ||
| 2347 | **/  | 
            ||
| 2348 | public function canViewAdminStuff($member = null)  | 
            ||
| 2359 | |||
| 2360 | /**  | 
            ||
| 2361 | * if we set canEdit to false then we  | 
            ||
| 2362 | * can not see the child records  | 
            ||
| 2363 | * Basically, you can edit when you can view and canEdit (even as a customer)  | 
            ||
| 2364 | * Or if you are a Shop Admin you can always edit.  | 
            ||
| 2365 | * Otherwise it is false...  | 
            ||
| 2366 | *  | 
            ||
| 2367 | * @param Member $member  | 
            ||
| 2368 | *  | 
            ||
| 2369 | * @return bool  | 
            ||
| 2370 | **/  | 
            ||
| 2371 | public function canEdit($member = null)  | 
            ||
| 2390 | |||
| 2391 | /**  | 
            ||
| 2392 | * is the order ready to go through to the  | 
            ||
| 2393 | * checkout process.  | 
            ||
| 2394 | *  | 
            ||
| 2395 | * This method checks all the order items and order modifiers  | 
            ||
| 2396 | * If any of them need immediate attention then this is done  | 
            ||
| 2397 | * first after which it will go through to the checkout page.  | 
            ||
| 2398 | *  | 
            ||
| 2399 | * @param Member (optional) $member  | 
            ||
| 2400 | *  | 
            ||
| 2401 | * @return bool  | 
            ||
| 2402 | **/  | 
            ||
| 2403 | public function canCheckout(Member $member = null)  | 
            ||
| 2417 | |||
| 2418 | /**  | 
            ||
| 2419 | * Can the order be submitted?  | 
            ||
| 2420 | * this method can be used to stop an order from being submitted  | 
            ||
| 2421 | * due to something not being completed or done.  | 
            ||
| 2422 | *  | 
            ||
| 2423 | * @see Order::SubmitErrors  | 
            ||
| 2424 | *  | 
            ||
| 2425 | * @param Member $member  | 
            ||
| 2426 | *  | 
            ||
| 2427 | * @return bool  | 
            ||
| 2428 | **/  | 
            ||
| 2429 | public function canSubmit(Member $member = null)  | 
            ||
| 2446 | |||
| 2447 | /**  | 
            ||
| 2448 | * Can a payment be made for this Order?  | 
            ||
| 2449 | *  | 
            ||
| 2450 | * @param Member $member  | 
            ||
| 2451 | *  | 
            ||
| 2452 | * @return bool  | 
            ||
| 2453 | **/  | 
            ||
| 2454 | public function canPay(Member $member = null)  | 
            ||
| 2467 | |||
| 2468 | /**  | 
            ||
| 2469 | * Can the given member cancel this order?  | 
            ||
| 2470 | *  | 
            ||
| 2471 | * @param Member $member  | 
            ||
| 2472 | *  | 
            ||
| 2473 | * @return bool  | 
            ||
| 2474 | **/  | 
            ||
| 2475 | public function canCancel(Member $member = null)  | 
            ||
| 2492 | |||
| 2493 | /**  | 
            ||
| 2494 | * @param Member $member  | 
            ||
| 2495 | *  | 
            ||
| 2496 | * @return bool  | 
            ||
| 2497 | **/  | 
            ||
| 2498 | public function canDelete($member = null)  | 
            ||
| 2514 | |||
| 2515 | /**  | 
            ||
| 2516 | * Returns all the order logs that the current member can view  | 
            ||
| 2517 | * i.e. some order logs can only be viewed by the admin (e.g. suspected fraud orderlog).  | 
            ||
| 2518 | *  | 
            ||
| 2519 | * @return ArrayList (OrderStatusLogs)  | 
            ||
| 2520 | **/  | 
            ||
| 2521 | public function CanViewOrderStatusLogs()  | 
            ||
| 2533 | |||
| 2534 | /**  | 
            ||
| 2535 | * returns all the logs that can be viewed by the customer.  | 
            ||
| 2536 | *  | 
            ||
| 2537 | * @return ArrayList (OrderStausLogs)  | 
            ||
| 2538 | */  | 
            ||
| 2539 | public function CustomerViewableOrderStatusLogs()  | 
            ||
| 2553 | |||
| 2554 | /*******************************************************  | 
            ||
| 2555 | * 8. GET METHODS (e.g. Total, SubTotal, Title, etc...)  | 
            ||
| 2556 | *******************************************************/  | 
            ||
| 2557 | |||
| 2558 | /**  | 
            ||
| 2559 | * returns the email to be used for customer communication.  | 
            ||
| 2560 | *  | 
            ||
| 2561 | * @return string  | 
            ||
| 2562 | */  | 
            ||
| 2563 | public function OrderEmail()  | 
            ||
| 2585 | |||
| 2586 | /**  | 
            ||
| 2587 | * Returns true if there is a prink or email link.  | 
            ||
| 2588 | *  | 
            ||
| 2589 | * @return bool  | 
            ||
| 2590 | */  | 
            ||
| 2591 | public function HasPrintOrEmailLink()  | 
            ||
| 2595 | |||
| 2596 | /**  | 
            ||
| 2597 | * returns the absolute link to the order that can be used in the customer communication (email).  | 
            ||
| 2598 | *  | 
            ||
| 2599 | * @return string  | 
            ||
| 2600 | */  | 
            ||
| 2601 | public function EmailLink($type = 'Order_StatusEmail')  | 
            ||
| 2613 | |||
| 2614 | /**  | 
            ||
| 2615 | * returns the absolute link to the order for printing.  | 
            ||
| 2616 | *  | 
            ||
| 2617 | * @return string  | 
            ||
| 2618 | */  | 
            ||
| 2619 | public function PrintLink()  | 
            ||
| 2631 | |||
| 2632 | /**  | 
            ||
| 2633 | * returns the absolute link to the order for printing.  | 
            ||
| 2634 | *  | 
            ||
| 2635 | * @return string  | 
            ||
| 2636 | */  | 
            ||
| 2637 | public function PackingSlipLink()  | 
            ||
| 2647 | |||
| 2648 | /**  | 
            ||
| 2649 | * returns the absolute link that the customer can use to retrieve the email WITHOUT logging in.  | 
            ||
| 2650 | *  | 
            ||
| 2651 | * @return string  | 
            ||
| 2652 | */  | 
            ||
| 2653 | public function RetrieveLink()  | 
            ||
| 2657 | |||
| 2658 | public function getRetrieveLink()  | 
            ||
| 2672 | |||
| 2673 | public function ShareLink()  | 
            ||
| 2677 | |||
| 2678 | public function getShareLink()  | 
            ||
| 2696 | |||
| 2697 | /**  | 
            ||
| 2698 | * @alias for getFeedbackLink  | 
            ||
| 2699 | * @return string  | 
            ||
| 2700 | */  | 
            ||
| 2701 | public function FeedbackLink()  | 
            ||
| 2705 | |||
| 2706 | /**  | 
            ||
| 2707 | * @return string | null  | 
            ||
| 2708 | */  | 
            ||
| 2709 | public function getFeedbackLink()  | 
            ||
| 2717 | |||
| 2718 | /**  | 
            ||
| 2719 | * link to delete order.  | 
            ||
| 2720 | *  | 
            ||
| 2721 | * @return string  | 
            ||
| 2722 | */  | 
            ||
| 2723 | public function DeleteLink()  | 
            ||
| 2735 | |||
| 2736 | /**  | 
            ||
| 2737 | * link to copy order.  | 
            ||
| 2738 | *  | 
            ||
| 2739 | * @return string  | 
            ||
| 2740 | */  | 
            ||
| 2741 | public function CopyOrderLink()  | 
            ||
| 2753 | |||
| 2754 | /**  | 
            ||
| 2755 | * A "Title" for the order, which summarises the main details (date, and customer) in a string.  | 
            ||
| 2756 | *  | 
            ||
| 2757 | * @param string $dateFormat - e.g. "D j M Y, G:i T"  | 
            ||
| 2758 | * @param bool $includeName - e.g. by Mr Johnson  | 
            ||
| 2759 | *  | 
            ||
| 2760 | * @return string  | 
            ||
| 2761 | **/  | 
            ||
| 2762 | public function Title($dateFormat = null, $includeName = false)  | 
            ||
| 2825 | |||
| 2826 | /**  | 
            ||
| 2827 | * Returns the subtotal of the items for this order.  | 
            ||
| 2828 | *  | 
            ||
| 2829 | * @return float  | 
            ||
| 2830 | */  | 
            ||
| 2831 | public function SubTotal()  | 
            ||
| 2849 | |||
| 2850 | /**  | 
            ||
| 2851 | * @return Currency (DB Object)  | 
            ||
| 2852 | **/  | 
            ||
| 2853 | public function SubTotalAsCurrencyObject()  | 
            ||
| 2857 | |||
| 2858 | /**  | 
            ||
| 2859 | * @return Money  | 
            ||
| 2860 | **/  | 
            ||
| 2861 | public function SubTotalAsMoney()  | 
            ||
| 2869 | |||
| 2870 | /**  | 
            ||
| 2871 | * @param string|array $excluded - Class(es) of modifier(s) to ignore in the calculation.  | 
            ||
| 2872 | * @param bool $stopAtExcludedModifier - when this flag is TRUE, we stop adding the modifiers when we reach an excluded modifier.  | 
            ||
| 2873 | *  | 
            ||
| 2874 | * @return Currency (DB Object)  | 
            ||
| 2875 | **/  | 
            ||
| 2876 | public function ModifiersSubTotalAsCurrencyObject($excluded = null, $stopAtExcludedModifier = false)  | 
            ||
| 2880 | |||
| 2881 | /**  | 
            ||
| 2882 | * @param string|array $excluded - Class(es) of modifier(s) to ignore in the calculation.  | 
            ||
| 2883 | * @param bool $stopAtExcludedModifier - when this flag is TRUE, we stop adding the modifiers when we reach an excluded modifier.  | 
            ||
| 2884 | *  | 
            ||
| 2885 | * @return Money (DB Object)  | 
            ||
| 2886 | **/  | 
            ||
| 2887 | public function ModifiersSubTotalAsMoneyObject($excluded = null, $stopAtExcludedModifier = false)  | 
            ||
| 2891 | |||
| 2892 | /**  | 
            ||
| 2893 | * Returns the total cost of an order including the additional charges or deductions of its modifiers.  | 
            ||
| 2894 | *  | 
            ||
| 2895 | * @return float  | 
            ||
| 2896 | */  | 
            ||
| 2897 | public function Total()  | 
            ||
| 2905 | |||
| 2906 | /**  | 
            ||
| 2907 | * @return Currency (DB Object)  | 
            ||
| 2908 | **/  | 
            ||
| 2909 | public function TotalAsCurrencyObject()  | 
            ||
| 2913 | |||
| 2914 | /**  | 
            ||
| 2915 | * @return Money  | 
            ||
| 2916 | **/  | 
            ||
| 2917 | public function TotalAsMoney()  | 
            ||
| 2925 | |||
| 2926 | /**  | 
            ||
| 2927 | * Checks to see if any payments have been made on this order  | 
            ||
| 2928 | * and if so, subracts the payment amount from the order.  | 
            ||
| 2929 | *  | 
            ||
| 2930 | * @return float  | 
            ||
| 2931 | **/  | 
            ||
| 2932 | public function TotalOutstanding()  | 
            ||
| 2952 | |||
| 2953 | /**  | 
            ||
| 2954 | * @return Currency (DB Object)  | 
            ||
| 2955 | **/  | 
            ||
| 2956 | public function TotalOutstandingAsCurrencyObject()  | 
            ||
| 2960 | |||
| 2961 | /**  | 
            ||
| 2962 | * @return Money  | 
            ||
| 2963 | **/  | 
            ||
| 2964 | public function TotalOutstandingAsMoney()  | 
            ||
| 2972 | |||
| 2973 | /**  | 
            ||
| 2974 | * @return float  | 
            ||
| 2975 | */  | 
            ||
| 2976 | public function TotalPaid()  | 
            ||
| 2997 | |||
| 2998 | /**  | 
            ||
| 2999 | * @return Currency (DB Object)  | 
            ||
| 3000 | **/  | 
            ||
| 3001 | public function TotalPaidAsCurrencyObject()  | 
            ||
| 3005 | |||
| 3006 | /**  | 
            ||
| 3007 | * @return Money  | 
            ||
| 3008 | **/  | 
            ||
| 3009 | public function TotalPaidAsMoney()  | 
            ||
| 3017 | |||
| 3018 | /**  | 
            ||
| 3019 | * returns the total number of OrderItems (not modifiers).  | 
            ||
| 3020 | * This is meant to run as fast as possible to quickly check  | 
            ||
| 3021 | * if there is anything in the cart.  | 
            ||
| 3022 | *  | 
            ||
| 3023 | * @param bool $recalculate - do we need to recalculate (value is retained during lifetime of Object)  | 
            ||
| 3024 | *  | 
            ||
| 3025 | * @return int  | 
            ||
| 3026 | **/  | 
            ||
| 3027 | public function TotalItems($recalculate = false)  | 
            ||
| 3041 | |||
| 3042 | /**  | 
            ||
| 3043 | * Little shorthand.  | 
            ||
| 3044 | *  | 
            ||
| 3045 | * @param bool $recalculate  | 
            ||
| 3046 | *  | 
            ||
| 3047 | * @return bool  | 
            ||
| 3048 | **/  | 
            ||
| 3049 | public function MoreThanOneItemInCart($recalculate = false)  | 
            ||
| 3053 | |||
| 3054 | /**  | 
            ||
| 3055 | * returns the total number of OrderItems (not modifiers) times their respectective quantities.  | 
            ||
| 3056 | *  | 
            ||
| 3057 | * @param bool $recalculate - force recalculation  | 
            ||
| 3058 | *  | 
            ||
| 3059 | * @return float  | 
            ||
| 3060 | **/  | 
            ||
| 3061 | public function TotalItemsTimesQuantity($recalculate = false)  | 
            ||
| 3081 | |||
| 3082 | /**  | 
            ||
| 3083 | *  | 
            ||
| 3084 | * @return string (country code)  | 
            ||
| 3085 | **/  | 
            ||
| 3086 | public function Country()  | 
            ||
| 3090 | |||
| 3091 | /**  | 
            ||
| 3092 | * Returns the country code for the country that applies to the order.  | 
            ||
| 3093 | * @alias for getCountry  | 
            ||
| 3094 | *  | 
            ||
| 3095 | * @return string - country code e.g. NZ  | 
            ||
| 3096 | */  | 
            ||
| 3097 | public function getCountry()  | 
            ||
| 3134 | |||
| 3135 | /**  | 
            ||
| 3136 | * @alias for getFullNameCountry  | 
            ||
| 3137 | *  | 
            ||
| 3138 | * @return string - country name  | 
            ||
| 3139 | **/  | 
            ||
| 3140 | public function FullNameCountry()  | 
            ||
| 3144 | |||
| 3145 | /**  | 
            ||
| 3146 | * returns name of coutry.  | 
            ||
| 3147 | *  | 
            ||
| 3148 | * @return string - country name  | 
            ||
| 3149 | **/  | 
            ||
| 3150 | public function getFullNameCountry()  | 
            ||
| 3154 | |||
| 3155 | /**  | 
            ||
| 3156 | * @alis for getExpectedCountryName  | 
            ||
| 3157 | * @return string - country name  | 
            ||
| 3158 | **/  | 
            ||
| 3159 | public function ExpectedCountryName()  | 
            ||
| 3163 | |||
| 3164 | /**  | 
            ||
| 3165 | * returns name of coutry that we expect the customer to have  | 
            ||
| 3166 | * This takes into consideration more than just what has been entered  | 
            ||
| 3167 | * for example, it looks at GEO IP.  | 
            ||
| 3168 | *  | 
            ||
| 3169 | * @todo: why do we dont return a string IF there is only one item.  | 
            ||
| 3170 | *  | 
            ||
| 3171 | * @return string - country name  | 
            ||
| 3172 | **/  | 
            ||
| 3173 | public function getExpectedCountryName()  | 
            ||
| 3177 | |||
| 3178 | /**  | 
            ||
| 3179 | * return the title of the fixed country (if any).  | 
            ||
| 3180 | *  | 
            ||
| 3181 | * @return string | empty string  | 
            ||
| 3182 | **/  | 
            ||
| 3183 | public function FixedCountry()  | 
            ||
| 3196 | |||
| 3197 | /**  | 
            ||
| 3198 | * Returns the region that applies to the order.  | 
            ||
| 3199 | * we check both billing and shipping, in case one of them is empty.  | 
            ||
| 3200 | *  | 
            ||
| 3201 | * @return DataObject | Null (EcommerceRegion)  | 
            ||
| 3202 | **/  | 
            ||
| 3203 | public function Region()  | 
            ||
| 3240 | |||
| 3241 | /**  | 
            ||
| 3242 | * Casted variable  | 
            ||
| 3243 | * Currency is not the same as the standard one?  | 
            ||
| 3244 | *  | 
            ||
| 3245 | * @return bool  | 
            ||
| 3246 | **/  | 
            ||
| 3247 | public function HasAlternativeCurrency()  | 
            ||
| 3263 | |||
| 3264 | /**  | 
            ||
| 3265 | * Makes sure exchange rate is updated and maintained before order is submitted  | 
            ||
| 3266 | * This method is public because it could be called from a shopping Cart Object.  | 
            ||
| 3267 | **/  | 
            ||
| 3268 | public function EnsureCorrectExchangeRate()  | 
            ||
| 3286 | |||
| 3287 | /**  | 
            ||
| 3288 | * speeds up processing by storing the IsSubmitted value  | 
            ||
| 3289 | * we start with -1 to know if it has been requested before.  | 
            ||
| 3290 | *  | 
            ||
| 3291 | * @var bool  | 
            ||
| 3292 | */  | 
            ||
| 3293 | protected $_isSubmittedTempVar = -1;  | 
            ||
| 3294 | |||
| 3295 | /**  | 
            ||
| 3296 | * Casted variable - has the order been submitted?  | 
            ||
| 3297 | * alias  | 
            ||
| 3298 | * @param bool $recalculate  | 
            ||
| 3299 | *  | 
            ||
| 3300 | * @return bool  | 
            ||
| 3301 | **/  | 
            ||
| 3302 | public function IsSubmitted($recalculate = true)  | 
            ||
| 3306 | |||
| 3307 | /**  | 
            ||
| 3308 | * Casted variable - has the order been submitted?  | 
            ||
| 3309 | *  | 
            ||
| 3310 | * @param bool $recalculate  | 
            ||
| 3311 | *  | 
            ||
| 3312 | * @return bool  | 
            ||
| 3313 | **/  | 
            ||
| 3314 | public function getIsSubmitted($recalculate = false)  | 
            ||
| 3326 | |||
| 3327 | /**  | 
            ||
| 3328 | *  | 
            ||
| 3329 | *  | 
            ||
| 3330 | * @return bool  | 
            ||
| 3331 | */  | 
            ||
| 3332 | public function IsArchived()  | 
            ||
| 3342 | |||
| 3343 | /**  | 
            ||
| 3344 | * Submission Log for this Order (if any).  | 
            ||
| 3345 | *  | 
            ||
| 3346 | * @return Submission Log (OrderStatusLog_Submitted) | Null  | 
            ||
| 3347 | **/  | 
            ||
| 3348 | public function SubmissionLog()  | 
            ||
| 3356 | |||
| 3357 | /**  | 
            ||
| 3358 | * Submission Log for this Order (if any).  | 
            ||
| 3359 | *  | 
            ||
| 3360 | * @return DateTime  | 
            ||
| 3361 | **/  | 
            ||
| 3362 | public function OrderDate()  | 
            ||
| 3373 | |||
| 3374 | /**  | 
            ||
| 3375 | * @return int  | 
            ||
| 3376 | */  | 
            ||
| 3377 | public function SecondsSinceBeingSubmitted()  | 
            ||
| 3385 | |||
| 3386 | /**  | 
            ||
| 3387 | * if the order can not be submitted,  | 
            ||
| 3388 | * then the reasons why it can not be submitted  | 
            ||
| 3389 | * will be returned by this method.  | 
            ||
| 3390 | *  | 
            ||
| 3391 | * @see Order::canSubmit  | 
            ||
| 3392 | *  | 
            ||
| 3393 | * @return ArrayList | null  | 
            ||
| 3394 | */  | 
            ||
| 3395 | public function SubmitErrors()  | 
            ||
| 3411 | |||
| 3412 | /**  | 
            ||
| 3413 | * Casted variable - has the order been submitted?  | 
            ||
| 3414 | *  | 
            ||
| 3415 | * @param bool $withDetail  | 
            ||
| 3416 | *  | 
            ||
| 3417 | * @return string  | 
            ||
| 3418 | **/  | 
            ||
| 3419 | public function CustomerStatus($withDetail = true)  | 
            ||
| 3441 | |||
| 3442 | /**  | 
            ||
| 3443 | * Casted variable - does the order have a potential shipping address?  | 
            ||
| 3444 | *  | 
            ||
| 3445 | * @return bool  | 
            ||
| 3446 | **/  | 
            ||
| 3447 | public function CanHaveShippingAddress()  | 
            ||
| 3455 | |||
| 3456 | /**  | 
            ||
| 3457 | * returns the link to view the Order  | 
            ||
| 3458 | * WHY NOT CHECKOUT PAGE: first we check for cart page.  | 
            ||
| 3459 | *  | 
            ||
| 3460 | * @return CartPage | Null  | 
            ||
| 3461 | */  | 
            ||
| 3462 | public function DisplayPage()  | 
            ||
| 3480 | |||
| 3481 | /**  | 
            ||
| 3482 | * returns the link to view the Order  | 
            ||
| 3483 | * WHY NOT CHECKOUT PAGE: first we check for cart page.  | 
            ||
| 3484 | * If a cart page has been created then we refer through to Cart Page.  | 
            ||
| 3485 | * Otherwise it will default to the checkout page.  | 
            ||
| 3486 | *  | 
            ||
| 3487 | * @param string $action - any action that should be added to the link.  | 
            ||
| 3488 | *  | 
            ||
| 3489 | * @return String(URLSegment)  | 
            ||
| 3490 | */  | 
            ||
| 3491 | public function Link($action = null)  | 
            ||
| 3507 | |||
| 3508 | /**  | 
            ||
| 3509 | * Returns to link to access the Order's API.  | 
            ||
| 3510 | *  | 
            ||
| 3511 | * @param string $version  | 
            ||
| 3512 | * @param string $extension  | 
            ||
| 3513 | *  | 
            ||
| 3514 | * @return String(URL)  | 
            ||
| 3515 | */  | 
            ||
| 3516 | public function APILink($version = 'v1', $extension = 'xml')  | 
            ||
| 3520 | |||
| 3521 | /**  | 
            ||
| 3522 | * returns the link to finalise the Order.  | 
            ||
| 3523 | *  | 
            ||
| 3524 | * @return String(URLSegment)  | 
            ||
| 3525 | */  | 
            ||
| 3526 | public function CheckoutLink()  | 
            ||
| 3541 | |||
| 3542 | /**  | 
            ||
| 3543 | * Converts the Order into HTML, based on the Order Template.  | 
            ||
| 3544 | *  | 
            ||
| 3545 | * @return HTML Object  | 
            ||
| 3546 | **/  | 
            ||
| 3547 | public function ConvertToHTML()  | 
            ||
| 3557 | |||
| 3558 | /**  | 
            ||
| 3559 | * Converts the Order into a serialized string  | 
            ||
| 3560 | * TO DO: check if this works and check if we need to use special sapphire serialization code.  | 
            ||
| 3561 | *  | 
            ||
| 3562 | * @return string - serialized object  | 
            ||
| 3563 | **/  | 
            ||
| 3564 | public function ConvertToString()  | 
            ||
| 3568 | |||
| 3569 | /**  | 
            ||
| 3570 | * Converts the Order into a JSON object  | 
            ||
| 3571 | * TO DO: check if this works and check if we need to use special sapphire JSON code.  | 
            ||
| 3572 | *  | 
            ||
| 3573 | * @return string - JSON  | 
            ||
| 3574 | **/  | 
            ||
| 3575 | public function ConvertToJSON()  | 
            ||
| 3579 | |||
| 3580 | /**  | 
            ||
| 3581 | * returns itself wtih more data added as variables.  | 
            ||
| 3582 | * We add has_one and has_many as variables like this: $this->MyHasOne_serialized = serialize($this->MyHasOne()).  | 
            ||
| 3583 | *  | 
            ||
| 3584 | * @return Order - with most important has one and has many items included as variables.  | 
            ||
| 3585 | **/  | 
            ||
| 3586 | protected function addHasOneAndHasManyAsVariables()  | 
            ||
| 3599 | |||
| 3600 | /*******************************************************  | 
            ||
| 3601 | * 9. TEMPLATE RELATED STUFF  | 
            ||
| 3602 | *******************************************************/  | 
            ||
| 3603 | |||
| 3604 | /**  | 
            ||
| 3605 | * returns the instance of EcommerceConfigAjax for use in templates.  | 
            ||
| 3606 | * In templates, it is used like this:  | 
            ||
| 3607 | * $EcommerceConfigAjax.TableID.  | 
            ||
| 3608 | *  | 
            ||
| 3609 | * @return EcommerceConfigAjax  | 
            ||
| 3610 | **/  | 
            ||
| 3611 | public function AJAXDefinitions()  | 
            ||
| 3615 | |||
| 3616 | /**  | 
            ||
| 3617 | * returns the instance of EcommerceDBConfig.  | 
            ||
| 3618 | *  | 
            ||
| 3619 | * @return EcommerceDBConfig  | 
            ||
| 3620 | **/  | 
            ||
| 3621 | public function EcomConfig()  | 
            ||
| 3625 | |||
| 3626 | /**  | 
            ||
| 3627 | * Collects the JSON data for an ajax return of the cart.  | 
            ||
| 3628 | *  | 
            ||
| 3629 | * @param array $js  | 
            ||
| 3630 | *  | 
            ||
| 3631 | * @return array (for use in AJAX for JSON)  | 
            ||
| 3632 | **/  | 
            ||
| 3633 | public function updateForAjax(array $js)  | 
            ||
| 3686 | |||
| 3687 | /**  | 
            ||
| 3688 | * @ToDO: move to more appropriate class  | 
            ||
| 3689 | *  | 
            ||
| 3690 | * @return float  | 
            ||
| 3691 | **/  | 
            ||
| 3692 | public function SubTotalCartValue()  | 
            ||
| 3696 | |||
| 3697 | /*******************************************************  | 
            ||
| 3698 | * 10. STANDARD SS METHODS (requireDefaultRecords, onBeforeDelete, etc...)  | 
            ||
| 3699 | *******************************************************/  | 
            ||
| 3700 | |||
| 3701 | /**  | 
            ||
| 3702 | *standard SS method.  | 
            ||
| 3703 | **/  | 
            ||
| 3704 | public function populateDefaults()  | 
            ||
| 3708 | |||
| 3709 | public function onBeforeWrite()  | 
            ||
| 3724 | |||
| 3725 | /**  | 
            ||
| 3726 | * standard SS method  | 
            ||
| 3727 | * adds the ability to update order after writing it.  | 
            ||
| 3728 | **/  | 
            ||
| 3729 | public function onAfterWrite()  | 
            ||
| 3753 | |||
| 3754 | /**  | 
            ||
| 3755 | *standard SS method.  | 
            ||
| 3756 | *  | 
            ||
| 3757 | * delete attributes, statuslogs, and payments  | 
            ||
| 3758 | * THIS SHOULD NOT BE USED AS ORDERS SHOULD BE CANCELLED NOT DELETED  | 
            ||
| 3759 | */  | 
            ||
| 3760 | public function onBeforeDelete()  | 
            ||
| 3805 | |||
| 3806 | /*******************************************************  | 
            ||
| 3807 | * 11. DEBUG  | 
            ||
| 3808 | *******************************************************/  | 
            ||
| 3809 | |||
| 3810 | /**  | 
            ||
| 3811 | * Debug helper method.  | 
            ||
| 3812 | * Can be called from /shoppingcart/debug/.  | 
            ||
| 3813 | *  | 
            ||
| 3814 | * @return string  | 
            ||
| 3815 | */  | 
            ||
| 3816 | public function debug()  | 
            ||
| 3822 | }  | 
            ||
| 3823 | 
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.