Thanks Dave,

I still haven't figured this out... You were right about what is dumping and
what is built.  Here is what I am trying to do...

In my "cart" array I build two structs. 1 for options and 1 for choices.
There can be multiple options and choices. (So, 2 options and 3 choices or
vice versa - totally unlimited.)

When you add a product to the cart it keeps the "MerchID" (Merchandise ID)
and then builds the structs for the choices and options by looping through
the form elements. This works fine - it adds everything as it should be.
However...

If I add TWO of the same product - I need to see if it is already in the
cart. (Does MerchIDX already exist - if so - make the quantity 2)  However,
it's not quite that simple, maybe they want a MerchIDx Option Large and a
MerchIDX Option Small... If that is the case - then the quantity isn't 2 -
it should be 2 separate items in the cart.

To do this I check if the MerchID is already in the cart:
<CFIF This.CartArray[i].MerchID EQ Arguments.MerchID>  

If it is, I need to see if both the options AND the choices are identitical
- if so, I up the quantity - if not - make a new CartItem.  This is where I
need to compare the two Structs see if they are the same and break if not...
the code is close - but not quite there...


<!--- Need to compare both Options Struct AND Choice Struct --->
        <cfif StructCount(Arguments.Options) GT 0>
        
                <cfset CartItemOptions = This.CartArray[i].Options>
            
            <!--- Loop over Option Items to find similar value --->
            <cfloop collection="#Arguments.Options#" item="o">
                <cfset PassedOptionItemID = #StructFind(Arguments.Options,
o)#  >
                <cfset CurrentOptionItemID = #StructFind(CartItemOptions,
o)#  >


                        <!--- If the values match - remove from temp list
--->
                                        <cfif PassedOptionItemID EQ
CurrentOptionItemID>
                                                <cfset DeleteRow =
StructDelete(CartItemOptions, "#o#", "True")>
                    <cfelse>
                    <!--- If they don't match - set to FALSE and break loop
--->
                        <cfset OptionsMatch = "FALSE">    
                        <CFBREAK>                    
                    </cfif>
            </cfloop>

        </cfif>


        <cfif StructCount(Arguments.Choices) GT 0>
        
                <cfset CartItemChoices = This.CartArray[i].Choices>
            
            <!--- Loop over Option Items to find similar value --->
            <cfloop collection="#Arguments.Choices#" item="c">
                <cfset PassedChoiceItemID = #StructFind(Arguments.Choices,
c)#  >
                <cfset CurrentChoiceItemID = #StructFind(CartItemChoices,
c)#  >


                        <!--- If the values match - remove from temp list
--->
                                        <cfif PassedChoiceItemID EQ
CurrentChoiceItemID>
                                                <cfset DeleteRow =
StructDelete(CartItemChoices, "#c#", "True")>
                    <cfelse>
                    <!--- If they don't match - set to FALSE and break loop
--->
                        <cfset ChoicesMatch = "FALSE">    
                        <CFBREAK>                    
                    </cfif>
            </cfloop>

        </cfif>




            <!--- Check size of CartItemOptions - if anything left - the two
do NOT match--->
                <cfif OptionsMatch EQ "TRUE" AND ChoicesMatch EQ "TRUE">
                                <cfif StructCount(CartItemOptions) EQ 0 AND
StructCount(CartItemChoices) EQ 0>
                    <CFSET CurrentArrayPos = i>
                </cfif>
            </cfif>
            <CFBREAK>

Full code can be seen here: http://code-bin.homedns.org/336 

Thanks again  - Nick



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:4675
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15

Reply via email to