Last active
April 24, 2018 19:41
-
-
Save salsalabs/8e92eaf742506efe2996 to your computer and use it in GitHub Desktop.
Script to clean up the purchased items table on a storefront checkout page
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 clean up totals in the storefront checkout page --> | |
<script type="text/javascript"> | |
$(document).ready(function() { | |
// Clean up the totals in the storefont checkout invoice. | |
// @see https://help.salsalabs.com/hc/en-us/community/posts/213571707 | |
// | |
if (RegExp('shop/checkOut.jsp').test(window.location.href)) { | |
// Put an ID on the table so that it can be decorated with CSS. | |
// | |
var t = $('td[colspan=3]:contains("Subtotal:")').parent().parent() | |
t.parent().attr('id', 'payment-table'); | |
// Remove all dollar signs. | |
// | |
t.html(t.html().replace(/\$/g, '')) | |
// Missing cell at the end of the column head line. | |
// | |
t.find('tr').eq(0).append('<td></td>') | |
// Line up total cells with the amounts | |
// | |
t.find('td[colspan=3]').attr('colspan', '4'); | |
// Add a cell after subtotal/shipping/display cell in total rows. | |
// | |
$.each('sub shipping amountDisplay'.split(' '), function(i, n) { | |
$('input[name=' + n + ']').parent().after('<td></td>'); | |
}) | |
} | |
}); | |
</script> | |
<!-- END clean up totals in the storefront checkout page --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment