adding "your cart is empty", anyone know how ??!

greenspun.com : LUSENET : S-Mart Shopping Cart : One Thread

Hi Does anyone know how to add a message like "Your Cart is Empty", which will show up when then are no items in the cart. If this can be done i think i would just about finish off this superb script :-)

Thanks

Sam

-- Sam Thompson (samt@lhsl.co.uk), May 10, 1999

Answers

That's a good idea for a modification. Here's how you do it.

Find the "sub list_items {" section of your script (what's in between the quotes)

Go down about 5 lines and you will see a line saying $SIZE=@LINES;

Directly after this line, add the following code:

if ($SIZE eq '1') { print "

Your Shopping Cart is Empty!"; }

That's all there is to it. It will still show the customer the blank order form but will have that note above it. Making the table completely disappear would be a lot bigger of a challenge since each and every one of the "If" statements in that section of code would also need to include something about the cart being empty to force them not to display the code... Doing that is probably more trouble than it's worth.

Hope this helps! I put it in my script and it works perfectly.

-BP

-- bp (bppilot@aol.com), May 17, 1999.


Thanks BP :-)

-- Sam Thompson (samt@lhsl.co.uk), May 20, 1999.

Similar to the cart is empty information is when the customer does a search and no information comes up. I wanted to add some text that would tell them they had no matches to their search. After much pouring over the script and sweating I came up with this solution.

In the sub gen_page routine find the elsif routine that says

elsif ($type eq 'search')

find the end of table line

print "\n";

add this information

if ($matches < 1) { print "Your search returned no matches\n"; }

What you put in the print line is up to you.

Rick

-- Rick Clevenger (Rick@Clevenger.com), June 12, 1999.


You could also avoid printing the cart table ....

add the following line below: --- exit; --- This way you will print only "Your cart is empty". It is more professional!

-- Robi (webmater@webupgrade.com), October 24, 1999.


sorry
the line is only:
exit;

-- robi (webmaster@webupgrade.com), October 24, 1999.


Moderation questions? read the FAQ