PluginProbe
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments / 4.4.1
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments v4.4.1
4.7.2 4.7.1 4.7.0 4.6.6 4.6.5 4.6.4 4.6.3 4.6.2 4.6.1 4.6.0 4.5.1 4.5.0 4.4.2 4.4.1 4.4.0 4.3.3 4.3.2 4.3.1 4.3.0 4.2.3 4.2.2 4.2.1 1.0.3 1.0.4 1.0.5 All 281 releases
surecart / app / src / Middleware / AccountClaimMiddleware.php
AccountClaimMiddleware.php
35 lines 1021 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace SureCart\Middleware;
4
5 use Closure;
6 use SureCart\Models\Account;
7 use SureCartCore\Requests\RequestInterface;
8
9 /**
10 * Middleware for handling model archiving.
11 */
12 class AccountClaimMiddleware {
13 /**
14 * Handle the middleware.
15 *
16 * @param RequestInterface $request Request.
17 * @param Closure $next Next.
18 * @param string $model_name Model name.
19 * @return function
20 */
21 public function handle( RequestInterface $request, Closure $next ) {
22 $account = Account::find();
23
24 if ( $account->claimed ) {
25 // clear the account cache.
26 \SureCart::account()->clearCache();
27 // render success.
28 return \SureCart::redirect()->to( esc_url_raw( add_query_arg( [ 'account_claimed_success' => true ], \SureCart::routeUrl( 'dashboard.show' ) ) ) );
29 }
30
31 // redirect back here to handle invalidating cache.
32 return \SureCart::redirect()->to( esc_url_raw( add_query_arg( [ [ 'onboarding' => [ 'return_url' => \SureCart::routeUrl( 'account.claim' ) ] ] ], $account->claim_url ) ) );
33 }
34 }
35