Skip to content

Instantly share code, notes, and snippets.

@cyberwombat
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cyberwombat/a5c07bd050ca65f24a28 to your computer and use it in GitHub Desktop.
Save cyberwombat/a5c07bd050ca65f24a28 to your computer and use it in GitHub Desktop.
Foxycart snippet for no tax coupon
(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