On my shopping cart app, I've gotten through the payment processing part and
now I'm entering the data into two tables. I'm using Nate's example from WACK.
Does anyone have any suggestions on improving this code? It works but I want to
improve it, and I've never used cftransaction before.
In this example, ListFirst(cfhttp.filecontent)is the value returned from
authorize.net. 1 - approved, 2- declined, 3- error
Thanks much,
...cf Will
<!--- Enter order into tblorders --->
<cftransaction action="begin">
<cfquery datasource="#APPLICATION.DSN#" name="insertorder">
INSERT INTO tblorders
(orderID, orderdate, contactFname, contactLname, shipaddress1, shipaddress2,
shipcity, shipstate, shipzip, shipcountry, shipphone, shipemail, billingfname,
billinglname, billingaddress1, billingaddress2, billingcity, billingstate,
billingzip, billingcountry, billingphone, billingemail, shopperID, notes)
VALUES ('#VARIABLES.invoicenumber#', '#VARIABLES.invoicedate#',
'#shopperinfo.s_fname#', '#shopperinfo.s_lname#',
'#shopperinfo.s_address1#','#shopperinfo.s_address2#', '#shopperinfo.s_city#',
'#shopperinfo.s_state#',
'#shopperinfo.s_zip#', '#shopperinfo.s_country#', '#shopperinfo.s_phone#',
'#shopperinfo.s_email#',
'#shopperinfo.b_fname#', '#shopperinfo.b_lname#', '#shopperinfo.b_address1#',
'#shopperinfo.b_address2#',
'#shopperinfo.b_city#', '#shopperinfo.b_state#', '#shopperinfo.b_zip#',
'#shopperinfo.b_country#',
'#shopperinfo.b_phone#', '#shopperinfo.b_email#', #shopperinfo.custID#,
'#ATTRIBUTES.comments#')
</cfquery>
<cfloop collection="#sc#" item="i">
<cfquery datasource="#APPLICATION.DSN#" name="insertorderitem">
INSERT INTO tblorderitems
(orderID, prodID, prodqty, prodsellprice)
VALUES ('#VARIABLES.invoicenumber#', '#i#', #sc[i].qty#, #sc[i].price#)
</cfquery>
</cfloop>
<cfif ListFirst(cfhttp.filecontent) EQ 1>
<cftransaction action="commit" />
<cfelse>
<cftransaction action="rollback" />
</cfif>
<!--- End transaction --->
</cftransaction>
<!--- Send confirmation email about this order --->
Working on this part now
<!--- Gotta empty their cart --->
<cfinvoke component="#SESSION.myshoppingcart#" method="Empty">
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking
application. Start tracking and documenting hours spent on a project or with a
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:207704
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54