Skip to content
Permalink
Browse files
Add files via upload
  • Loading branch information
sadasivamm committed Nov 2, 2022
1 parent 810d5a1 commit 44110618746a20e45ec46ea5bee60b8703d418e9
Show file tree
Hide file tree
Showing 18 changed files with 166 additions and 0 deletions.
@@ -0,0 +1,99 @@
body{
background-color: hsl(0, 0%, 98%);
}

h1,h2,h3,h4,h5,h6{
color:hsl(0, 0%, 30%);
}

.box-element{
box-shadow:hsl(0, 0%, 80%) 0 0 16px;
background-color: #fff;
border-radius: 4px;
padding: 10px;
}

.thumbnail{
width: 100%;
height: 200px;
-webkit-box-shadow: -1px -3px 5px -2px rgba(214,214,214,1);
-moz-box-shadow: -1px -3px 5px -2px rgba(214,214,214,1);
box-shadow: -1px -3px 5px -2px rgba(214,214,214,1);
}

.product{
border-radius: 0 0 4px 4px;
}

.bg-dark{
background-color: #4f868c!important;
}

#cart-icon{
width:25px;
display: inline-block;
margin-left: 15px;
}

#cart-total{
display: block;
text-align: center;
color:#fff;
background-color: red;
width: 20px;
height: 25px;
border-radius: 50%;
font-size: 14px;
}

.col-lg-4, .col-lg-6, .col-lg-8, .col-lg-12{
margin-top: 10px;
}

.btn{
border-radius: 0;
}

.row-image{
width: 100px;
}

.form-field{
width:250px;
display: inline-block;
padding: 5px;
}

.cart-row{
display: flex;
align-items: flex-stretch;
padding-bottom: 10px;
margin-bottom: 10px;
border-bottom: 1px solid #ececec;

}

.quantity{
display: inline-block;
font-weight: 700;
padding-right:10px;


}

.chg-quantity{
width: 12px;
cursor: pointer;
display: block;
margin-top: 5px;
transition:.1s;
}

.chg-quantity:hover{
opacity: .6;
}


.hidden{
display: none!important;
}
BIN +9.82 KB static/images/acer.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN +89.8 KB static/images/cart.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN +6.6 KB static/images/el1.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN +4.94 KB static/images/hp1.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN +5.6 KB static/images/hp2.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,67 @@
var updateBtns = document.getElementsByClassName('update-cart')

for (var i =0; i < updateBtns.length; i++){
updateBtns[i].addEventListener('click', function()
{
var productId = this.dataset.product
var action= this.dataset.action
console.log('productId:', productId, 'action:', action)

console.log('USER:', user)
if (user === 'AnonymousUser'){
addCookieItem(productId, action)


}else{
updateUserOrder(productId, action)
}
})

}

function addCookieItem(productId, action){
console.log('Not logged in!....')
if (action == 'add'){
if(cart[productId] == undefined){
cart[productId] = {'quantity':1}

}else{
cart[productId]['quantity'] += 1
}
}
if (action == 'remove'){
cart[productId]['quantity'] -= 1
if(cart[productId]['quantity']<= 0){
console.log('Remove Item')
delete cart[productId]
}
}
console.log('Cart:', cart)
document.cookie = 'cart=' + JSON.stringify(cart) + ";domain=;path=/"
location.reload()

}

function updateUserOrder(productId, action){
console.log('logged in. Sending Data')
var url ='/update_item/'

fetch(url,{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': csrftoken
},
body:JSON.stringify({ 'productId':productId, 'action':action})
})
.then((response) =>{
return response.json()

})
.then((data) =>{
console.log('data:', data)
location.reload()

})

}

0 comments on commit 4411061

Please sign in to comment.