Sunday 7 March 2021

Part 31: Removing Items From Cart

# 5 Minutes Of Reading In this article I will show you removing item from cart. But before fix issue of Cart controller index view which is not updating item count properly.
Run application again and update cart quantity.
Currently count is 2 and I made it 4 using quantity field from index view of Cart controller shown above highlighted. Click on add button (+).
It is working as expected now.
ā€ƒ Open Cart controller and add below piece of code.
Open Index view of cart controller and update below highlighted piece of code.
Run application and check browser window. Click on remove button
Item from cart deleted successfully but Index view of Cart controller not updated after deleting item from cart and still shown cart item on index page. Refresh browser window and you observe now Index page updated and showing no item.
Index automatically gets refreshed once item deleted successfully from cart. Open cart controller and modify shown in below screen.
Add empty view for load cart and create view as partial view shown below.
ā€ƒ Add below code in load cart item or just copied razor code from index view of cart controller and verify with below screen.
Open Index action of Cart controller and update razor code shown below. Now Iā€™m using partial view to load cart items and ajax jquery function to load partial view in HTML div (dvCart) available in Index view of cart controller.
Now run application add item in cart if not and click on remove item from Cart index view. This time it will refresh page and show you updated items on Index page of cart controller. ā€ƒ I have added two items in my cart.
Click on Remove button highlighted.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home