URL: http://www.uburst.com/cgi-bin/dcforum/dcboard.cgi
Forum: ushp_general_purpose
Thread Number: 310
[ Go back to previous page ]

Original Message
"Blocking Empty Carts"

Posted by James [mail@hamptonplace.com] on at 08:40 AM
I have found that some people will go completely through an order process and pay shipping for an empty cart. This happens on occassions. Is there a way to block, not letting the customers go through to checkout if the cart is empty?

Thanks again,

Table of contents

Messages in this discussion
"RE: Blocking Empty Carts"
Posted by Bill Weiner on at 05:40 AM
Here is a trick to use uShop's JavaScript API to make sure the cart is not empty:

STEP 1: On your "begin order process" page (or whatever page(s) that you have the "uShopOrderButton" applet on) ... try adding the following JavaScript function:

< SCRIPT LANGUAGE="Javascript" >
function checkQuantity()
var itemCount = document.uShopJSI.getTotalQuantity();
if (itemCount == 0)
alert("Your shopping cart is empty.");

You can put that script pretty much anywhere on the page (it won't be visible).

STEP 2: Also on that page, modify the "BODY" line of the page to call the new JavaScript function via the "onLoad" action.

For example, if your "BODY" line of your HTML page is:


Then change it to:

< BODY BGCOLOR="#FFFFFF" onLoad="checkQuantity;" >

STEP 3: And finally, on that page, don't forget to add the special "uShopJSI" applet so that the JavaScript can interface with uShop. The uShopJSI applet can usually put at the very bottom of your page with the following HTML:

< APPLET CODE="uShopJSI.class" CODEBASE="../classes/" NAME="uShopJSI" WIDTH="2" HEIGHT="2" >

NOTE: If you have any questions about using the uShopJSI applet with uShop or with just interfacing JavaScript with uShop, please refer to the "JavaScript Examples" in the uShop Applet Reference:


Or the uShop Programmer's Guide:


"Re: Blocking Carts"
Posted by James on at 12:13 PM
Thanks, I edited the template, which seems to be the best file for this mod.


I put the javascript in the header, the onload in the body tag and then at the footer / closing body tag the uShopJSI.class. Don't forget to remove the codebase within the class tag as it is in the same directory.

Works great, should be a standard.

Thanks again, great support,