I'm just fishing for ideas.

I have this core shopping cart code that I've used before and it's always
worked fine (I'll share the core code below).

I'm building a music site -- there are accessories to buy and songs to
download.  Essentially, I need to have a two-part shopping cart -- part one
for accessories and part two for songs. The core of the cart needs to be
slightly different from each other, but then for checkout I've been working
toward  merging the two halves into a single cart.

The accessories portion works perfectly.  I can add items, add quantity and
delete without a problem.

The song portion has a problem ... I can't add a second item.  I add the
first item ... and that's it. No matter how many more items I try to ad, it
don't work.  BUT, if I move over to the accessories section, add and item
and them move back to the songs -- then I can ADD all of the songs I want.
Even if I then remove the added accessory, I can keep adding songs.

I have another site that I use this same exact core code on and it works
fine -- add items, no problem.

Again, this post is just a fishing expedition in case anybody has some
ideas.

I should know, you'll see in the code below that has a conditional test
whether the shopping cart has been initialized. If it has, the second half
of the conditional runs.  If you're wondering whether the second half of the
conditional is running when it is supposed to, it is.  I've test that
several times. The conditional works the way it should every time. BUT, the
code adding the next item to the array (a structure) doesn't seem to
execute.

Well, it does and it doesn't -- the item doesn't show up in the shopping
cart output, but the item added does show up in test output for just that
item (like this: <cfoutput>#session.itemname#</cfoutput>).   Below the core
shopping cart code below, I'll show you the standard shopping cart output I
use (I should note, that after failed attempts to add a second song to the
cart, I've moved over to the accessories portion of the cart (which has
worked without fail) to see if more than one song shows up in that cart's
output (it should), but it doesn't.  So I don't think this is an output
problem.  It's an addition problem.

Here's how items are added to the cart -- a link is clicked and the link has
the song ID number as a URL variable. The cart.cfm page runs a query to find
the details for that song and then adds to details to the cart.

Here's the core code:


<cflock timeout="#createtimespan(0,0,30,0)#"
                name="#session.sessionID#"
        type="EXCLUSIVE">

                <!--- if this is not a new cart, let's add our first item
--->
<cfif session.newcart is "no">


<!--- script to add new, first item to cart --->
<CFSCRIPT>
        session.cart = ArrayNew(1);
        session.item = StructNew();
        session.item.PRODUCT_ID = 0;
        session.item.NAME = "#FindItem.SONG_TITLE#";
        session.item.DESCRIPTION = "#FindItem.ARTIST_FIRST_NAME#
#FindItem.ARTIST_LAST_NAME#";
        session.item.QUANTITY = 1;
        session.item.PRICE = "#request.songprice#";
        session.item.ITEMTOTAL = "3";
        session.item.SONG_ID = "#FindItem.SONG_ID#";
        
        session.CartItems = ArrayAppend(session.cart, session.item);

</CFSCRIPT> 

<!--- now, let's let our system know that an item has indeed been added.
--->
<cfset session.newcart="yes">




<cfelse>
<!--- if the cart already exists, we'll now add more items --->


<!--- script to add additional items to the cart --->
        <CFSCRIPT>
        session.item = StructNew();
        session.item.PRODUCT_ID = 0;
        session.item.NAME = "#FindItem.SONG_TITLE#";
        session.item.DESCRIPTION = "#FindItem.ARTIST_FIRST_NAME#
#FindItem.ARTIST_LAST_NAME#";
        session.item.QUANTITY = 1;
        session.item.PRICE = "#request.songprice#";
        session.item.ITEMTOTAL = "3";
        session.item.SONG_ID = "#FindItem.SONG_ID#";
        
        session.CartItems = ArrayAppend(session.cart, session.item);
        
        </CFSCRIPT> 
        
        
</cfif>
</cflock>



Like I said, I don't think output is the problem, but here's the output code
(stripped of HTML for easier reading):


<cfloop index="ThisOrder" from="1" to="#ArrayLen(session.cart)#">
                        
                        <cfif session.cart[ThisOrder].QUANTITY GTE 1>
                        
<cfoutput>
                        
#UCASE(session.cart[ThisOrder].NAME
#session.cart[ThisOrder].DESCRIPTION# 
#DollarFormat(session.cart[ThisOrder].PRICE)# 

</cfoutput>

                        
                        </cfif>
</cfloop>

btw:  When I test for #ArrayLen(session.cart)# after an song should have
been added (and wasn't), the ArreyLen is always 1 -- so this is more
evidence to me that the item is not getting added (and that this is not an
output problem).

H.






______________________________________________________________________
Why Share?
  Dedicated Win 2000 Server � PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation � $99/Month � Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusionc
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to