Skip to content

Instantly share code, notes, and snippets.

@salsalabs
Last active March 3, 2018 00:32
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 salsalabs/b44fe35b1df39289dff14dad7ac842d7 to your computer and use it in GitHub Desktop.
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.
<!-- 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