I'm working with a merchant account processing page and I need to submit product details to the merchant. The code provided by the merchant doesn't work for dynamic results...meaning they're code assumes each product is hard coded on the page. Here's what they have provided, but I need to make it work with query results.
Here's what I have for an equivalent dynamic version...can anyone tell me if this looks right or not? I don't really get any error messages from the merchant account so I wanted to check with the experts here to see if this looks right.
Is this correct, am I missing anything? Thanks in advance!
Code:
<!--- CREATE THE ARRAY --->
<CFSET items = ArrayNew(2)>
<!--- FIRST ITEM --->
<CFSET item_id = "BC456">
<CFSET item_description = "Ball Cap">
<CFSET item_quantity = "1">
<CFSET item_price = "12.99">
<!--- EXAMPLE OF ADDING A SECOND ITEM --->
<CFSET item_id2 = "A98765">
<CFSET item_description2 = "T-Shirt">
<CFSET item_quantity2 = "3">
<CFSET item_price2 = "13.99">
<!--- ADD ITEMS TO THE ARRAY --->
<!--- FIRST ITEM --->
<CFSET items[1][1] = "#product_id#"> <!--- ITEM ID --->
<CFSET items[1][2] = "#prod_name#"> <!--- ITEM DESCRIPTION --->
<CFSET items[1][3] = "#quantity#"> <!--- ITEM QUANTITY --->
<CFSET items[1][4] = "#price#"> <!--- ITEM PRICE --->
<!--- EXAMPLE OF SECOND ITEM --->
<CFSET items[2][1] = "#product_id2#"> <!--- ITEM ID --->
<CFSET items[2][2] = "#prod_name2#"> <!--- ITEM DESCRIPTION --->
<CFSET items[2][3] = "#quantity2#"> <!--- ITEM QUANTITY --->
<CFSET items[2][4] = "#price2#"> <!--- ITEM PRICE --->
Here's what I have for an equivalent dynamic version...can anyone tell me if this looks right or not? I don't really get any error messages from the merchant account so I wanted to check with the experts here to see if this looks right.
Code:
<cfquery name="get_cart_items" datasource="#app.ds#">
SELECT a.product_id, a.prod_name, a.price, a.sale_price, a.special, a.img_full, b.prod_size, b.gender, b.LR, b.quantity
FROM products a, cart_items b
WHERE a.product_id = b.product_id
AND b.cart_id = '#form.cart_id#'
</cfquery>
<!--- CREATE THE ARRAY --->
<cfset items = ArrayNew(2)>
<cfset loopcount = 0>
<cfoutput>
<cfloop query="get_cart_items">
<cfset loopcount = loopcount + 1>
<CFSET item_id[#loopcount#][1] = "#get_cart_items.product_id#">
<CFSET item_description[#loopcount#][2] = "#get_cart_items.prod_name#">
<CFSET item_quantity[#loopcount#][3] = "#get_cart_items.quantity#">
<CFSET item_price[#loopcount#][4] = "#get_cart_items.price#">
</cfloop>
</cfoutput>
Is this correct, am I missing anything? Thanks in advance!