Middleware Added
This commit is contained in:
parent
40d815d39b
commit
ea4954361f
|
|
@ -31,7 +31,7 @@ class Kernel extends HttpKernel
|
|||
\Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
|
||||
'api' => [
|
||||
|
|
@ -56,5 +56,6 @@ class Kernel extends HttpKernel
|
|||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'cart.merger' => \Webkul\Checkout\Http\Middleware\CartMerger::class,
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Checkout\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
|
||||
class CartMerger
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
\Cart::mergeDeactivatedCart();
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
|
|
@ -59,8 +59,6 @@ class ProductsCategoriesProxyController extends Controller
|
|||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
\Cart::mergeDeactivatedCart();
|
||||
|
||||
$slugOrPath = trim($request->getPathInfo(), '/');
|
||||
|
||||
$slugOrPath = urldecode($slugOrPath);
|
||||
|
|
|
|||
|
|
@ -112,7 +112,19 @@ Route::group(['middleware' => ['web', 'locale', 'theme', 'currency']], function
|
|||
'view' => 'shop.products.index'
|
||||
])->name('shop.product.file.download');
|
||||
|
||||
//customer routes starts here
|
||||
/**
|
||||
* Cart merger middleware. This middleware will take care of the items
|
||||
* which are deactivated at the time of buy now functionality. If somehow
|
||||
* user redirects without completing the checkout then this will merge
|
||||
* full cart.
|
||||
*
|
||||
* If some routes are not able to merge the cart, then place the route in this
|
||||
* group.
|
||||
*/
|
||||
Route::group(['middleware' => ['cart.merger']], function () {
|
||||
/**
|
||||
* Customer routes.
|
||||
*/
|
||||
Route::prefix('customer')->group(function () {
|
||||
// forgot Password Routes
|
||||
// Forgot Password Form Show
|
||||
|
|
@ -301,7 +313,6 @@ Route::group(['middleware' => ['web', 'locale', 'theme', 'currency']], function
|
|||
});
|
||||
});
|
||||
});
|
||||
//customer routes end here
|
||||
|
||||
Route::get('page/{slug}', 'Webkul\CMS\Http\Controllers\Shop\PagePresenterController@presenter')->name('shop.cms.page');
|
||||
|
||||
|
|
@ -311,4 +322,5 @@ Route::group(['middleware' => ['web', 'locale', 'theme', 'currency']], function
|
|||
'category_view' => 'shop::products.index'
|
||||
])
|
||||
->name('shop.productOrCategory.index');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,6 +2,32 @@
|
|||
|
||||
Route::group(['middleware' => ['web', 'locale', 'theme', 'currency']], function () {
|
||||
Route::namespace('Webkul\Velocity\Http\Controllers\Shop')->group(function () {
|
||||
|
||||
/**
|
||||
* Cart merger middleware. This middleware will take care of the items
|
||||
* which are deactivated at the time of buy now functionality. If somehow
|
||||
* user redirects without completing the checkout then this will merge
|
||||
* full cart.
|
||||
*
|
||||
* If some routes are not able to merge the cart, then place the route in this
|
||||
* group.
|
||||
*/
|
||||
Route::group(['middleware' => ['cart.merger']], function () {
|
||||
Route::group(['middleware' => ['customer']], function () {
|
||||
Route::get('/customer/account/comparison', 'ComparisonController@getComparisonList')
|
||||
->name('velocity.customer.product.compare')
|
||||
->defaults('_config', [
|
||||
'view' => 'shop::customers.account.compare.index'
|
||||
]);
|
||||
});
|
||||
|
||||
Route::put('/comparison', 'ComparisonController@addCompareProduct')
|
||||
->name('customer.product.add.compare');
|
||||
|
||||
Route::delete('/comparison', 'ComparisonController@deleteComparisonProduct')
|
||||
->name('customer.product.delete.compare');
|
||||
});
|
||||
|
||||
Route::get('/product-details/{slug}', 'ShopController@fetchProductDetails')
|
||||
->name('velocity.shop.product');
|
||||
|
||||
|
|
@ -34,20 +60,6 @@ Route::group(['middleware' => ['web', 'locale', 'theme', 'currency']], function
|
|||
'view' => 'shop::guest.compare.index'
|
||||
]);
|
||||
|
||||
Route::group(['middleware' => ['customer']], function () {
|
||||
Route::get('/customer/account/comparison', 'ComparisonController@getComparisonList')
|
||||
->name('velocity.customer.product.compare')
|
||||
->defaults('_config', [
|
||||
'view' => 'shop::customers.account.compare.index'
|
||||
]);
|
||||
});
|
||||
|
||||
Route::put('/comparison', 'ComparisonController@addCompareProduct')
|
||||
->name('customer.product.add.compare');
|
||||
|
||||
Route::delete('/comparison', 'ComparisonController@deleteComparisonProduct')
|
||||
->name('customer.product.delete.compare');
|
||||
|
||||
Route::get('/items-count', 'ShopController@getItemsCount')
|
||||
->name('velocity.product.item-count');
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue