vagrant/website/source/assets/javascripts/application.js

57 lines
1.4 KiB
JavaScript
Raw Normal View History

//= require jquery
//= require bootstrap
2013-09-03 20:48:55 +00:00
//= require lib/_Base
2017-03-03 18:56:16 +00:00
//= require hashicorp/mega-nav
//= require app/_app
//= require app/_docs
//= require app/_sidebar
//= require app/_util
//= require_self
2013-09-03 20:48:55 +00:00
// Redirect to the proper checkout screen for quantity
$(document).ready(function() {
2015-11-15 01:12:59 +00:00
var selectedProduct = "";
function setSelectedProduct() {
selectedProduct = $("input[name=product]:checked").val();
}
$(".buy-form input[name=product]").change(function() {
setSelectedProduct();
var text = selectedProduct.charAt(0).toUpperCase() + selectedProduct.slice(1);
$("#buy-fusion").text("Buy " + text + " Licenses Now");
});
$("#buy-fusion").click(function() {
var seats = parseInt($("#seats").val(), 10);
if (isNaN(seats)) {
alert("The number of seats you want to purchase must be a number.");
return;
} else if (seats <= 0) {
alert("The number of seats you want must be greater than zero.");
return;
2013-09-03 20:48:55 +00:00
}
2015-11-15 01:12:59 +00:00
var productId = "";
if (selectedProduct == "fusion") {
productId = "279661674";
} else if (selectedProduct == "workstation") {
productId = "302167489";
} else {
alert("Unknown product selected. Please refresh and try again.");
return;
2013-09-03 20:48:55 +00:00
}
2015-11-15 01:12:59 +00:00
window.location = "http://shopify.hashicorp.com/cart/" + productId + ":" + seats;
});
if ($("#buy-fusion").length > 0) {
setSelectedProduct();
}
2013-09-03 20:48:55 +00:00
});