Passed
Push — master ( e3fcf4...82e94b )
by
unknown
02:37
created
code/model/translations/CountryPrice_SiteTreeExtensions.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -123,6 +123,7 @@
 block discarded – undo
123 123
     /**
124 124
      * @var int $countryID
125 125
      *
126
+     * @param integer $countryID
126 127
      * @return CountryPrice_Translation | null
127 128
      */
128 129
     public function getEcommerceTranslation($countryID)
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -48,12 +48,12 @@  discard block
 block discarded – undo
48 48
     public function CanonicalObject()
49 49
     {
50 50
         $countryObject = CountryPrice_EcommerceCountry::get_real_country();
51
-        if($countryObject && $countryObject->Code) {
51
+        if ($countryObject && $countryObject->Code) {
52 52
             $object = $this->owner->CountryPriceTranslations()
53 53
                 ->innerJoin('EcommerceCountry', '"EcommerceCountry"."ID" = "CountryPrice_Translation"."EcommerceCountryID"')
54 54
                 ->filter(array('EcommerceCountry.Code' => $countryObject->Code))
55 55
                 ->first();
56
-            if($object && $object->exists()) {
56
+            if ($object && $object->exists()) {
57 57
                 return $object;
58 58
             }
59 59
         }
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     public function loadTranslatedValues($countryID = 0, $variableOrMethod = '')
64 64
     {
65 65
         $translation = null;
66
-        if (! $countryID) {
66
+        if (!$countryID) {
67 67
             $countryObject = CountryPrice_EcommerceCountry::get_real_country();
68 68
             if ($countryObject) {
69 69
                 $countryID = $countryObject->ID;
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
             $fieldsToReplace = $translation->FieldsToReplace();
83 83
             foreach ($fieldsToReplace as $replaceFields) {
84 84
                 $pageField = $replaceFields->PageField;
85
-                $pageFieldTranslated = $pageField . 'Translated';
85
+                $pageFieldTranslated = $pageField.'Translated';
86 86
                 $translationField = $replaceFields->TranslationField;
87
-                if (! $variableOrMethod || $variableOrMethod === $pageField) {
87
+                if (!$variableOrMethod || $variableOrMethod === $pageField) {
88 88
                     if ($translation->hasMethod($translationField)) {
89 89
                         $this->owner->$pageField = $translation->$translationField();
90 90
                         $this->owner->$pageFieldTranslated = $translation->$translationField();
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
      */
148 148
     public function getEcommerceTranslation($countryID)
149 149
     {
150
-        if(!isset($this->_translations_all_cache[$countryID])) {
150
+        if (!isset($this->_translations_all_cache[$countryID])) {
151 151
             $this->_translations_all_cache[$countryID] = $this->owner
152 152
                 ->CountryPriceTranslations()
153 153
                 ->filter(
Please login to merge, or discard this patch.
code/interfaces/CountryURLProviderInterface.php 1 patch
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -3,14 +3,17 @@
 block discarded – undo
3 3
 interface CountryURLProviderInterface
4 4
 {
5 5
     /**
6
+     * @return boolean
6 7
      */
7 8
     public function hasCountrySegment($url = '');
8 9
 
9 10
     /**
11
+     * @return string
10 12
      */
11 13
     public function replaceCountryCodeInUrl($countryCode, $url = '');
12 14
 
13 15
     /**
16
+     * @return string
14 17
      */
15 18
     public function addCountryCodeToUrl($countryCode, $url = '');
16 19
 
Please login to merge, or discard this patch.
code/model/translations/CountryPrice_Translation.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -225,8 +225,7 @@
 block discarded – undo
225 225
             $hasCountrySegment = CountryPrice_Translation::get_country_url_provider()->hasCountrySegment($link);
226 226
             if($hasCountrySegment){
227 227
                 $link = CountryPrice_Translation::get_country_url_provider()->replaceCountryCodeInUrl($this->EcommerceCountry()->Code, $link);
228
-            }
229
-            else {
228
+            } else {
230 229
                 $link = CountryPrice_Translation::get_country_url_provider()->addCountryCodeToUrl($this->EcommerceCountry()->Code, $link);
231 230
             }
232 231
         }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
         $countryDropdownField = DropdownField::create(
100 100
             'EcommerceCountryID',
101 101
             $fields->dataFieldByName('EcommerceCountryID')->Title(),
102
-            array('' => '-- make sure to select a country --')+$countries
102
+            array('' => '-- make sure to select a country --') + $countries
103 103
         );
104 104
 
105 105
         // //$fields->removeFieldFromTab("Root.Main", 'ParentID');
106
-        if($this->WithoutTranslation) {
106
+        if ($this->WithoutTranslation) {
107 107
             return FieldList::create(
108 108
                 array(
109 109
                     $countryDropdownField,
@@ -123,19 +123,19 @@  discard block
 block discarded – undo
123 123
             );
124 124
         }
125 125
         $dbFields = $this->inheritedDatabaseFields();
126
-        foreach($dbFields as $dbField => $fieldType) {
126
+        foreach ($dbFields as $dbField => $fieldType) {
127 127
             $useField = 'UseOriginal'.$dbField;
128
-            if(!empty($this->$useField)) {
128
+            if (!empty($this->$useField)) {
129 129
                 $fields->replaceField(
130 130
                     $dbField,
131 131
                     $fields->dataFieldByName($dbField)->performReadonlyTransformation()
132 132
                 );
133 133
             }
134
-            if($fields->dataFieldByName($useField)){
135
-                $fields->dataFieldByName($useField)->setDescription(_t('CountryPrice_Translation.IGNORE', 'Use untranslated value for ') . $dbField);
134
+            if ($fields->dataFieldByName($useField)) {
135
+                $fields->dataFieldByName($useField)->setDescription(_t('CountryPrice_Translation.IGNORE', 'Use untranslated value for ').$dbField);
136 136
             }
137 137
         }
138
-        if($this->exists() && $this->ParentID) {
138
+        if ($this->exists() && $this->ParentID) {
139 139
             $fields->addFieldToTab(
140 140
                 'Root.ParentPage',
141 141
                 CMSEditLinkField::create(
@@ -210,9 +210,9 @@  discard block
 block discarded – undo
210 210
             )
211 211
         );
212 212
         $this->extend('updateFieldsToReplace', $al);
213
-        foreach($al as $fieldToReplace) {
214
-            $ignoreField = 'UseOriginal' . $fieldToReplace->PageField;
215
-            if(!empty($this->owner->$ignoreField)) {
213
+        foreach ($al as $fieldToReplace) {
214
+            $ignoreField = 'UseOriginal'.$fieldToReplace->PageField;
215
+            if (!empty($this->owner->$ignoreField)) {
216 216
                 $al->remove($fieldToReplace);
217 217
             }
218 218
         }
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
         $link = $this->Parent()->Link();
236 236
         if ($this->EcommerceCountryID) {
237 237
             $hasCountrySegment = CountryPrice_Translation::get_country_url_provider()->hasCountrySegment($link);
238
-            if($hasCountrySegment){
238
+            if ($hasCountrySegment) {
239 239
                 $link = CountryPrice_Translation::get_country_url_provider()->replaceCountryCodeInUrl($this->EcommerceCountry()->Code, $link);
240 240
             }
241 241
             else {
@@ -250,20 +250,20 @@  discard block
 block discarded – undo
250 250
         parent::requireDefaultRecords();
251 251
         //get rid of rogue entries:
252 252
         DB::query('DELETE FROM CountryPrice_Translation WHERE EcommerceCountryID = 0 OR ParentID = 0');
253
-        if(Config::inst()->get('CountryPrice_Translation', 'automatically_create_dummy_translations_for_products_and_productgroups')) {
253
+        if (Config::inst()->get('CountryPrice_Translation', 'automatically_create_dummy_translations_for_products_and_productgroups')) {
254 254
             $prices = CountryPrice::get();
255 255
             $ecommerceCountries = array();
256
-            foreach($prices as $price) {
257
-                if($countryObject = $price->CountryObject()) {
258
-                    if($buyable = $price->Buyable()) {
259
-                        if($buyable instanceof Product) {
260
-                            if($buyable->ID && $countryObject->ID) {
256
+            foreach ($prices as $price) {
257
+                if ($countryObject = $price->CountryObject()) {
258
+                    if ($buyable = $price->Buyable()) {
259
+                        if ($buyable instanceof Product) {
260
+                            if ($buyable->ID && $countryObject->ID) {
261 261
                                 $filter = array(
262 262
                                     'EcommerceCountryID' => $countryObject->ID,
263 263
                                     'ParentID' => $buyable->ID
264 264
                                 );
265 265
                                 $ecommerceCountries[$countryObject->ID] = $countryObject;
266
-                                if(! CountryPrice_Translation::get()->filter($filter)->first()) {
266
+                                if (!CountryPrice_Translation::get()->filter($filter)->first()) {
267 267
                                     DB::alteration_message(
268 268
                                         'Creating fake translation for '.$buyable->Title.' for country '.$countryObject->Code,
269 269
                                         'created'
@@ -277,14 +277,14 @@  discard block
 block discarded – undo
277 277
                     }
278 278
                 }
279 279
             }
280
-            if(count($ecommerceCountries)) {
281
-                foreach(ProductGroup::get() as $productGroup) {
282
-                    foreach($ecommerceCountries as $countryID => $countryObject) {
280
+            if (count($ecommerceCountries)) {
281
+                foreach (ProductGroup::get() as $productGroup) {
282
+                    foreach ($ecommerceCountries as $countryID => $countryObject) {
283 283
                         $filter = array(
284 284
                             'EcommerceCountryID' => $countryObject->ID,
285 285
                             'ParentID' => $productGroup->ID
286 286
                         );
287
-                        if(! CountryPrice_Translation::get()->filter($filter)->first()) {
287
+                        if (!CountryPrice_Translation::get()->filter($filter)->first()) {
288 288
                             DB::alteration_message(
289 289
                                 'Creating fake translation for '.$productGroup->Title.' for country '.$countryObject->Code,
290 290
                                 'created'
Please login to merge, or discard this patch.
code/api/CountryURLProvider.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -10,62 +10,62 @@
 block discarded – undo
10 10
 
11 11
 class CountryURLProvider extends Object implements CountryURLProviderInterface
12 12
 {
13
-    private static $country_segments  = array('nz', 'au', 'gb', 'eu', 'jp', 'us', 'zz');
13
+    private static $country_segments = array('nz', 'au', 'gb', 'eu', 'jp', 'us', 'zz');
14 14
 
15
-    public function hasCountrySegment($url = ''){
15
+    public function hasCountrySegment($url = '') {
16 16
         $url = $this->getDefaultURL($url);
17 17
         $parsedUrl = parse_url($url);
18 18
         $pathSegments = explode("/", $parsedUrl['path']);
19 19
         $firstSegment = '';
20
-        $countries =  Config::inst()->get('CountryURLProvider', 'country_segments');
21
-        foreach ($pathSegments as $position => $segment){
22
-            if($segment){
20
+        $countries = Config::inst()->get('CountryURLProvider', 'country_segments');
21
+        foreach ($pathSegments as $position => $segment) {
22
+            if ($segment) {
23 23
                 $firstSegment = $segment;
24 24
                 break;
25 25
             }
26 26
         }
27
-        if(in_array($firstSegment, $countries)){
27
+        if (in_array($firstSegment, $countries)) {
28 28
             return true;
29 29
         }
30 30
         return false;
31 31
     }
32 32
 
33
-    public function replaceCountryCodeInUrl($countryCode, $url = ''){
33
+    public function replaceCountryCodeInUrl($countryCode, $url = '') {
34 34
         $url = $this->getDefaultURL($url);
35 35
         $parsedUrl = parse_url($url);
36 36
         $pathParts = explode('/', $parsedUrl['path']);
37
-        $countries =  Config::inst()->get('CountryURLProvider', 'country_segments');
38
-        foreach($pathParts as $pathPartsKey => $pathPart) {
37
+        $countries = Config::inst()->get('CountryURLProvider', 'country_segments');
38
+        foreach ($pathParts as $pathPartsKey => $pathPart) {
39 39
             //check for first match
40
-            if(in_array($pathPart, $countries)) {
40
+            if (in_array($pathPart, $countries)) {
41 41
                 $pathParts[$pathPartsKey] = strtolower($countryCode);
42 42
                 break;
43 43
             }
44 44
         }
45 45
         $parsedUrl['path'] = implode('/', $pathParts);
46
-        $url = $parsedUrl['scheme']. '://'. $parsedUrl['host']. $parsedUrl['path'];
47
-        if(isset($parsedUrl['query'])){
48
-            $url = $url . $parsedUrl['query'];
46
+        $url = $parsedUrl['scheme'].'://'.$parsedUrl['host'].$parsedUrl['path'];
47
+        if (isset($parsedUrl['query'])) {
48
+            $url = $url.$parsedUrl['query'];
49 49
         }
50 50
         return $url;
51 51
     }
52 52
 
53
-    public function addCountryCodeToUrl($countryCode, $url = ''){
53
+    public function addCountryCodeToUrl($countryCode, $url = '') {
54 54
         $url = $this->getDefaultURL($url);
55 55
         $parsedUrl = parse_url($url);
56
-        $url = $parsedUrl['scheme']. '://'. $parsedUrl['host']. '/'. strtolower($countryCode) . $parsedUrl['path'];
57
-        if(isset($parsedUrl['query'])){
58
-            $url = $url . $parsedUrl['query'];
56
+        $url = $parsedUrl['scheme'].'://'.$parsedUrl['host'].'/'.strtolower($countryCode).$parsedUrl['path'];
57
+        if (isset($parsedUrl['query'])) {
58
+            $url = $url.$parsedUrl['query'];
59 59
         }
60 60
         return $url;
61 61
     }
62 62
 
63 63
     private function getDefaultURL($url = '')
64 64
     {
65
-        if($url) {
65
+        if ($url) {
66 66
             return Director::absoluteURL($url);
67 67
         }
68
-        return (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
68
+        return (isset($_SERVER['HTTPS']) ? "https" : "http")."://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
69 69
     }
70 70
 
71 71
 }
Please login to merge, or discard this patch.
code/model/buyables/CountryPrice_BuyableExtension.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
     /**
100 100
      * This is called from /ecommerce/code/Product
101 101
      * returning NULL is like returning TRUE OR FALSE, i.e. ignore this.
102
-     * @param Member (optional)   $member
102
+     * @param Member Member   $member
103 103
      * @param bool (optional)     $checkPrice
104
-     * @return false | null
104
+     * @return null|false | null
105 105
      */
106 106
     public function canPurchaseByCountry(Member $member = null, $checkPrice = true, $countryCode = '')
107 107
     {
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
      * as long as we do not give distributors access to the Products
400 400
      * this is fairly safe.
401 401
      * @param member (optiona) $member
402
-     * @return null / bool
402
+     * @return boolean / bool
403 403
      */
404 404
     public function canEdit($member = null)
405 405
     {
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
     {
108 108
         $countryObject = CountryPrice_EcommerceCountry::get_real_country($countryCode);
109 109
         if ($countryObject) {
110
-            if ($this->debug) {debug::log('found country object: '.$countryObject->Code);}
110
+            if ($this->debug) {debug::log('found country object: '.$countryObject->Code); }
111 111
             $countryCode = $countryObject->Code;
112 112
         }
113 113
         if ($countryCode == '') {
114
-            if ($this->debug) {debug::log('There is no country Code! ');}
114
+            if ($this->debug) {debug::log('There is no country Code! '); }
115 115
 
116 116
             //we can not decide
117 117
             return null;
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
             //easy  ... overrules all ...
122 122
             if ($this->owner->AllCountries) {
123 123
                 //is there a valid price ???
124
-                if ($this->debug) {debug::log('All countries applies - updated  ... new price = '.floatval($this->owner->updateCalculatedPrice()));}
124
+                if ($this->debug) {debug::log('All countries applies - updated  ... new price = '.floatval($this->owner->updateCalculatedPrice())); }
125 125
                 $canSell = true;
126 126
             } else {
127 127
 
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
                 //excluded first...
130 130
                 $excluded = $this->owner->getManyManyComponents('ExcludedCountries', "\"Code\" = '$countryCode'")->Count();
131 131
                 if ($excluded) {
132
-                    if ($this->debug) {debug::log('excluded country');}
132
+                    if ($this->debug) {debug::log('excluded country'); }
133 133
 
134 134
                     //no!
135 135
                     return false;
@@ -137,12 +137,12 @@  discard block
 block discarded – undo
137 137
 
138 138
                 //default country is included by default ...
139 139
                 if ($countryCode == EcommerceConfig::get('EcommerceCountry', 'default_country_code')) {
140
-                    if ($this->debug) {debug::log('we are in the default country! exiting now ... ');}
140
+                    if ($this->debug) {debug::log('we are in the default country! exiting now ... '); }
141 141
                     $canSell = true;
142
-                } elseif($this->owner->IncludedCountries()->count()) {
142
+                } elseif ($this->owner->IncludedCountries()->count()) {
143 143
                     $included = $this->owner->getManyManyComponents('IncludedCountries', "\"Code\" = '$countryCode'")->Count();
144 144
                     if ($included) {
145
-                        if ($this->debug) {debug::log('In included countries');}
145
+                        if ($this->debug) {debug::log('In included countries'); }
146 146
                         //null basically means - ignore ...
147 147
                         $canSell = true;
148 148
                     } else {
@@ -151,11 +151,11 @@  discard block
 block discarded – undo
151 151
                     }
152 152
                 }
153 153
             }
154
-            if ($this->debug) {debug::log('the product is '.($canSell ? '' : 'NOT ').' for sale - lets check price ... ');}
154
+            if ($this->debug) {debug::log('the product is '.($canSell ? '' : 'NOT ').' for sale - lets check price ... '); }
155 155
 
156 156
             //is there a valid price ???
157 157
             $countryPrice = $this->owner->getCalculatedPrice(true);
158
-            if ($this->debug) {debug::log('nothing applies, but we have a country price... '.$countryPrice);}
158
+            if ($this->debug) {debug::log('nothing applies, but we have a country price... '.$countryPrice); }
159 159
 
160 160
             return floatval($countryPrice) > 0 ? null : false;
161 161
         }
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
             return null;
219 219
         }
220 220
         $key = $this->owner->ClassName."___".$this->owner->ID.'____'.$countryCode;
221
-        if (! isset(self::$_buyable_price[$key])) {
221
+        if (!isset(self::$_buyable_price[$key])) {
222 222
             //basics
223 223
             $currency = null;
224 224
             $currencyCode = null;
@@ -226,17 +226,17 @@  discard block
 block discarded – undo
226 226
             if ($countryCode) {
227 227
                 $order = ShoppingCart::current_order();
228 228
                 //if the order has never been localised, then we do this now!!!!
229
-                if(count(self::$_buyable_price) === 0) {
229
+                if (count(self::$_buyable_price) === 0) {
230 230
                     CountryPrice_OrderDOD::localise_order($countryCode, $force = true, $runAgain = true);
231 231
 
232 232
                     // CRUCIAL!!!!
233 233
                     // reload order with new values!
234 234
                     $order = ShoppingCart::current_order();
235 235
                 }
236
-                if($order && $order->exists()) {
236
+                if ($order && $order->exists()) {
237 237
                     $currency = $order->CurrencyUsed();
238 238
                 }
239
-                if($currency && $currency->exists()) {
239
+                if ($currency && $currency->exists()) {
240 240
                     //do nothing
241 241
                 } else {
242 242
                     $currency = CountryPrice_EcommerceCurrency::get_currency_for_country($countryCode);
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
                 }
321 321
             }
322 322
             //order must have a country and a currency
323
-            if (! $currencyCode ||  ! $countryCode) {
323
+            if (!$currencyCode || !$countryCode) {
324 324
                 if ($this->debug) {
325 325
                     debug::log('No currency ('.$currencyCode.') or no country code ('.$countryCode.') for order: ');
326 326
                 }
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
      */
414 414
     public function canEdit($member = null)
415 415
     {
416
-        if (! $member) {
416
+        if (!$member) {
417 417
             $member = Member::currentUser();
418 418
         }
419 419
         if ($member) {
Please login to merge, or discard this patch.
code/control/CountryPrice_ChangeCountryController.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -120,8 +120,7 @@
 block discarded – undo
120 120
             $hasCountrySegment = CountryPrice_Translation::get_country_url_provider()->hasCountrySegment($url);
121 121
             if($hasCountrySegment){
122 122
                 $url = CountryPrice_Translation::get_country_url_provider()->replaceCountryCodeInUrl($newCountryCode, $url);
123
-            }
124
-            else {
123
+            } else {
125 124
                 $url = CountryPrice_Translation::get_country_url_provider()->addCountryCodeToUrl($newCountryCode, $url);
126 125
             }
127 126
             return $url.$query;
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -84,11 +84,11 @@  discard block
 block discarded – undo
84 84
 
85 85
         //redirect now
86 86
         $param = Config::inst()->get('CountryPrice_Translation', 'locale_get_parameter');
87
-        if(isset($_GET['force']) && $_GET['force']) {
87
+        if (isset($_GET['force']) && $_GET['force']) {
88 88
 
89
-            return $this->redirect(self::$url_segment . '/changeto/' .$newCountryCode . '/'. '?force-back-home');
89
+            return $this->redirect(self::$url_segment.'/changeto/'.$newCountryCode.'/'.'?force-back-home');
90 90
         }
91
-        if(isset($_GET['force-back-home']) || $_GET['force-back-home']) {
91
+        if (isset($_GET['force-back-home']) || $_GET['force-back-home']) {
92 92
 
93 93
             return $this->redirect('/');
94 94
         }
@@ -149,10 +149,10 @@  discard block
 block discarded – undo
149 149
 
150 150
             $path = isset($parsedUrl['path']) ? $parsedUrl['path'] : '';
151 151
 
152
-            $query = !empty($query) ? '?'. http_build_query($query) : '';
152
+            $query = !empty($query) ? '?'.http_build_query($query) : '';
153 153
 
154 154
             $hasCountrySegment = CountryPrice_Translation::get_country_url_provider()->hasCountrySegment($url);
155
-            if($hasCountrySegment){
155
+            if ($hasCountrySegment) {
156 156
                 $url = CountryPrice_Translation::get_country_url_provider()->replaceCountryCodeInUrl($newCountryCode, $url);
157 157
             }
158 158
             else {
Please login to merge, or discard this patch.
code/model/process/extensions/CountryPrice_OrderDOD.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
             $order = Order::get()->byID($order->ID);
102 102
             $orderHasBeenChanged = false;
103 103
 
104
-             //check currency ...
104
+                //check currency ...
105 105
             if ($order->CurrencyUsedID != $currencyObject->ID) {
106 106
                 $order->SetCurrency($currencyObject);
107 107
                 $orderHasBeenChanged = true;
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
                 'Root.Country',
150 150
                 DropdownField::create(
151 151
                     'DistributorID',
152
-                     _t('Distributor.SINGULAR_NAME', 'Distributor'),
152
+                        _t('Distributor.SINGULAR_NAME', 'Distributor'),
153 153
                     array(''=> '--- Please select ---') + Distributor::get()->map()->toArray()
154 154
                 )
155 155
             );
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
      */
51 51
     public static function localise_order($countryCode = null, $force = false, $runAgain = false)
52 52
     {
53
-        if($runAgain) {
53
+        if ($runAgain) {
54 54
             self::$_number_of_times_we_have_run_localise_order = 0;
55 55
         }
56 56
         if (self::$_number_of_times_we_have_run_localise_order > 2) {
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
             if ($order->IsSubmitted()) {
63 63
                 return true;
64 64
             }
65
-            if (! $countryCode) {
65
+            if (!$countryCode) {
66 66
                 $countryCode = $order->getCountry();
67 67
             }
68 68
             $currencyObject = CountryPrice_EcommerceCurrency::get_currency_for_country($countryCode);
@@ -76,13 +76,13 @@  discard block
 block discarded – undo
76 76
             //check if the billing and shipping address have a country so that they will not be overridden by previous Orders
77 77
             //we do this to make sure that the previous address can not change the region and thereby destroy the order in the cart
78 78
             if ($billingAddress = $order->CreateOrReturnExistingAddress('BillingAddress')) {
79
-                if (! $billingAddress->Country || $force) {
79
+                if (!$billingAddress->Country || $force) {
80 80
                     $billingAddress->Country = $countryCode;
81 81
                     $billingAddress->write();
82 82
                 }
83 83
             }
84 84
             if ($shippingAddress = $order->CreateOrReturnExistingAddress('ShippingAddress')) {
85
-                if (! $shippingAddress->ShippingCountry || $force) {
85
+                if (!$shippingAddress->ShippingCountry || $force) {
86 86
                     $shippingAddress->ShippingCountry = $countryCode;
87 87
                     $shippingAddress->write();
88 88
                 }
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
             //if a country code and currency has been set then all is good
92 92
             //from there we keep it this way
93 93
             if (
94
-                $order->OriginatingCountryCode ==  $countryCode &&
94
+                $order->OriginatingCountryCode == $countryCode &&
95 95
                 $order->CurrencyUsedID == $currencyObject->ID
96 96
             ) {
97 97
                 return true;
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
                 if ($items) {
114 114
                     foreach ($items as $item) {
115 115
                         $buyable = $item->Buyable(true);
116
-                        if (! $buyable->canPurchase()) {
116
+                        if (!$buyable->canPurchase()) {
117 117
                             $item->delete();
118 118
                         }
119 119
                     }
@@ -161,10 +161,10 @@  discard block
 block discarded – undo
161 161
      */
162 162
     public function onAfterWrite()
163 163
     {
164
-        if(! $this->owner->DistributorID) {
165
-            if($defaultDistributor = Distributor::get_default_distributor()) {
166
-                if($defaultDistributor->exists()) {
167
-                    if($defaultDistributor->ID) {
164
+        if (!$this->owner->DistributorID) {
165
+            if ($defaultDistributor = Distributor::get_default_distributor()) {
166
+                if ($defaultDistributor->exists()) {
167
+                    if ($defaultDistributor->ID) {
168 168
                         $this->owner->DistributorID = $defaultDistributor->ID;
169 169
                         $this->owner->write();
170 170
                     }
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 
181 181
     public function canEdit($member = null)
182 182
     {
183
-        if (! $member) {
183
+        if (!$member) {
184 184
             $member = Member::currentUser();
185 185
         }
186 186
         if ($member) {
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
                 $countryMessageObject->CountrySpecificEmailMessage
292 292
             );
293 293
         }
294
-        if($step->SendEmailToDistributor) {
294
+        if ($step->SendEmailToDistributor) {
295 295
             if ($distributor = $this->owner->Distributor()) {
296 296
                 $distributorEmail = $distributor->Email;
297 297
                 if ($distributorEmail) {
Please login to merge, or discard this patch.
code/model/money/CountryPrice_EcommerceCurrency.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -44,10 +44,10 @@  discard block
 block discarded – undo
44 44
             $currencyCode = isset($currencyPerCountry[$countryCode]) ? $currencyPerCountry[$countryCode] : EcommerceCurrency::default_currency_code();
45 45
             $currencyDO = EcommerceCurrency::get_one_from_code($currencyCode);
46 46
         }
47
-        if (! $currencyDO) {
47
+        if (!$currencyDO) {
48 48
             $currencyDO = EcommerceCurrency::create_new($currencyCode);
49 49
         }
50
-        if (! $currencyDO) {
50
+        if (!$currencyDO) {
51 51
             $currencyDO = EcommerceCurrency::get_default();
52 52
         }
53 53
         return $currencyDO;
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
     {
68 68
         $cachekey = "EcommerceCurrencyCountryMatrix";
69 69
         $cache = SS_Cache::factory('CountryPrice_EcommerceCurrency');
70
-        if (! ($serializedArray = $cache->load($cachekey))) {
70
+        if (!($serializedArray = $cache->load($cachekey))) {
71 71
             $countries = CountryPrice_EcommerceCountry::get_real_countries_list();
72 72
             $unserializedArray = array();
73 73
             $defaultCurrencyCode = EcommerceCurrency::default_currency_code();
@@ -128,8 +128,8 @@  discard block
 block discarded – undo
128 128
             return null;
129 129
         }
130 130
         $key = $this->owner->ClassName.'____'.$countryCode;
131
-        if (! isset(self::$_money_object_currency[$key])) {
132
-            if(is_null($currencyCode)){
131
+        if (!isset(self::$_money_object_currency[$key])) {
132
+            if (is_null($currencyCode)) {
133 133
                 $currency = CountryPrice_EcommerceCurrency::get_currency_for_country($countryCode);
134 134
                 if ($currency) {
135 135
                     $currencyCode = strtoupper($currency->Code);
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -133,8 +133,7 @@
 block discarded – undo
133 133
                 $currency = CountryPrice_EcommerceCurrency::get_currency_for_country($countryCode);
134 134
                 if ($currency) {
135 135
                     $currencyCode = strtoupper($currency->Code);
136
-                }
137
-                else {
136
+                } else {
138 137
                     return null;
139 138
                 }
140 139
             }
Please login to merge, or discard this patch.