<cfcomponent output="false">

<!--- addItem() function --->
<cffunction name="addItem" access="remote" output="false" returnType="void"
            hint="Adds an item to the session’s shopping cart.">
 
	<!--- Required argument: MerchID --->
	<cfargument name="merchID" type="numeric" required="Yes">
	
	<!--- Call the Add() method of the ShoppingCart CFC --->
	<cfinvoke component="#SESSION.myShoppingCart#" method="add" 
           merchID="#ARGUMENTS.merchID#">

</cffunction> 
 

<!--- getItemCount() function --->
<cffunction name="getItemCount" returnType="numeric" access="Remote" 
            output="false">
 
  <cfset var cartContents = "">
  <cfset var getCount = "">
  
	<!--- Call the List() method of the ShoppingCart CFC --->
	<cfinvoke component="#SESSION.myShoppingCart#" method="list"
            returnVariable="cartContents">
	 
	<!--- Use Query-of-Queries to get the number of items in cart --->
	<cfquery dbtype="query" name="getCount">
	SELECT SUM(Quantity) AS ItemCount
	FROM CartContents
	</cfquery>
	
	<!--- Return the total number of items to Flash ---> 
	<cfreturn val(getCount.ItemCount)>
</cffunction>

</cfcomponent>
