Skip to content

Instantly share code, notes, and snippets.

@RajeshReddyM
Created December 19, 2015 01:38
Show Gist options
  • Select an option

  • Save RajeshReddyM/b931610d32041aec6fa2 to your computer and use it in GitHub Desktop.

Select an option

Save RajeshReddyM/b931610d32041aec6fa2 to your computer and use it in GitHub Desktop.
Review JavaScript Code
function receipt(order) {
var p;
switch (order.payment_type) {
case "creditcard":
p = "Payment info: " + order.payment.getCardType + " " + order.payment.card_number; //card type(VISA/MasterCard etc.) and number)
break;
case "paypal":
p = "Payment info: " + order.payment.paypal_info;
break;
case "manual":
p = "Payment info: " + order.payment.manual_payment_info;
break;
case "free":
p = "Payment info: This order was free!"; //Free order or promotional item
break;
default:
p = "Payment info: " + order.payment.default_payment_info;//default order info
if (order.payment_type != "free") {
p = p + "<p> was charged " + order.amount_in_dollars + "$" + "</p>";
}
html = "<p>" + "Your order of " + order.products.name + " has been received" + "</p>" + "<p>" + p + "</p>";
document.write("<h1> Order receipt details </h1>" + html);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment