Skip to content

Instantly share code, notes, and snippets.

@salsalabs
Created May 1, 2019 21:21
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save salsalabs/8b591caccc00a843a1a63f3317cb636f to your computer and use it in GitHub Desktop.
Script to add a flat $10.00 shipping and handling to a storefront checkout if the merchandise total is $50 or less.
<script type="text/javascript">
$(document).ready(function() {
var shippingAndHandling = 10.00;
if (window.location.href.indexOf('/shop/checkOut.jsp') != -1) {
var s = $('input[name=sub]').val();
s = parseFloat(s);
if (s < 50.00) {
var t = s + shippingAndHandling;
$('input[name=shipping]').val(shippingAndHandling.toFixed(2));
$('input[name=amount]').val(t.toFixed(2));
$('input[name=amountDisplay').val(t.toFixed(2));
}
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment