Skip to content

Commit

Permalink
Merge pull request Open-Source-Chandigarh#13 from lovishGIT/main
Browse files Browse the repository at this point in the history
issue#6 and issue#7 done.
  • Loading branch information
Kavyam172 authored Oct 23, 2023
2 parents f3e79ea + 3b8fd10 commit dfd1792
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 43 deletions.
6 changes: 6 additions & 0 deletions menu.css
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,10 @@ div.col h3{
.cartsidebar{
background-color: black;
width: 100px;
}

.flex-menu {
display: flex;
justify-content: space-between;
gap: 1px;
}
22 changes: 11 additions & 11 deletions menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,52 +103,52 @@ <h1 class="text-bg-dark">CAFE MENU</h1>
<tr>
<th>ITEMS</th>
<th style="width:117px">PRICE</th>
<th style="width: 100px;"></th>
<th style="width: 120px;"></th>
</tr>
</thead>
<tbody>
<tr>
<td id="itemi1">Hot Coffee</td>
<td id="pricei1">Rs.80</td>
<td id="ri1" class="add"><button id="i1" class="btn cart" type="button">Add</button></td>
<td id="ri1" class="add flex-menu"><button id="i1" class="btn cart" type="button">Add</button></td>
</tr>
<tr>
<td id="itemi2">Black Coffee</td>
<td id="pricei2">Rs.80</td>
<td id="ri2" class="add"><button id="i2" class="btn cart" type="button">Add</button></td>
<td id="ri2" class="add flex-menu"><button id="i2" class="btn cart" type="button">Add</button></td>
</tr>
<tr>
<td id="itemi3">Hazelnut Cold Coffee</td>
<td id="pricei3">Rs.125</td>
<td id="ri3" class="add"><button id="i3" class="btn cart" type="button">Add</button></td>
<td id="ri3" class="add flex-menu"><button id="i3" class="btn cart" type="button">Add</button></td>
</tr>
<tr>
<td id="itemi4">Chocolate Cold Coffee</td>
<td id="pricei4">Rs.125</td>
<td id="ri4" class="add"><button id="i4" class="btn cart" type="button">Add</button></td>
<td id="ri4" class="add flex-menu"><button id="i4" class="btn cart" type="button">Add</button></td>
</tr>
<tr>
<td id="itemi5">Caramel Cold Coffee</td>
<td id="pricei5">Rs.125</td>
<td id="ri5" class="add"><button id="i5" class="btn cart" type="button">Add</button></td>
<td id="ri5" class="add flex-menu"><button id="i5" class="btn cart" type="button">Add</button></td>
</tr>
<tr>
<td id="itemi6">Classic Cold Coffee</td>
<td id="pricei6">Rs.100</td>
<td id="ri6" class="add"><button id="i6" class="btn cart" type="button">Add</button></td>
<td id="ri6" class="add flex-menu"><button id="i6" class="btn cart" type="button">Add</button></td>
</tr>
<tr>
<td id="itemi7">Iced Americano</td>
<td id="pricei7">Rs.160</td>
<td id="ri7" class="add">
<buttonn id="i7" class="btn cart" type="button">Add</buttonn>
<td id="ri7" class="add flex-menu">
<button id="i7" class="btn cart" type="button">Add</button>
</td>
</tr>
<tr>
<td id="itemi8">Maggie</td>
<td id="pricei8">Rs.30</td>
<td id="ri8" class="add">
<buttonn id="i8" class="btn cart" type="button">Add</buttonn>
<td id="ri8" class="add flex-menu">
<button id="i8" class="btn cart" type="button">Add</button>
</td>
</tr>
</tbody>
Expand Down
2 changes: 1 addition & 1 deletion menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function updatecart(cart){
document.getElementById("r"+item).innerHTML=`<button id="`+item+`" class="btn cart" type="button">Add</button>`;
}
else{
document.getElementById("r"+item).innerHTML="<button id='minus"+item+"' class='btn minus'>-</button><div id='val"+item+"' style='text-align:center;'>"+cart[item].quantity+"</div><button id='plus"+item+"' class='btn plus'>+</button>";
document.getElementById("r"+item).innerHTML=`<div><button id='minus${item}' class='btn minus'> -</button></div><div id='val${item}' style='font-size: 3vh;'> ${cart[item].quantity} </div> <div><button id='plus${item}' class='btn plus'>+ </button> </div>`;
}
}
localStorage.setItem('cart', JSON.stringify(cart));
Expand Down
8 changes: 8 additions & 0 deletions order.css
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,12 @@ body{
padding: 8px;
border-radius: 20px;
text-align: center;
}

.hide_as_link {
text-decoration: none;
color: #000000;
}
.hide_as_link :active {
color: #000000;
}
19 changes: 9 additions & 10 deletions order.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,15 @@
</div>
</div>
</nav>
<div class="container step1">
<div class="row">
<h2> Step 1 - My Awesome Cart Express Checkout - Review Your Cart items </h2>
<div class="row">
<div id="items">
<!-- items will be added here -->
</div>

</div>
</div>
<div class="container step1">
<a class="hide_as_link" href="./menu.html">
<h2> Step 1 - My Awesome Cart Express Checkout - Review Your Cart items </h2>
<div class="row">
<div id="items">
<!-- items will be added here -->
</div>
</div>
</a>
</div>
<div class="col my-4">
<h2> Step 2 - Enter Address & Other Details</h2>
Expand Down
37 changes: 16 additions & 21 deletions order.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,21 @@ $(document).ready(function () {
listcart(cart);
});
function listcart(cart) {
let str=``;
if (cart == {}) {
str += `<div id="default">
<span><h5>Your Cart is Empty........</h5></span>
let str_order=``;
for (let item in cart) {
str_order+=`<div class="row">
<div class="col">
`+cart[item].name+`
</div>
<div class="col">
x`+ cart[item].quantity +`
</div>
<div class="col">
= Rs.`+ (cart[item].price)*(cart[item].quantity) +`
</div>
</div>`
}
else{
for (let item in cart) {
str+=`<div class="row">
<div class="col">
`+cart[item].name+`
</div>
<div class="col">
x`+ cart[item].quantity +`
</div>
<div class="col">
= Rs.`+ (cart[item].price)*(cart[item].quantity) +`
</div>
</div>`
}
}
document.getElementById("items").innerHTML=str;
}

if(str_order == ``) str_order = `<h5 class='default'> Your Cart is Empty. Click here to Go to Menu </h5>`;
document.getElementById("items").innerHTML= str_order;
}

0 comments on commit dfd1792

Please sign in to comment.