Copy link to clipboard
Copied
So I have the page cart.cfm
Probably like a lot of similar pages, it's job is to respond to various forms around the website
View Cart > simply displays the contents of the Cart
Add to Cart > submits a productID to cart.cfm
Update Cart > submits QTY rows to cart.cfm, which updates the cart (and deletes rows if QTY=0)
Checkout > as Update Cart, but also displays checkout screens1, 2 & 3
I need to separate Checkout from cart.cfm , and create a new page called checkout.cfm
i'm just wondering what's the best way to go about it. Is CFLOCATION the best bet ? The user clicks CHECKOUT, cart.cfm catches it, does the Update Cart routine... and then CFLOCATION passes user onto checkout.cfm ?
Copy link to clipboard
Copied
Depends somewhat WHY you want to separate "cart" and "checkout". Separating these functions is probably a good idea. It sounds like you are turning "cart" into a bit of a controller.
But it is good to remember how <cflocation...> really works. It involves a round trip with the client browser. When you put a <cflocation...> on a page, ColdFusion sends a HTTP 302 "Temporary Redirect" to the client. This is basically saying to the browser, "The page you wanted doesn't exist here right now. For the time being it exists here." The browser goes, "OK" and repeats the request to the new page.
This works. But I dislike the extra round trip and the the misrepresented messages that content has been moved, when really you just want to move the flow from file A to file B.
I usually try to work it out that this gets done on the server with other features such as includes, custom tags, components or something else.
Copy link to clipboard
Copied
Great info
Agreed, I think I'm giving the cart.cfm page too much to do, in that it's handling checkout along with lots of other things. I want to separate cart.cfm & checkout.cfm so I can cleanly switch to HTTPS://www.mysite.com/checkout.cfm without disrupting any form data like I was doing before.
Checkout is a button on my form
I see it's job as 2 fold:
1) To perform a last update to the shopping Cart using the form (row's of data who's QTY may have changed by the user) to do the update
2) To handle the user's checkout
I want to perform 1) then make a clean break to https://www.mysite.com/checkout.cfm to do 2)
Copy link to clipboard
Copied
Instead of just seperating the checkout logic from the cart logic. Maybe you should seperate them both from the flow control logic.
Then you would have a true (albeit probably a small) controller. This page is where you submit all the forms to. It's logic is to say "What needs to happen now". When updates to the cart are supposed to happen, the cart page logic is accessed. When a checkout is supposed to happen, the checkout logic is accessed.
Copy link to clipboard
Copied
you've lost me - do you have an example demonstrating this technique ?
Copy link to clipboard
Copied
you mean something like this ?
controller.cfm
<cfif is definted ("form.submit")>
switch(form.submit) {
case "viewCart": <cfinclude template="../cart/viewCart.cfm" case "updateCart": <cfinclude template="../cart/updateCart.cfm" } //end switch
</cfif>
Copy link to clipboard
Copied
Looking at AMAZON for inspiration, I see they don't integrate the checkout button with the shopping cart form.
They rely on the user utilising the "update" button to ensure quanitites are correct
Their "checkout" button is simply a hyperlink to the https://checkout screen, so I've followed their lead and implemented the same system.