sent
in the following bug fix...
Someone recently sent me an email message concerning a problem they were having with my
JJW.cc version of the Web store. The problem involved an "Image Button Bug" which everyone
should know about.
The error/problem was this:
The shopping cart was a "super cart" type which used an Image Button for the "Submit Quantity
Changes". Sometimes when submitting changes the user would receive a "Bad Change Quantity"
Error Message --- even though the quantity change numbers were obviously greater than zero!
As some of you already realize, browsers will return name/value pairs (into %form_data) for
the x and y coordinates of where the image button was click on ( x=3, y=0 for example).
The problem was that the browser was sending coordinate values for x and y which in some
cases were zero. This caused the code in sub "modify_quantity_of_items_in_cart" to think
that there was a change quantity of zero, producing the "Bad Change Quantity" Error Message .
This fix is very simple:
In web_store.cgi find the subroutine "modify_quantity_of_items_in_cart":
Change the IF statement:
if ((($key =~ /[\d]/) && ($form_data{$key} =~ /\D/)) ||
$form_data{$key} eq "0")
to:
if (($key =~ /[\d]/ && $form_data{$key} =~ /\D/) ||
($key =~ /[\d]/ && $form_data{$key} eq "0"))
That's it.