sent
in the following hack to make life simpler when shopping at WebStore!
As Webstore is set up, you have one 'add to cart' button per page,
and you need to enter a quantity by the items that you want to
purchase. For some situations, it works much better to have an
'add to cart' button for each item. Clicking this item will assume
a quantity of one for that item and add it to the user's cart.
In the web_store.setup.db file:
Find the definition of $sc_product_display_row. Within this,
replace the element:
<INPUT TYPE = "text"
NAME = "item-%s"
SIZE = "3" MAXLENGTH = "4">
with:
<INPUT BORDER=0 NAME=add_to_cart_button
TYPE=submit
VALUE="Add Items to my Cart" ONCLICK="calc('%s')"><BR>
This will mean that you will not have a quantity box on your site.
This shouldn't be a problem, as there is a 'change quantity option' on
the shopping cart that they can use.
In the definition of $sc_product_display_header, add the following to
the beginning (before the <TABLE> definition):
<SCRIPT LANGUAGE="javascript">
<!-- function calc(i) {document.form.item.value=i;}
//--></SCRIPT>
<INPUT TYPE="hidden" NAME="item">
In the file web_store.cgi, find the line:
@items_ordered = keys (%form_data);
Before this line, add:
if ($form_data{"item"} ne "")
{
$form_data{"item-".$form_data{"item"}}=1;
undef $form_data{"item"};
}
In the web_store_html_lib.pl file, find both occurances of the line:
<FORM METHOD = "post" ACTION = "$sc_main_script_url">
replace them with:
<FORM METHOD = "post" NAME="form" ACTION = "$sc_main_script_url"GT;
And that should be it.
Please note, my own implementation of this is much more complex. I
have distilled out the necessary from it to make it work, but I
haven't tested it. If you try it and it doesn't work, please do
contact me and I'll see if I can correct it.
Malcolm Holmes
malcolm@fwbo.org