Elektromarket/templates/checkout.html
2018-11-23 10:31:47 +01:00

71 lines
2.6 KiB
HTML

{{define "content"}}
<script type="text/javascript">
var pM = 1;
var dD = 0;
function calculatedelivery() {
var date = new Date();
var days = 2;
var dayOfWeek = date.getDay()
if (dayOfWeek == 4 || dayOfWeek == 5)
days = 4;
else if (dayOfWeek == 6)
days = 3;
date.setDate(date.getDate() + days);
document.getElementById("deliveryDate").innerHTML = date.toLocaleDateString();
dD = date.toLocaleDateString();
}
function paymentMethodChanged(v) {
pM = v;
var loanPaymentEl = document.getElementById("loanPayment");
switch (v) {
case "1":
loanPaymentEl.style.display = "none";
break;
case "2":
var price = parseInt({{.cart.PriceTotal}});
document.getElementById("loanPaymentinstallment").innerHTML = Math.round(100 * price/24) / 100;
loanPaymentEl.style.display = "block";
break;
}
}
function pay() {
var fN = document.getElementById("fname").value;
var lN = document.getElementById("lname").value;
if (fN!='' && lN!='')
location.href = '/paymentDone?fn=' + fN + '&ln=' + lN + "&pm=" + pM + "&dd=" + dD;
}
</script>
<h1>Podsumowanie</h1>
<div class="checkoutSummary">
<div class="checkoutSummaryColumn">Imię:</div>
<div class="checkoutSummaryColumn"><input required type="text" name="fname" id="fname" autocomplete="given-name"></div>
</div>
<div class="checkoutSummary">
<div class="checkoutSummaryColumn">Nazwisko:</div>
<div class="checkoutSummaryColumn"><input required type="text" name="lname" id="lname" autocomplete="family-name"></div>
</div>
<div class="checkoutSummary">
<div class="checkoutSummaryColumn">Metoda płatności:</div>
<div class="checkoutSummaryColumn">
<form id="paymentMethodRadio">
<input type="radio" name="payment" value="1" checked onchange="paymentMethodChanged(value)"> Gotówka/ karta
<input type="radio" name="payment" value="2" onchange="paymentMethodChanged(value)"> Raty 0% na 24 mies.
</form>
</div>
</div>
<div class="checkoutSummary">
<div class="checkoutSummaryColumn">Kwota zamówienia:</div>
<div class="checkoutSummaryColumn" id="paymentTotal">{{ .cart.PriceTotal }} zł</div>
</div>
<div class="checkoutPayment">
<div id="delivery">Data dostawy: <span id="deliveryDate"></span></div><br>
<div id="loanPayment" style="display: none;">Wysokość raty miesięcznej: <span id="loanPaymentinstallment">0</span><br><br></div>
<input type="button" value="Zapłać" onclick="pay();">
</div>
<script type="text/javascript">
calculatedelivery();
</script>
{{end}}