#93 Make E-commerce in Laravel 8 | Shopping Cart (VI) | Update Cart Item's Quantity via Ajax
Автор: Stack Developers
Загружено: 2020-11-12
Просмотров: 1904
Описание:
In Part-93 of Advance E-com Series in Laravel 6/7/8, we will continue working on the Cart Page and update cart item quantity with Ajax.
1) Update front_script.js file :-
Get current quantity, cart item id and plus/minus in Jquery and pass via Ajax to update-cart-item-qty route to pass further to function to update the cart.
2) Create Route :-
Now create post route for updating cart item quantity in web.php file like below :-
// Update Cart Item Quantity
Route::post('/update-cart-item-qty','ProductsController@updateCartItemQty');
3) Create updateCartItemQty function :-
Now create updateCartItemQty function at Front/ProductsController to get the cart id and new quantity of cart item that we require to update.
4) Add Header Statement :-
Add below header statement at top of ProductsController :-
use Illuminate\Support\Facades\View;
5) Update front_script.js file :-
Update front_script.js file once again to get response in Ajax and show updated cart items by calling it within success function.
Now you can see we able to update quantity of cart items with Ajax without refreshing the page.
In next video, we will add some necessary checks and show error/success messages.
Join this channel to get access to perks:
/ @stackdevelopers
Повторяем попытку...

Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: