Skip to main content

Posts

Showing posts from January 29, 2023

How to add & remove items from Shopping Cart- Add to Cart - Remove From Cart - Node JS, Express js , Java Script

  Suppose we have 3 Birthday Cakes in our database as a product - and we want to get item added & removed by customer -   Before adding into cart we have to show Products(cakes) to customer using following code -  Note - Create Your Own Roues, Controller & Models and Import it here //UserRouter.js //Middleware to get cake list to send on menu.ejs var Bcakes ; router . use ( "/menu" ,( req , res , next ) => {     IndexController . fetchProducts ({ "catnm" : "birthday cake" }). then (( result ) => {     Bcakes = result ;       next ();   }). catch (( err ) => {     console . log ( err );   }); }) router . use ( "/" ,( req , res , next ) => {   IndexController . fetchProducts ({ "catnm" : "birthday cake" }). then (( result ) => {   Bcakes = result ;     next (); }). catch (( err ) => {   console . log ( err ); }); }) //============Middle Ware end =============== import ProductSchemaModel from &#

HOW TO INCREASE AND DECREASE TOTAL PRICE BY PRODUCT QUANTITY - SHOPPING CART - NODE JS, EXPRESS JS

< html > < td data-th = "Quantity" class = 'addtocart1' >       < input type = "hidden" id = "pricecounter" value = " < %- cDetails[i].price %>" >                             < b > < input type = "number" id = "qty"   class = "form-control text-center" min = "0" max = "10" value = "1" > </ b >   </ td >   < script > $ ( document ). ready ( function (){         //============= Product Quantity Start ===========         var priceCount = $ ( '#pricecounter' ). val ();         //var qty = $('#qty').val();         var counts = 0 ;         $ ( ".addtocart1" ). change ( function () {             var qty = $ ( '#qty' ). val ();                                                           $ ( ".cart-counter1" ). animate ({                   opacity: 1                  

How to Remove random object from Array using value - Java Script, Node Js ,Express Js

To remove Random object we need Index Number of that object -  //here Vasu is array name - var index = vasu . findIndex ( x => x . _id === "1" ); // find Index by Property & its value       console . log ( index )       if ( index >= 0 ) {         vasu . splice ( index , 1 ); //1st parameter is Index number & 2nd is Remove count       }