VP-ASP New User
Posted - January 31 2005 : 10:11:09
| Hi, everyone. I'm working on adding a table to the database which contains used items for sale which can be ordered from the database. Well, the table itself isn't the problem, of course, it's thinking through all the subtleties of the cart to make sure a customer can actually buy them. I'm writing this to help clear my head and sort out ideas, and will appreciate input from members as I'm pondering.
Adding an item to the cart: Sticky, because used stuff is in a seperate table. Hmm... wait a moment... Let's take a closer look at what happens on shopaddtocart...
Right: When I click on the 'order' button on a normal product page, I go to shopaddtocart.asp and pass some value as the "action." Now - what actions does shopaddtocart expect? I could probably use an 'addused' action to do add the proper logic.
We'll also have to find the display part of 'shopaddtocart' since that's also where we can change product quantities. We'll want to remember used products, since there's a limited number of each used item. This might be a tad trickier, but we'll see...
Edited by - Dulrr on January 31 2005 10:20:09
Hmm... the strAction variable is tough to decipher... This is a very messy piece of code, actually - a few elseif statements probably would have cleaned this up quite a bit. Here's a small sample:
if straction<>"" then
If straction="" then
if straction<> "" then
Not that I'm being picky or fussy (me? NEVER! *innocent*), but wouldn't the following do the same thing with half the headache?
if Request("Checkout")<>"" then
elseif Request("Checkout.x")<>"" then
'elseif Request("recalculate")<>"" then
Anyways, moving on...
Edited by - Dulrr on January 31 2005 10:30:53
VPASP doesn't use the "request" command the way my reference books expect it to be used. Normally, according to the sources I've got at hand, it's suppossed to be "Request.Something()" not just "Request()." Request.Querystring(), Request.Servervariables(), Request.Form()... but no mention of simply Request(). Where is the cart getting info from, then?
Edited by - Dulrr on January 31 2005 10:44:42
Found the logic for actually adding a product to the cart. Sub CartAddItem() in shopproductfeatures.asp.
Not the first place I'd look for this sub - thank-you Dreamweaver for having a site search ability!
Modifying this should accomplish what I need to do. (Here's hoping, at least!) Now - to find a way to get the right variables to this function...
Edited by - Dulrr on January 31 2005 10:53:58
My kingdom for some comprehensive comments! Flaaaargh!
Edited by - Dulrr on January 31 2005 11:09:11
"Boldly going foreward 'cause we can't find reverse!"
EUREKA!! I think I've found it!
Alrighty: in shop$db, near the beginning, there's a slew of constants defined. Starting at const MaxCartAttributes, we see defined everything that will be stored in the 2D array, "CartArray," when items are purchased.
Saving an additional piece of information should be a breeze. We increase MaxCartAttributes by one, then add a new constant at the end of the list. (So cProductUsed would be #22 in my Ver. 5.0 shopping cart)
On most pages, the array of items is referred to as "arrCart" - so I can run checks based on the value stored there. Something like "if arrCart(cProductUsed, [itemnumber]) = true then ... "
We're going to need to make updates in a few areas now, including shopaddtocart.asp. However, I think we're now pretty close to the end - and still working within the structure and confines of the software!
Time to plow foreward and see what new mistakes await us!
Edited by - Dulrr on January 31 2005 14:09:25