Hi. I am trying to understand how to use a very simple shopping cart in Cold Fusion, but am having a hard time. I've tried looking at information on web sites, but they all use a script like this below that fills in the info. into a cart.
Cart = ArrayNew(1);
for ( i=1; i LE cartItems; i=i+1)
Cart.Name="Product " & i;
I would rather use my own form that outputs info. into a table to display to the user and this table could be used as a shopping cart. I've created this very simple form below. Can someone please show me an example of how to make this form into a shopping cart so I can add, update, and delete the items in it? Thank you.
Your question seems very broad. Can you explain what difficulties you are having so we can help you better?
A customer chooses that they want Product 1 and the price is $10.00. I want them to click a button that Adds the item to a shopping cart. Then if they want to continue to choose other products, they can add those items to the shopping cart also. So if they choose Product 2 and the price is $20.00, they click Add to Cart, the Cart total will show $30.00. Then they'll have the option to add more quantities or remove each product that is in their cart. Then later, I will set up a Checkout with Stripe.com that will handle the credit cart information. I need to set up a shopping cart this way because I have a page that is calculating the prices for parts on the fly, so I wouldn't be able to use anything like a CFWebstore or CartWeaver or anything like that since I don't have a database of parts to just output. If you want to see the page I have created, it's located here: Shin-Etsu Polymer Elastomer cut to size Just choose a part number and type in 10 for the Xmm and 10 for the Ymm. You'll notice that after you click one part number and fill in the info. and click update, and then click on a different part number, the table disappears for the first part you chose. I just have a Place Order button at the bottom after you click update that just opens up a pop up screen to call us for now. Can you show me how to get this to work so that if the customer wants to add the first part to shopping cart, they can and then continue ordering other parts? I'm pretty sure I need to use session variables to get this to work, correct? Some of the web sites I've been reading say to use Arrays and Structures too, but I don't understand how to use these. Thanks.
You have a good start. I like your example, "Shin-Etsu Polymer Elastomer cut to size".
You should now
1) change the Update button to Add;
2) add the Delete button
3) use the session scope to maintain the user's shopping-cart across multiple requests.
You could emulate the code in Brian Kotek's article, Create a simple shopping cart using ColdFusion. If you do, note that the last comment in the code should be:
<!—- Add the specified item to the cart. —->
<!—- Delete the specified item from the cart. —->