Sha256: 92f3e48b090542621326f7508235f2acc8375721dfbca757e18b2fc485b3ec7f
Contents?: true
Size: 940 Bytes
Versions: 15
Compression:
Stored size: 940 Bytes
Contents
Spree.onCouponCodeApply = (e) -> couponCodeField = $('#order_coupon_code') couponCode = $.trim(couponCodeField.val()) return if couponCode == '' couponStatus = $("#coupon_status") successClass = 'success' errorClass = 'alert' url = Spree.url(Spree.routes.apply_coupon_code(Spree.current_order_id), { order_token: Spree.current_order_token, coupon_code: couponCode } ) couponStatus.removeClass([successClass,errorClass].join(" ")); req = Spree.ajax method: "PUT", url: url req.done (data) -> window.location.reload(); couponCodeField.val('') couponStatus.addClass(successClass).html("Coupon code applied successfully.") req.fail (xhr) -> # handler = JSON.parse(xhr.responseText) handler = xhr.responseJSON couponStatus.addClass(errorClass).html(handler["error"]) Spree.ready ($) -> $('#coupon-code-apply-button').click (e) -> Spree.onCouponCodeApply(e)
Version data entries
15 entries across 15 versions & 1 rubygems