Skip to content
This repository was archived by the owner on Dec 5, 2023. It is now read-only.

Commit 3fad5ed

Browse files
Merge pull request #87 from rberlind/master
modified customer-orders.html to support full URLs and modified basket.html
2 parents bdc6f3f + d87d89f commit 3fad5ed

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

public/basket.html

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ <h1>Shopping cart</h1>
119119
<div class="box">
120120
<div class="box-header">
121121
<h4 style="display: inline;">Shipping Address</h4>
122-
<p style="display: inline; float: right;">
123-
<a data-toggle="modal" data-target="#address-modal" href="#change">Change</a>
122+
<p id="add_shipping" style="display: inline; float: right;">
123+
<a data-toggle="modal" data-target="#address-modal" href="#add">Add</a>
124124
</p>
125125
</div>
126126
<p id="address"></p>
@@ -170,8 +170,8 @@ <h4 class="modal-title" id="Login">Address</h4>
170170
<div class="box">
171171
<div class="box-header">
172172
<h4 style="display: inline;">Payment</h4>
173-
<p style="display: inline; float: right;">
174-
<a data-toggle="modal" data-target="#card-modal" href="#change">Change</a>
173+
<p id="add_payment" style="display: inline; float: right;">
174+
<a data-toggle="modal" data-target="#card-modal" href="#add">Add</a>
175175
</p>
176176
</div>
177177
<p id="number"></p>
@@ -366,6 +366,7 @@ <h4>Coupon code</h4>
366366
var cartTotal = 0;
367367
var numItemsInCart = 0;
368368
var shipping = 4.99;
369+
var orderPlaced = false;
369370
$.each(data, function (index, element) {
370371
if (element != null && element.itemId != null && element.itemId != "null") {
371372
$.getJSON('/catalogue/' + element.itemId, function (data) {
@@ -405,6 +406,8 @@ <h4>Coupon code</h4>
405406
});
406407
} else {
407408
$('#orderButton').click(function(event) {
409+
if (orderPlaced == false) {
410+
orderPlaced = true;
408411
return order();
409412
});
410413
}
@@ -423,8 +426,10 @@ <h4>Coupon code</h4>
423426
$.getJSON('/card', function(data) {
424427
if (data.status_code !== 500) {
425428
$("p#number").text("Card ending in " + data.number).css("color", "black");
429+
$("#add_payment").hide();
426430
} else {
427431
$("p#number").text("No credit card saved for user.").css("color", "red");
432+
$("#add_payment").show();
428433
}
429434
});
430435

@@ -439,8 +444,10 @@ <h4>Coupon code</h4>
439444
text += "</br>";
440445
text += data.country;
441446
$("p#address").html(text).css("color", "black");
447+
$("#add_shipping").hide();
442448
} else {
443449
$("p#address").text("No address saved for user.").css("color", "red");
450+
$("#add_shipping").show();
444451
}
445452
});
446453

public/customer-orders.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ <h1>My orders</h1>
177177
<span class="label label-success">Shipped</span>\
178178
</td>\
179179
<td>\
180-
<a href="customer-order.html?order=' + selfRef.replace("http://orders", "") + '" class="btn btn-primary btn-sm">View</a>\
180+
<a href="customer-order.html?order=' + selfRef.replace(/http:\/\/(.*)\/orders/, "/orders") + '" class="btn btn-primary btn-sm">View</a>\
181181
</td>\
182182
</tr>');
183183
});

0 commit comments

Comments
 (0)