Something went wrong. Try again.
An E-Commerce Website built using Node.js, Express, Express Generator, MongoDB, and HandleBars Template Engine. Scope - Single Admin/Vendor…
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110<section> <div class="container">
<table class="table mt-5"> <thead> <tr> <th scope="col">SI No:</th> <th scope="col">Item</th> <th scope="col">Title</th> <th scope="col">Price</th> <th scope="col">Quantity</th> </tr> </thead> <tbody>
{{#each products}} <tr> {{!-- {{#each this.product}} --}} <th class="count"></th> <td><img style="height: 75px; width: auto;" src="/product-images/{{this.product._id}}.jpg"></td> <td>{{this.product.Name}}</td> <td>₹ {{this.product.Price}}</td> {{!-- {{/each}} --}} <td> <button class="cart-item-count btn btn-secondary px-3 mr-3" onclick="changeQuantity( '{{this._id}}' , '{{this.product._id}}' , '{{../user._id}}' , -1 )">-</button> <span id="{{this.product._id}}">{{this.quantity}}</span> <button class="cart-item-count btn btn-secondary px-3 ml-3" onclick="changeQuantity( '{{this._id}}' , '{{this.product._id}}' , '{{../user._id}}' , 1 )">+</button> </td> <td> <button class="btn btn-danger" onclick="removeCartProduct( '{{this._id}}' , '{{this.product._id}}' )">Remove</button> </td> </tr> {{/each}}
</tbody> </table>
<hr style="margin-top: 60px;"> <div class="float-right"> <h4 class="float-center mx-5 px-5 text-centered text-muted">Total : ₹ <span id="total">{{totalValue}}</span></h4> <a href="/place-order" style="width: 100%;" class="btn btn-success my-2 py-2">Place Order</a> </div> <hr style="margin-top: 125px;"> <hr style="margin-bottom: 80px;">
</div></section>
<script> function changeQuantity(cartId, prodId, userId, count) {
var quantity = parseInt(document.getElementById(prodId).innerHTML) count = parseInt(count) console.log(userId)
$.ajax({ url: '/change-product-quantity', method: 'POST', data: { cart: cartId, product: prodId, user: userId, count: count, quantity: quantity }, success: (response) => { if (response.removeProduct) { alert("Product removed from Cart:") location.reload() } else { console.log(response) document.getElementById(prodId).innerHTML = quantity + count document.getElementById('total').innerHTML = response.total } // alert(response) } }) }
function removeCartProduct(cartId, prodId) {
$.ajax({ url: '/remove-cart-product', method: 'POST', data: { cart: cartId, product: prodId }, success: () => { alert("Product removed from Cart:") location.reload() } }) }</script>
<style> table { counter-reset: section; }
.count:before { counter-increment: section; content: counter(section); }</style>