Hi. I have some session variables for a shopping cart page. I want to set up a button for the user to click to clear the cart. How do I do this? I tried using the StructDelete function, inside a form with a button, but even if I don't click on this and I just click on the Checkout page button instead, it clears the cart before the info. can be inserted into the database on the confirmation page. How do I set this up so that the cart only gets cleared if the button is clicked? Here is what I have:
<cfif NOT StructKeyExists(session,'ElastomerCart')>
<cfset Session.ElastomerCart = StructNew()>
<cfset Session.ElastomerCart.First_Name = "">
<cfset Session.ElastomerCart.Last_Name = "">
<cfset Session.ElastomerCart.Title = "">
<cfset Session.ElastomerCart.Company = "">
<cfset Session.ElastomerCart.Address1 = "">
<cfset Session.ElastomerCart.Address2 = "">
<cfset Session.ElastomerCart.City = "">
<cfset Session.ElastomerCart.State = "">
<cfset Session.ElastomerCart.Zip = "">
<cfset Session.ElastomerCart.Country = "">
<cfset Session.ElastomerCart.Phone = "">
<cfset Session.ElastomerCart.Fax = "">
<cfset Session.ElastomerCart.Email = "">
<cfset Session.ElastomerCart.Products = ArrayNew(2)>
</cfif>
<cfif StructKeyExists(session,'ElastomerCart')>
<form action="ElastomerCart.cfm" method="post">
<cfset StructDelete(session,'ElastomerCart')>
<input type="submit" class="submit" value="Clear Cart">
</form>
</cfif>
Thanks.
Andy