Sorry to sound so hack-like, but how about putting a code in the coupon (coupon = jer456 or jer897 for a coupon meant for a jersey) that specifies what the coupon specifically applies to, with a generic code which specifies no required product (coupon = gen345 for generic). Then if the coupon is not generic, meaning a specific product should be in the cart, call a function that loops over cart contents looking for the specific product type, returning pass/fail result.
Mark -----Original Message----- From: Mike | NZSolutions Ltd [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 30, 2005 9:17 PM To: CF-Talk Subject: Shopping Cart Coupon facility hi there, i have the following function which checks the validity of a coupon code at checkout time. when uploading a new coupon, the site admin can specify a minimum amount spent as well as having it available for any purchase... ---------------------------------- <cffunction name="isValid" output="false" access="public" returntype="numeric"> <cfargument name="promotion_uuid" type="string" required="true"> <cfargument name="customer_id" type="numeric" required="true"> <cfargument name="order_subtotal" type="numeric" required="true"> <cfquery name="getPromotion" datasource="#Request.App.dsn#" password="#Request.App.DBpassword#" username="#Request.App.DBusername#"> SELECT promotion_id FROM promotions WHERE promotion_uuid = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.promotion_uuid#"> AND dExpiry >= <cfqueryparam cfsqltype="cf_sql_date" value="#now()#"> AND amount_min <= <cfqueryparam cfsqltype="cf_sql_decimal" value="#arguments.order_subtotal#" scale="2"> AND enabled = <cfqueryparam cfsqltype="cf_sql_bit" value="1"> </cfquery> <cfif getPromotion.recordcount> <cfquery name="isRedeemed" datasource="#Request.App.dsn#" password="#Request.App.DBpassword#" username="#Request.App.DBusername#"> SELECT promotion_id FROM promotions_to_customer WHERE promotion_id = <cfqueryparam cfsqltype="cf_sql_integer" value="#getPromotion.promotion_id#"> AND customer_id = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.customer_id#"> </cfquery> <cfif isRedeemed.recordcount> <!--- alert customer that this promotion has already been used ---> <cfreturn -1/> <cfelse> <cfreturn getPromotion.promotion_id/> </cfif> <cfelse> <!--- alert customer that this promotion does not exist or order sub total is invalid ---> <cfreturn 0/> </cfif> </cffunction> ---------------------------------- now, the client has requested that a particular coupon only be available if the customer has a selected product (or product type eg. jerseys) in their cart. i am a bit lost as to how i should be modifying the above to account for this. any help would be really appreciated. Regards Mike ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:225814 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54