<!--#include file="../owFunctions/I_GeneralFunctions.asp"-->
<!--#include file="../owFunctions/I_Cart.asp"-->
<!--#include file="../owFunctions/I_StoreFront.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/											*
	'*																					*
	'************************************************************************************

	Call SF_OpenPage()
	Call ActionSubroutine()

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

		total = 0
		pSpecialPrice = 0

		if Cint(CART_CountRows())=0 then
			Call owMessage(LANG_DT( "RECALC_EMPTYCART", "Your cart is empty." ), C_ERROR)
		Else
			' iterate through the cart in order to identify wich items have changed the quantity
			sSQLText = "SELECT idCartRow, CartProducts.idProduct, quantity, price, bToBPrice, unitPrice, unitBtoBPrice FROM CartProducts, products WHERE CartProducts.idProduct=products.idProduct AND CartProducts.IDCart=" & sIDCart
			Call DB_getFromDatabase(sSQLText, rsStoreData, "") 
			do while not rsStoreData.eof
				' identify which index item
				if Cdbl(request.form("cant"+Cstr(rsStoreData("idCartRow")))) <> Cdbl(rsStoreData("quantity")) then                  
					pIdProduct		= rsStoreData("idProduct")
					pIdCartRow		= rsStoreData("idCartRow")  
					pNewQuantity	= request.form("cant"+Cstr(rsStoreData("idCartRow")))                  
					pPrice			= rsStoreData("price") 
					pBtoBPrice		= rsStoreData("bToBPrice") 
					pUnitPrice		= rsStoreData("unitPrice") 
					pUnitBtoBPrice	= rsStoreData("unitBtoBPrice") 
	
					pPrice			= replace(pPrice,",",".")
					pBtoBPrice		= replace(pBtoBPrice,",",".")
					pUnitPrice		= replace(pUnitPrice,",",".")
					pUnitBtoBPrice 	= replace(pUnitBToBPrice,",",".")
			
					' update cart quantity and restore original price
					sSQLText = "UPDATE CartProducts SET quantity=" &pNewQuantity& ", unitPrice=" &pPrice& ", unitBtoBPrice=" &pBtoBPrice& " WHERE idCartRow="&pIdCartRow
					call DB_updateDatabase(sSQLText)
	
				End If  ' that product has changed the quantity       
				rsStoreData.movenext
			loop    
			Call DB_closeRecordset(rsStoreData)
			If ( sError = "" ) Then
				response.redirect "owShowCart.asp"
			Else
				Call owMessage(sError, C_ERROR)
			End If
		End If
		
	End Sub
	'************************************************************************************
%>