Copy link to clipboard
Copied
I have been beating my brains out trying to figure this out. If any of you have thoughts, I would love to hear them. I have a cflocation to redirect to PayPal as follows...
<cflocation url="https://www.paypal.com/cgi-bin/websrc?tax_cart=#WA_eCart_FormatNumber(WA_eCart_GetTax(whitcart), false, 2)#&no_note=0&no_shipping=1&return=http://xxxxxxxx.com/paypalsuccess.cfm&cmd=_cart&upload=1¤cy_code=USD&address_override=0&firstn...), false, 2)#&
<cfoutput>
<CFLOOP FROM='1' TO='#ArrayLen(session.whitcart_items)#' INDEX='i'>
<CFLOOP COLLECTION='#session.whitcart_items#' ITEM='y'>
<CFIF StructKeyExists(session.whitcart_items, y)>
#y#=#session.whitcart_items
</CFIF>
</CFLOOP>
</CFLOOP>
</cfoutput>
business=xxxxxx@xxxxxxx.com" />
When I run this, it comes back with element at position 2 cannot be found. The probem is that my array only has one item in it. I dumped it to the screen and see this...
Price=0.01 TotalPrice=0.01 Name=The_Day_After_His_Birth.pdf Weight=0 Description=The Day After His Birth FullDetails=1 The_Day_After_His_Birth.pdf (2) ID=2 TotalWeight=0 Quantity=1
So I am struggling as to what is occurring.
Thoughts?
Copy link to clipboard
Copied
Is your array 1D or 2D?
Copy link to clipboard
Copied
It is an array with a struct inside it. Here is a copy...
array
1struct | |
---|---|
Description | The Day After His Birth |
FullDetails | 1 The_Day_After_His_Birth.pdf (2) |
ID | 2 |
Name | The_Day_After_His_Birth.pdf |
Price | 0.01 |
Quantity | 1 |
TotalPrice | 0.01 |
TotalWeight | 0 |
Weight | 0 |
Copy link to clipboard
Copied
So in other words, it's a 1D array. That means this line will never work:
#y#=#session.whitcart_items
Copy link to clipboard
Copied
Dan Bracuk wrote:
So in other words, it's a 1D array. That means this line will never work:
#y#=#session.whitcart_items
#
Well it should work as long as 'i' is an integer in the set of {1} and 'y' is a string in the set of {'Description','FullDetails','ID',etc}
I.E this hard coded example should work.
<cfoutput>Description = #session.whitcart_items[1]["Description"]#</cfoutput>
Thus, this should also work.
<cfset i = 1>
<cfset y = "Description">
<cfoutput>#y# = #session.whitchat_items
</cfoutput>
Copy link to clipboard
Copied
Are you sure the error is occurring where you think it is? To find out, test by replacing the line
<CFLOOP FROM='1' TO='#ArrayLen(session.whitcart_items)#' INDEX='i'>
with
<CFLOOP FROM='1' TO='1' INDEX='i'>
Do you get the same error message? If so, does Coldfusion refer you to a line number where the error occurs?
Copy link to clipboard
Copied
Thanks for the input. I decided to go in a different direction by utilizing a cfc and calling the functions using ajax.