Examples of interactions required:
function amount_calc() {
var c = $(".type-choice input:checked");
var shipping = 0;
var digital_desc = "";
if (c.attr("data-ship") === "1") {
$(".shipping-choice").removeClass("inactive");
$(".shipping-choice input").removeAttr("disabled");
if (!is_gift()) {
$(".shipping-information").show();
}
var sc = $(".shipping-choice input:checked");
shipping = Number(sc.attr("data-amount"));
digital_desc = " (" + sc.parent().find(".desc").text() + ")";
} else {
$(".shipping-choice").addClass("inactive");
$(".shipping-choice input").attr("disabled", "disabled");
$(".shipping-information").hide();
}
var discount = 0;
function format_money(d) {
var pad = "";
if (d % 100 < 10) {
pad = "0";
}
return Math.floor(d / 100) + "." + pad + (d % 100);
}
if ($(".coupon-info").length != 0) {
if (c.attr("data-ship") === "1") {
var d = $(".coupon-info").attr("data-" + c.attr("data-type") + "-" + sc.attr("data-code"));
} else {
var d = $(".coupon-info").attr("data-" + c.attr("data-type"));
}
if ($(".coupon-info").attr("data-gift-only") === "true") {
if (is_gift()) {
var gift_passed = true;
} else {
var gift_passed = false;
}
} else {
var gift_passed = true;
}
if (typeof d !== "undefined" && d !== "0" && gift_passed) {
discount = Number(d)
$(".coupon-amount").text(" - $" + format_money(d) + " Off");
} else {
$(".coupon-amount").text(" - You can't use this coupon with that selection.");
}
}
var cents = Number(c.attr("data-amount")) + shipping - discount;
var amount = format_money(cents);
$(".total .amount").text(amount);
{{ display_text }}
new Vue({
el: '#my-component',
data: {
display_text: 'Hello World!'
}
})
{{ display_text }}
new Vue({
el: '#my-component',
data: {
display_text: 'Hello World!',
show_display: true
}
})
Subtotal: {{ subtotal }}
new Vue({
el: '#my-component',
data: {
expedite_shipping: false,
add_donation: false
},
computed: {
shipping_subtotal: function() {
if (this.expedite_shipping) {
return 5
} else {
return 1
}
},
donation_subtotal: function() {
if (this.add_donation) {
return 10
} else {
return 0
}
},
subtotal: function() {
return 10 + this.shipping_subtotal + this.donation_subtotal
}
}
})
Subtotal: {{ subtotal }}
new Vue({
el: '#my-component',
data: {
expedite_shipping: false, add_donation: false,
shipping_cost: {reg: 0, exp: 0}, donation_cost: 0, base_cost: 0
},
mounted: function() {
this.shipping_cost = {
reg: parseInt(this.$refs.shipping_toggle.dataset.reg),
exp: parseInt(this.$refs.shipping_toggle.dataset.exp)
};
this.donation_cost = parseInt(this.$refs.donation_toggle.dataset.amount);
this.base_cost = parseInt(this.$refs.base_cost.dataset.amount);
},
computed: {
shipping_subtotal: function() {
return this.expedite_shipping ? this.shipping_cost.exp : this.shipping_cost.reg
},
donation_subtotal: function() {
return this.add_donation ? this.donation_cost : 0
},
subtotal: function() {
return this.base_cost + this.shipping_subtotal + this.donation_subtotal;
}
}
})