-
-
Save cyberwombat/a5c07bd050ca65f24a28 to your computer and use it in GitHub Desktop.
Foxycart snippet for no tax coupon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (FC, $) { | |
FC.wholesaleCoupon = {}; | |
FC.wholesaleCoupon.execute = function() { | |
var is_w = false; | |
for (item in FC.json.coupons) { | |
if (~item.indexOf('FRIEND')) { | |
is_w = true; | |
} | |
} | |
if (is_w) { | |
// This works - the field gets updated - | |
$('#shipping_tax_id').val('friend'); | |
$('#billing_tax_id').val('friend'); | |
// None of the above seem to update taxes | |
FC.json.taxes_calculated = true; // tried false | |
FC.cart.recalculateCartTotals(); | |
FC.cart.renderTaxes(); | |
} | |
}; | |
function wholesaleCouponHandler(){ | |
FC.wholesaleCoupon.execute() | |
} | |
FC.client.on("checkout-shipping-options-update.done",wholesaleCouponHandler); | |
FC.client.on("checkout-submit",wholesaleCouponHandler); | |
FC.client.on("customer-login.done",wholesaleCouponHandler); | |
FC.client.on("cart-coupon-add.done",wholesaleCouponHandler); | |
FC.client.on("cart-coupon-remove.done",wholesaleCouponHandler); | |
{% if cart_is_fullpage or context == 'checkout' %}FC.client.on("ready.done",wholesaleCouponHandler);{% endif %} | |
})(FC, jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment