Tim Laureska wrote:
>upon submission of this order screen, the template needs to summarize
>the order for the customer
>
>I'm not sure how to approach this... ie. how to send the order
>information to a process template and then how to code the template to
>ensure proper entry into the DB
>
>Is this a structure scenario or query loop or what..??
>
>Being new to this sort of ordering, any pointers in the right direction
>would be appreciated
>
>
You're going to need 2 tables for storing orders.
One for storing the general details of an order like the date of the
order, customer name, address, contact details that kind of thing. You
could probably go one stage further and have a Customer table, so that
people can register on the site and only need enter a customer id and
password to complete their invoice/delivery details, but for the minute
I'll stick with one table with the customer details in there.
So, your Order table would be :
OrderID
OrderDate
CustomerName
Address1
Blah...
Items order would be in a table (OrderItems) like so :
OrderID
ProductID
OrderQty
On your order form you should make sure that each Quantity field is
uniquely identified for each product. One of the ways I've used in the
past is to append the productid to the name of the quantity form field.
eg.
<form action="ordersummary.cfm" method="post>
<cfoutput query="ProductList">
#ProductTitle# - #ProductDescription# - <input type="text"
name="Quantity_#ProductID#" size="3" maxlength="3">
</cfoutput>
<input type="submit" name="submit" value="submit">
</form>
If your Product ID for an item is say "123" this would give you a
quantity field called Quantity_123 on the summary page and the value of
this form field would be the quantity that the person wants to order.
You will need to parse through the form fields to get the productid and
quantity ordered. I'm sure there are probably better ways, but here's
one thats tried and tested.
<cfset NoFormFields = ListLen(form.fieldnames)>
<!--- Loop through all the form fields --->
<cfloop from="1" to="#NoFormFields#" index="i">
<cfset thisFieldName = lcase(ListGetAt(form.fieldnames,i))>
<!--- Check to see if this field is a Quanity Field --->
<cfif ListFirst(thisFieldName,"_") EQ "quantity">
<!--- It is, so get the productID off the end of the variable
name --->
<cfset thisProductID = ListLast(thisFieldName,"_")>
<cfset thisOrderQty = form[thisFieldName]>
<!--- Now insert the Order Item into the table with an OrderID
that was previously generated --->
<cfquery name="InsertOrderLine" datasource="YourDSN">
INSERT INTO OrderItem (OrderID,ProductID,OrderQty)
VALUES (#thisOrderID#,#thisProductID#,#thisOrderQty#)
</cfquery>
</cfif>
</cfloop>
It should go without saying that you need to use all the appropriate
variable scoping and cfqueryparams with any code in this email.
The "thisOrderID" is a value that you've either generated manually,
created using createuuid() or is the ID of the customer order details
record that was stored in the database. Which ever way you create it,
its the unique identifier for this particular order.
To create the summary you would create a JOIN query between your product
table and your order item table to get the details of each product
ordered and the quantity ordered. eg.
SELECT p.ProductID, p.Title, p.Description, p.Price, oi.OrderQty
FROM Product AS P
INNER JOIN OrderItem AS oi ON p.ProductID = oi.ProductID
WHERE oi.OrderID = #thisOrderItem#
You can now loop through this query row by row, outputting the product
details, the quantity ordered and the cost of ordering that many items,
with an total order value at the bottom of the summary.
Well I think thats about it... I hope that helps and hope I didn't go
off at a complete tangent, completely misinterprete your question or try
to teach my grandmother to suck eggs.
Regards
Stephen
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:192856
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