@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | //provided by stealth ... |
| 29 | 29 | $countryObject = CountryPrice_EcommerceCountry::get_real_country(); |
| 30 | 30 | |
| 31 | - if($countryObject) { |
|
| 31 | + if ($countryObject) { |
|
| 32 | 32 | |
| 33 | 33 | //check if a redirect is required ... |
| 34 | 34 | $this->checkForOffsiteRedirects($countryObject); |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | $oldURL = $protocol.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; |
| 95 | 95 | |
| 96 | 96 | $hasCountrySegment = CountryPrice_Translation::get_country_url_provider()->hasCountrySegment($oldURL); |
| 97 | - if($hasCountrySegment){ |
|
| 97 | + if ($hasCountrySegment) { |
|
| 98 | 98 | $newURL = CountryPrice_Translation::get_country_url_provider()->replaceCountryCodeInUrl($countryCode, $oldURL); |
| 99 | 99 | } |
| 100 | 100 | else { |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | public function AlternativeHrefLangLinksCachingKey() |
| 150 | 150 | { |
| 151 | 151 | $countryObject = CountryPrice_EcommerceCountry::get_real_country(); |
| 152 | - if($countryObject && $countryObject->Code) { |
|
| 152 | + if ($countryObject && $countryObject->Code) { |
|
| 153 | 153 | return 'AlternativeHrefLangLinksCachingKey-'.$countryObject->Code.'-'.$this->owner->dataRecord->ID.'-'.strtotime($this->owner->dataRecord->LastEdited); |
| 154 | 154 | } |
| 155 | 155 | return 'AlternativeHrefLangLinksCachingKey'.$this->owner->dataRecord->ID.'-'.$this->owner->dataRecord->ID.'-'.strtotime($this->owner->dataRecord->LastEdited); |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | public function UpdateCanonicalLink(&$link) |
| 163 | 163 | { |
| 164 | 164 | $obj = $this->owner->dataRecord->CanonicalObject(); |
| 165 | - if($obj) { |
|
| 165 | + if ($obj) { |
|
| 166 | 166 | $link = $obj->Link(); |
| 167 | 167 | } else { |
| 168 | 168 | $link = $this->owner->dataRecord->AbsoluteLink(); |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | 'Root.FAQPage', |
| 89 | 89 | new LiteralField( |
| 90 | 90 | "FAQPageExplanation", |
| 91 | - "<p class=\"message warning\">FAQ information can only be added to the main country for a ". _t('Distributor.SINGULAR_NAME', 'Distributor') ."</p>" |
|
| 91 | + "<p class=\"message warning\">FAQ information can only be added to the main country for a "._t('Distributor.SINGULAR_NAME', 'Distributor')."</p>" |
|
| 92 | 92 | ) |
| 93 | 93 | ); |
| 94 | 94 | } |
@@ -198,21 +198,21 @@ discard block |
||
| 198 | 198 | public static function get_real_country($country = null) |
| 199 | 199 | { |
| 200 | 200 | |
| 201 | - if($country && $country instanceof EcommerceCountry) { |
|
| 201 | + if ($country && $country instanceof EcommerceCountry) { |
|
| 202 | 202 | $cacheKey = $country->Code; |
| 203 | - } elseif($country) { |
|
| 203 | + } elseif ($country) { |
|
| 204 | 204 | $cacheKey = $country; |
| 205 | 205 | } else { |
| 206 | 206 | $cacheKey = 'notprovided'; |
| 207 | 207 | } |
| 208 | - if(isset(self::$_get_real_country_cache[$cacheKey]) && self::$_get_real_country_cache[$cacheKey]) { |
|
| 208 | + if (isset(self::$_get_real_country_cache[$cacheKey]) && self::$_get_real_country_cache[$cacheKey]) { |
|
| 209 | 209 | |
| 210 | 210 | } else { |
| 211 | 211 | //save original - just in case... |
| 212 | 212 | $originalCountry = $country; |
| 213 | 213 | |
| 214 | 214 | //no country provided |
| 215 | - if (! $country) { |
|
| 215 | + if (!$country) { |
|
| 216 | 216 | $param = Config::inst()->get('CountryPrice_Translation', 'locale_get_parameter'); |
| 217 | 217 | |
| 218 | 218 | // 1. CHECK FROM URL |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | |
| 226 | 226 | //now we check it from order / session .... |
| 227 | 227 | $order = ShoppingCart::current_order(); |
| 228 | - if($order && $order->exists()) { |
|
| 228 | + if ($order && $order->exists()) { |
|
| 229 | 229 | Session::clear('temporary_country_order_store'); |
| 230 | 230 | $countryCode = $order->getCountry(); |
| 231 | 231 | } else { |
@@ -233,30 +233,30 @@ discard block |
||
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | //if we still dont have a country then we use the standard e-commerce methods ... |
| 236 | - if(! $countryCode) { |
|
| 236 | + if (!$countryCode) { |
|
| 237 | 237 | $countryCode = EcommerceCountry::get_country(); |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | //lets make our object! |
| 241 | - if($countryCode) { |
|
| 241 | + if ($countryCode) { |
|
| 242 | 242 | $country = DataObject::get_one('EcommerceCountry', ['Code' => $countryCode]); |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - if($country && $country instanceof EcommerceCountry) { |
|
| 245 | + if ($country && $country instanceof EcommerceCountry) { |
|
| 246 | 246 | //do nothing |
| 247 | 247 | } else { |
| 248 | 248 | $country = null; |
| 249 | 249 | } |
| 250 | 250 | //IF THE COUNTRY DOES NOT MATCH THE URL COUNTRY THEN THE URL WINS!!!! |
| 251 | - if($urlCountryCode) { |
|
| 251 | + if ($urlCountryCode) { |
|
| 252 | 252 | if ( |
| 253 | 253 | ($country && $country->Code !== $urlCountryCode) |
| 254 | 254 | || |
| 255 | - ! $country |
|
| 255 | + !$country |
|
| 256 | 256 | |
| 257 | - ){ |
|
| 257 | + ) { |
|
| 258 | 258 | $country = DataObject::get_one('EcommerceCountry', ['Code' => $urlCountryCode]); |
| 259 | - if($country) { |
|
| 259 | + if ($country) { |
|
| 260 | 260 | //change country Object |
| 261 | 261 | //reset everything ... |
| 262 | 262 | CountryPrices_ChangeCountryController::set_new_country($country); |
@@ -326,9 +326,9 @@ discard block |
||
| 326 | 326 | public static function get_backup_country() |
| 327 | 327 | { |
| 328 | 328 | $obj = EcommerceCountry::get()->filter(array("IsBackupCountry" => true))->first(); |
| 329 | - if (! $obj) { |
|
| 329 | + if (!$obj) { |
|
| 330 | 330 | $obj = EcommerceCountry::get()->filter(array("Code" => EcommerceConfig::get('EcommerceCountry', 'default_country_code')))->first(); |
| 331 | - if (! $obj) { |
|
| 331 | + if (!$obj) { |
|
| 332 | 332 | $obj = EcommerceCountry::get()->first(); |
| 333 | 333 | } |
| 334 | 334 | } |
@@ -107,11 +107,11 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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) { |
@@ -101,7 +101,7 @@ discard block |
||
| 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 |
||
| 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 | ); |
@@ -50,7 +50,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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) { |