Skip to main content
July 1, 2008
Question

URL Parameters & Shopping Cart

  • July 1, 2008
  • 11 replies
  • 1704 views
I have made a simple shopping cart from several resources, user comes onto the site and picks a category, the url coding is as follows;

<cfoutput query="catList">
<a href="products.cfm?CatID=#catList.CatId#">#CatName#</a>
</cfoutput>

Which works fine, all the products under the selected Category ID (#CatId#) are displayed. It’s when I click on the “add to cart” or “empty cart” links / button the problem start. It will add the item to the cart as its refreshing the page but the url goes to ../products.cfm so there are no items displayed.

So my question is how can I add the item to the cart but return to the same pages?

Thanks,
Lee
This topic has been closed for replies.

11 replies

Inspiring
July 1, 2008
leemar99 wrote:
> I have made a simple shopping cart from several resources, user comes onto the
> site and picks a category, the url coding is as follows;
>
> <cfoutput query="catList">
> <a href="products.cfm?CatID=#catList.CatId#">#CatName#</a>
> </cfoutput>
>
> Which works fine, all the products under the selected Category ID (#CatId#)
> are displayed. It?s when I click on the ?add to cart? or ?empty cart? links /
> button the problem start. It will add the item to the cart as its refreshing
> the page but the url goes to ../products.cfm so there are no items displayed.
>
> So my question is how can I add the item to the cart but return to the same
> pages?
>
> Thanks,
> Lee
>
>

Where ever your logic is that returns to the page needs to include the
url paramaters in the logic.

On the product page, a couple of sources for these paramters would be
the URL scope and the cgi.query_string value. But neither of these are
going to be preserved from request to request unless you take steps to
do so.

There are many choice on how you preserve the values for use later. The
most common would be to make use of the Session scope. If this is the
first time you have heard of the Session scope it is too big of a topic
for a single e-mail. There are entire chapters on it in the
documentation and books such as Ben Forta's et al. ColdFusion books.