If you run a ShopSite Pro store and are interested in customizing the checkout screen to display specific information, then you may wish to consider using JavaScript to accomplish this goal. You could use JavaScript in any number of ways. It can be used to detect what items are in the cart and then output applicable text. For example, if someone orders a widget, and you want to display ‘thank you for ordering a widget’, you obviously do not want this displayed always, as it should only be displayed to someone ordering a widget. JavaScript can help you accomplish this goal, as you could have it perform the widget check, and if it finds a widget, display the text, else do nothing.
ShopSite Pro makes JavaScript variables available for use with items such as products, totals, coupons, etc. These variables can be found by viewing the source code in either your cart or checkout screen and searching for ‘ss_screen’. With simple JavaScript functions, you can reference and use this data to output text, images, or even pass data to third party applications. Using the example above for the widget, JavaScript code might look like:
<script type="text/javascript">
<!--
for (i = 0; i < number_products; i++) {
if (ss_name[i].match(/widget/)) {
document.write('thank you for ordering a widget');
}
}
// -->
</script>
An example for using JavaScript to check for an actual form value, such as the customer choosing one of the generic payment options on the checkout screen would look like:
<script type="text/javascript">
<!--
if (document.billing.paytype.value == 8) {
document.write('Custom text goes here');
}
// -->
</script>
which would output custom text for generic payment option 1 (ShopSite uses a value of 8 for the first generic payment option, and 9 for generic payment option 2). You would place the JavaScript where you want the text to output in the cart template.