fgc.checkout.js
8.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
function shipping_same_as_billing() {
"none" === jQuery(".shipping_address").css("display") && jQuery(".woocommerce-billing-fields input").each(function () {
input_id = jQuery(this).attr("id"), jQuery("#" + input_id.replace("billing", "shipping")).length > 0 && jQuery("#" + input_id.replace("billing", "shipping")).val(jQuery(this).val())
})
}
function updateForPOBox() {
for (jQuery("#order_comments").val(""), jQuery("#tv_same_as_billing_address").is(":checked") ? $shipping_address = jQuery("#billing_address_1").val() + " " + jQuery("#billing_address_2").val() : $shipping_address = jQuery("#shipping_address_1").val() + " " + jQuery("#shipping_address_2").val(), $PO_array = ["PO Box", "P.O. Box", "P.O Box", "PO. Box", "PO Bx", "P.O. Bx", "P.O Bx", "Parcel Locker", "Parcel Lckr", "Parcel Service", "Parcel Lkr"], i = 0; i < $PO_array.length; i++)
$shipping_address.indexOf($PO_array[i]) !== -1 && jQuery("#order_comments").val("AUS Post Only")
}
function updateTextForDelivery() {
jQuery("#authorise").is(":checked") ? jQuery("#text_for_delivery").html("By selecting this box, courier will leave your package of REIZE if nobody is home") : jQuery("#text_for_delivery").html("You have chosen to require a signature on delivery. If you are not home when the courier delivers your REIZE they will leave a note and you will need to collect it from a local pick up centre")
}
function show_link_term_different_currency(a) {
"shipping" === a ? country = jQuery("#s2id_shipping_country .select2-choice .select2-chosen").html() : "billing" === a && (country = jQuery("#s2id_billing_country .select2-choice .select2-chosen").html()), link_term_different_currency = jQuery('input[name="woocommerce_checkout_place_order"]').closest("div").find(".link_term_different_currency"), "Select a country…" === country || "Australia" === country ? link_term_different_currency.fadeOut() : link_term_different_currency.fadeIn()
}
function check_show_protip(a, b) {
return b ? b : ("shipping" === a ? country = jQuery("#s2id_shipping_country .select2-choice .select2-chosen").html() : "billing" === a && (country = jQuery("#s2id_billing_country .select2-choice .select2-chosen").html()), "Select a country…" !== country && "Australia" !== country && (jQuery("#foreign_country").modal("show"), !0))
}
jQuery(document).ready(function (a) {
for (array_id = ["stripe-card-number", "stripe-card-cvc", "order_comments", "billing_first_name", "billing_last_name", "billing_address_1", "billing_address_2", "billing_city", "billing_postcode", "billing_email", "billing_phone", "billing_state", "billing_country", "shipping_first_name", "shipping_last_name", "shipping_address_1", "shipping_address_2", "shipping_city", "shipping_postcode", "shipping_state", "shipping_country"], i = 0; i < array_id.length; i++)
"undefined" != typeof a.cookie(array_id[i]) && "" !== a.cookie(array_id[i]) && a("#" + array_id[i]).val(a.cookie(array_id[i]));
a("#stripe-card-expiry-month").val(a.cookie("stripe-card-expiry-month")), a("#stripe-card-expiry-year").val(a.cookie("stripe-card-expiry-year")), setTimeout(function () {
"undefined" != typeof a.cookie("stripe-card-expiry-year") && "" !== a.cookie("stripe-card-expiry-year") && a("#select2-chosen-8").val(a.cookie("stripe-card-expiry-year")).trigger("change"), a("#stripe-card-expiry").val(a.cookie("stripe-card-expiry-month") + "/" + a.cookie("stripe-card-expiry-year"))
}, 1e3), a(".update_your_order").click(function (b) {
for (b.preventDefault(), a.cookie("stripe-card-expiry-month", a(".select2-container.month_select .select2-chosen").html()), a.cookie("stripe-card-expiry-year", a(".select2-container.year_select .select2-chosen").html()), a.cookie("billing_first_name", a("#billing_first_name").val()), i = 0; i < array_id.length; i++)
"" !== a("#" + array_id[i]).val() && a.cookie(array_id[i], a("#" + array_id[i]).val());
return window.location = a(this).attr("href"), !0
}), a('input[name="woocommerce_checkout_place_order"]').click(function (b) {
setTimeout(function () {
a(".woocommerce_error").length > 0 && (a(".woocommerce_error").offset().top > 300 ? next_top = a(".woocommerce_error").offset().top - 300 : next_top = 0, jQuery("html, body").animate({
scrollTop: next_top
}, 1e3))
}, 1e3)
}), a("#page").append('<div class="blur"></div>'), a('input[name="apply_coupon"]').val("APPLY GIFT CARD"), a("#coupon_code").attr("placeholder", "Gift Card Code"), a(".add_gift_card a").on("tap", function (b) {
b.preventDefault(), a(".cart-discount").length > 0 ? (coupon_code = a(".cart-discount .woocommerce-remove-coupon").attr("data-coupon"), "firstreferee" === coupon_code ? alert("Coupon activated.") : alert("Coupon [" + a(".cart-discount .woocommerce-remove-coupon").attr("data-coupon") + "] activated.")) : (a(".checkout_coupon").fadeIn(), a("#page .blur").fadeIn())
}), a('input[name="apply_coupon"]').click(function () {
a(".checkout_coupon").fadeOut(), a("#page .blur").fadeOut()
}), a("#page .blur").click(function () {
a(".checkout_coupon").fadeOut(), a("#page .blur").fadeOut()
}), a("#tv_same_as_billing_address").click(function () {
shipping_same_as_billing()
}), a("#billing_country").change(function () {
jQuery("#tv_same_as_billing_address").is(":checked") && a("#shipping_country").val(a(this).val()).trigger("change")
}), updateForPOBox(), a("#billing_address_1").change(function () {
updateForPOBox()
}), a("#billing_address_2").change(function () {
updateForPOBox()
}), a("#shipping_address_1").change(function () {
updateForPOBox()
}), a("#shipping_address_2").change(function () {
updateForPOBox()
}), updateTextForDelivery(), a("#authorise").change(function () {
updateTextForDelivery()
}), jQuery('input[name="woocommerce_checkout_place_order"]').closest("div").append('<br/><span class="link_term_different_currency">If you are paying in a different currency from AUD, <a href="#">Click Here</a> to read our Terms and Conditions</span>'), a("#term_different_currency_popup").appendTo("body"), a(".link_term_different_currency a").click(function (b) {
b.preventDefault(), a("#term_different_currency_popup").css("top", a(window).scrollTop() + 15 + "px").fadeIn(), a(".blur").fadeIn()
}), a("body").on("click", ".blur", function (b) {
"none" !== a("#term_different_currency_popup").css("display") && (a("#term_different_currency_popup").fadeOut(), a(".blur").fadeOut())
}), a("#billing_country").on("change", function () {
a("#tv_same_as_billing_address").is(":checked") && show_link_term_different_currency("billing")
}), a("#shipping_country").on("change", function () {
show_link_term_different_currency("shipping")
}), a("#tv_same_as_billing_address").on("click", function () {
a(this).is(":checked") ? show_link_term_different_currency("billing") : on_change_country("shipping", !0)
}), "undefined" == typeof a.cookie("shipping_country") && setTimeout(function () {
country_val = jQuery('#shipping_country option[selected="selected"]').val()
}, 1e3), "undefined" == typeof a.cookie("shipping_state") && jQuery("select#shipping_state").length > 0 && (state_val = jQuery('#shipping_state option[selected="selected"]').val()), "undefined" == typeof a.cookie("billing_first_name") && setTimeout(function () {
a("#billing_first_name").val(a("#bk_billing_first_name").val())
}, 1e3), jQuery("#foreign_country").length > 0 && (isDisplayedProtip = !1, a("#billing_country").on("change", function () {
a("#tv_same_as_billing_address").is(":checked") && (isDisplayedProtip = check_show_protip("billing", isDisplayedProtip))
}), a("#shipping_country").on("change", function () {
isDisplayedProtip = check_show_protip("shipping", isDisplayedProtip)
}), a("#tv_same_as_billing_address").on("click", function () {
a(this).is(":checked") && (isDisplayedProtip = check_show_protip("billing", isDisplayedProtip))
})), jQuery("body").on("DOMNodeInserted", ".woocommerce-error", function () {
jQuery("html, body").animate({
scrollTop: 0
}, "slow")
}), a("input[name=woocommerce_checkout_place_order]").click(function () {
a(".woocommerce-checkout").find("#checkout_loader_img").removeClass("hide")
}), a("body").on("DOMNodeInserted", ".woocommerce-error", function () {
a(".woocommerce-checkout").find("#checkout_loader_img").addClass("hide")
})
if (jQuery('.order-confirm-page').length > 0) {
/* Load ajax check instead woocommerce_payment_complete hook */
// jQuery.ajax({
// url: '/?action=checkAfterPaymentComplete',
// type: "POST",
// success: function (data) {
// }
// });
// jQuery.ajax({
// url: '/?action=checkGtmAfterPaymentComplete',
// type: "POST",
// success: function (data) {
// }
// });
}
});