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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:225789 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