Last active
March 3, 2018 00:32
-
-
Save salsalabs/b44fe35b1df39289dff14dad7ac842d7 to your computer and use it in GitHub Desktop.
Replace the shipping fees on a Classic storefront with a flat-rate shipping fee.
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
<!-- BEGIN Use flat-rate shipping. See https://help.salsalabs.com/hc/en-us/articles/360001494394 --> | |
<script type="text/javascript"> | |
// You configure this. Change 10.50 to your shipping rate. Please | |
// do not disturb the punctuation. | |
var flatRateShippingFee = 10.50; | |
document.addEventListener("DOMContentLoaded", function() { | |
if (RegExp('/shop/checkOut.jsp\\?storefront_KEY=').test(window.location.href)) { | |
var e = document.querySelector("#shipping"); | |
if (e != null) { | |
e.value = flatRateShippingFee.toFixed(2); | |
e = document.querySelector("#sub"); | |
var sub = parseFloat(e.value); | |
var total = (sub + flatRateShippingFee).toFixed(2); | |
document.querySelector("#amount").value = total; | |
document.querySelector("#amountDisplay").value = total; | |
} | |
} | |
}); | |
</script> | |
<!-- END Use flat-rate shipping. --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment