From 33d5841b58e2c7f8b69e07c404da809060f3dad6 Mon Sep 17 00:00:00 2001 From: Kumar Priyansh Date: Mon, 3 Jun 2019 06:19:30 +0530 Subject: Updated to check empty cart Value --- shared/cart.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/shared/cart.js b/shared/cart.js index bc8f509..8393565 100644 --- a/shared/cart.js +++ b/shared/cart.js @@ -19,9 +19,30 @@ $(document).ready(function(){ showAlert("Failed to sign out") }); }) + + var user; + firebase.auth().onAuthStateChanged(function(user) { if (!user) { window.location.replace('../') } + user = firebase.auth().currentUser; + + console.log(user) + + //Checking if Cart is Empty + + var cartRef = firebase.database().ref('userCart/' + user.uid); + cartRef.on('value', function(snapshot) { + if(snapshot.val() === null) { + showEmptyCart(); + } + }); + }); + + + + + }) \ No newline at end of file -- cgit v1.2.3