Multi site redirect based on location
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
- VirtualSpy
- Advanced
- Posts: 122
- Joined: 05 Jul 2022, 07:55
Multi site redirect based on location
laravel version 9.36.4 , Aimeos version 2022.10.3 and PHP version 8.1.3 (Win)
Multi site automatically redirect on default site so i want redirect multi site based on location please tell me is it possible and what will it's process.
Multi site automatically redirect on default site so i want redirect multi site based on location please tell me is it possible and what will it's process.
Re: Multi site redirect based on location
What is "location" in terms of what you know from the user? IP? Zip code?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
- VirtualSpy
- Advanced
- Posts: 122
- Joined: 05 Jul 2022, 07:55
Re: Multi site redirect based on location
You should implement a redirect for the home page ("/") using a GeoIP database.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
- VirtualSpy
- Advanced
- Posts: 122
- Joined: 05 Jul 2022, 07:55
Re: Multi site redirect based on location
i tried like this
Code: Select all
$ip = \Request::ip();
$currentUserInfo = Location::get($ip);
if($currentUserInfo!==false) {
$country=$currentUserInfo->countryName;
}
if (config('app.shop_multishop')) {
if(isset($country)) {
if($country!=="India") {
$conf['prefix'] .= '/uae';
}
}
else {
$conf['prefix'] .= '/{site}';
$conf['where']['site'] = '[A-Za-z0-9\.\-]+';
}
}
if ($conf['prefix']) {
Route::get('/', function () use ($params) {
return redirect(airoute('aimeos_home', $params));
});
}
but it is not redirecting on uae site because it is redirecting from shop.php
Code: Select all
'mshop' => [
'locale' => [
'site' => 'in', // used instead of "default"
],
],
- VirtualSpy
- Advanced
- Posts: 122
- Joined: 05 Jul 2022, 07:55
Re: Multi site redirect based on location
i got this configVirtualSpy wrote: ↑03 Jan 2023, 04:55i tried like thisi am getting $conf['prefix'] = /uaeCode: Select all
$ip = \Request::ip(); $currentUserInfo = Location::get($ip); if($currentUserInfo!==false) { $country=$currentUserInfo->countryName; } if (config('app.shop_multishop')) { if(isset($country)) { if($country!=="India") { $conf['prefix'] .= '/uae'; } } else { $conf['prefix'] .= '/{site}'; $conf['where']['site'] = '[A-Za-z0-9\.\-]+'; } } if ($conf['prefix']) { Route::get('/', function () use ($params) { return redirect(airoute('aimeos_home', $params)); }); }
but it is not redirecting on uae site because it is redirecting from shop.phpplease tell me where this config is using or tell me other solutionCode: Select all
'mshop' => [ 'locale' => [ 'site' => 'in', // used instead of "default" ], ],
Code: Select all
'mshop' => [
'locale' => [
'site' => 'in', // used instead of "default"
],
],
- VirtualSpy
- Advanced
- Posts: 122
- Joined: 05 Jul 2022, 07:55
Re: Multi site redirect based on location
ok now i understand i should use redirect()->intended in place of airoute function.VirtualSpy wrote: ↑04 Jan 2023, 14:14i got this configVirtualSpy wrote: ↑03 Jan 2023, 04:55i tried like thisi am getting $conf['prefix'] = /uaeCode: Select all
$ip = \Request::ip(); $currentUserInfo = Location::get($ip); if($currentUserInfo!==false) { $country=$currentUserInfo->countryName; } if (config('app.shop_multishop')) { if(isset($country)) { if($country!=="India") { $conf['prefix'] .= '/uae'; } } else { $conf['prefix'] .= '/{site}'; $conf['where']['site'] = '[A-Za-z0-9\.\-]+'; } } if ($conf['prefix']) { Route::get('/', function () use ($params) { return redirect(airoute('aimeos_home', $params)); }); }
but it is not redirecting on uae site because it is redirecting from shop.phpplease tell me where this config is using or tell me other solutionCode: Select all
'mshop' => [ 'locale' => [ 'site' => 'in', // used instead of "default" ], ],
is using in airoute function of aimeos-laravel but can i overwrite or extend this function please tell meCode: Select all
'mshop' => [ 'locale' => [ 'site' => 'in', // used instead of "default" ], ],
Re: Multi site redirect based on location
Your route code also doesn't work because "/{site}" must be always the path prefix and "uae" is only a value for that placeholder. The correct code should look something like this:
Code: Select all
if (config('app.shop_multishop')) {
if(($currentUserInfo = Location::get(\Request::ip())) !== false
&& $currentUserInfo->countryName !== 'India') {
$param['site'] = 'uae';
}
$conf['prefix'] .= '/{site}';
$conf['where']['site'] = '[A-Za-z0-9\.\-]+';
}
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star