Skip to content

Commit 936afe5

Browse files
Pass locale across different steps (#347)
1 parent 9231d76 commit 936afe5

File tree

8 files changed

+28
-11
lines changed

8 files changed

+28
-11
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Its best to:
4848

4949
If you're forking the repository and wish to keep your copy up-to-date with the master, ensure you run this command:
5050

51-
`git remote add upstream [email protected]:osiset/laravel-shopify.git`
51+
`git remote add upstream [email protected]:Kyon147/laravel-shopify.git`
5252

5353
You can then update by simply running:
5454

src/Http/Middleware/Billable.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public function handle(Request $request, Closure $next)
4141
array_merge($request->input(), [
4242
'shop' => $shop->getDomain()->toNative(),
4343
'host' => $request->get('host'),
44+
'locale' => $request->get('locale'),
4445
])
4546
);
4647
}

src/Http/Middleware/VerifyScopes.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public function handle(Request $request, Closure $next)
4646
[
4747
'shop' => $shop->getDomain()->toNative(),
4848
'host' => $request->get('host'),
49+
'locale' => $request->get('locale'),
4950
]
5051
);
5152
}

src/Http/Middleware/VerifyShopify.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ protected function tokenRedirect(Request $request): RedirectResponse
305305
'shop' => ShopDomain::fromRequest($request)->toNative(),
306306
'target' => $target,
307307
'host' => $request->get('host'),
308+
'locale' => $request->get('locale'),
308309
]
309310
);
310311
}
@@ -320,7 +321,7 @@ protected function installRedirect(ShopDomainValue $shopDomain): RedirectRespons
320321
{
321322
return Redirect::route(
322323
Util::getShopifyConfig('route_names.authenticate'),
323-
['shop' => $shopDomain->toNative(), 'host' => request('host')]
324+
['shop' => $shopDomain->toNative(), 'host' => request('host'), 'locale' => request('locale')]
324325
);
325326
}
326327

src/Macros/TokenUrl.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public function generateParams(string $route, array $params = [], bool $absolute
2929
'shop' => ShopDomain::fromRequest(Request::instance())->toNative(),
3030
'target' => URL::route($route, $params, $absolute),
3131
'host' => Request::instance()->get('host'),
32+
'locale' => Request::instance()->get('locale'),
3233
],
3334
];
3435
}

src/Traits/AuthController.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public function authenticate(Request $request, AuthenticateShop $authShop)
6868
'authUrl' => $result['url'],
6969
'host' => $request->get('host'),
7070
'shopDomain' => $shopDomain,
71+
'locale' => $request->get('locale'),
7172
]
7273
);
7374
} else {
@@ -77,6 +78,7 @@ public function authenticate(Request $request, AuthenticateShop $authShop)
7778
[
7879
'shop' => $shopDomain->toNative(),
7980
'host' => $request->get('host'),
81+
'locale' => $request->get('locale'),
8082
]
8183
);
8284
}
@@ -100,11 +102,16 @@ public function token(Request $request)
100102
$params = Util::parseQueryString($query);
101103
$params['shop'] = $params['shop'] ?? $shopDomain->toNative() ?? '';
102104
$params['host'] = $request->get('host');
105+
$params['locale'] = $request->get('locale');
103106
unset($params['token']);
104107

105108
$cleanTarget = trim(explode('?', $target)[0].'?'.http_build_query($params), '?');
106109
} else {
107-
$params = ['shop' => $shopDomain->toNative() ?? '', 'host' => $request->get('host')];
110+
$params = [
111+
'shop' => $shopDomain->toNative() ?? '',
112+
'host' => $request->get('host'),
113+
'locale' => $request->get('locale'),
114+
];
108115
$cleanTarget = trim(explode('?', $target)[0].'?'.http_build_query($params), '?');
109116
}
110117

src/Traits/BillingController.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public function index(
6060
[
6161
'url' => $url,
6262
'host' => $host,
63+
'locale' => $request->get('locale'),
6364
'apiKey' => Util::getShopifyConfig('api_key', ShopDomain::fromNative($request->get('shop'))),
6465
]
6566
);
@@ -89,6 +90,7 @@ public function process(
8990
return Redirect::route(Util::getShopifyConfig('route_names.home'), [
9091
'shop' => $shop->getDomain()->toNative(),
9192
'host' => $host,
93+
'locale' => $request->get('locale'),
9294
]);
9395
}
9496
// Activate the plan and save
@@ -99,16 +101,20 @@ public function process(
99101
$host
100102
);
101103

104+
$data = [
105+
'shop' => $shop->getDomain()->toNative(),
106+
'host' => $host,
107+
'locale' => $request->get('locale'),
108+
];
109+
110+
if (!Util::useNativeAppBridge()) {
111+
$data['billing'] = $result ? 'success' : 'failure';
112+
}
113+
102114
// Go to homepage of app
103115
return Redirect::route(
104116
Util::getShopifyConfig('route_names.home'),
105-
array_merge([
106-
'shop' => $shop->getDomain()->toNative(),
107-
'host' => $host,
108-
], Util::useNativeAppBridge() ? [] : [
109-
'host' => $host,
110-
'billing' => $result ? 'success' : 'failure',
111-
])
117+
$data
112118
)->with(
113119
$result ? 'success' : 'failure',
114120
'billing'

src/resources/config/shopify-app.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@
351351
| in this configuration file is unnecessary.
352352
|
353353
| If you register the listeners manually again here, the listener will be called twice.
354-
|
354+
|
355355
| If you plan to store your listeners in a different directory like `App\Shopify\Listeners`
356356
| or within multiple directories, then you should register them here.
357357
|

0 commit comments

Comments
 (0)