You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: classes/controller/FrontController.php
+15-2Lines changed: 15 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -284,6 +284,16 @@ public function init()
284
284
thrownewPrestaShopException($this->trans('Current theme is unavailable. Please check your theme\'s directory name ("%s") and permissions.', [htmlspecialchars(basename(rtrim(_PS_THEME_DIR_, '/\\')))], 'Admin.Design.Notification'));
285
285
}
286
286
287
+
/*
288
+
* Here, we resolve the context->country, the default country that will be used to display
289
+
* prices, taxes, delivery options and other country specific data.
290
+
*
291
+
* The country may further change further down in this method, if we have a cart with an address assigned to it.
292
+
* If there is a cart already, the context country is set to the country of that cart.
293
+
*
294
+
* If you are looking to override the country selection logic, you can use actionFrontControllerInitBefore above
295
+
* and pre-set the things in beforehand.
296
+
*/
287
297
if (Configuration::get('PS_GEOLOCATION_ENABLED')) {
288
298
if (($new_default = $this->geolocationManagement($this->context->country)) && Validate::isLoadedObject($new_default)) {
289
299
$this->context->country = $new_default;
@@ -459,10 +469,13 @@ public function init()
459
469
460
470
Product::initPricesComputation();
461
471
472
+
/*
473
+
* If there is an address assigned to the cart in context, the context->country MUST be set to the country of that address.
474
+
* We use delivery or invoice address, depending on PS_TAX_ADDRESS_TYPE configuration.
475
+
*/
462
476
if (isset($cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) && $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) {
0 commit comments