<!--#include file="../owFunctions/I_GeneralFunctions.asp"-->
<!--#include file="../owTemplates/Template_AllLeft.asp"-->
<%
	'************************************************************************************
	'*																					*
	'*	MODIFICATION TO THIS SCRIPT OR ANY FILES INCLUDED WITH 							*
	'*		ONEWORLDSTORE IS DONE AT YOUR OWN RISK!										*
	'*	Product  : OneWorldStore														*
	'*	Version  : 9.0000																*
	'*	Modified : June 2004															*
	'*	Copyright:	Copyright (C) 2004 OneWorldStore.Com								*
	'*				Registration Number: 1024507										*
	'*				http://strategis.ic.gc.ca/											*
	'*																					*
	'************************************************************************************


	'************************************************************************************
	'*																					*
	'*																					*
	'*																					*
	'************************************************************************************
	Sub ActionSubroutine()

		' iterate through cart rows
		sSQLText = "SELECT idCartRow FROM CartProducts WHERE IDCart=" & sIDCart
		Call DB_getFromDatabase(sSQLText, rsStoreData, "cancelOrder") 
		While ( NOT rsStoreData.EOF )
			sSQLText = "DELETE FROM CartProductsOptions WHERE idCartRow=" & rsStoreData("idCartRow")
			call DB_updateDatabase(sSQLText) 
			rsStoreData.MoveNext
		Wend
		Call DB_closeRecordset(rsStoreData)

		' delete CartProducts
		call DB_updateDatabase("DELETE FROM CartProducts WHERE IDCart=" & sIDCart)
		
		' see if an order has been saved in the orders tables as unfinalized
		sSQLText = "SELECT idOrder FROM Orders WHERE SessionID = '" & Session.SessionID & "' AND OrderStatus = 7"
		Call DB_getFromDatabase(sSQLText, rsStoreData, "")
		If ( NOT rsStoreData.EOF ) Then
			' the customer has either refreshed the page or left and come back, possible w/ different contents of their cart, or different
			'	shipping, taxes, etc. So, delete the order information that's in the database now and recreate it below
			sIDOrder = rsStoreData("idOrder")
			Call DB_updateDatabase("DELETE FROM OrdersProdOptions WHERE idOrder = " & sIDOrder)
			Call DB_updateDatabase("DELETE FROM OrdersProdRef WHERE idOrder = " & sIDOrder)
			call DB_updateDatabase("DELETE FROM OrdersCreditCards WHERE idOrder=" & sIDOrder)
			call DB_updateDatabase("DELETE FROM ordersTaxes WHERE idOrder=" & sIDOrder)
			call DB_updateDatabase("DELETE FROM orders WHERE idOrder = " & sIDOrder)
		End If
		Call DB_closeRecordset(rsStoreData)
		
		' redirect to store home
		response.redirect "../Default.asp"

	End Sub
	'************************************************************************************
%>