There's not enough information here to tell you EXACTLY what to do. However, an overview of what you need to do follows. You need to alter your coupon creation code to add the ability to select products or groups of products, depending on your organization, to which the coupon will apply. Then you'll need to alter the function below such that it checks a person's cart contents against a query for the products in the valid groups...
So in the coupon creation, they should be able to select product categories (jerseys...) or specific products. Then in the isValid function you should check, given the coupon code, whether it's limited to a certain group of products. Then you'll just check the cart to see if the products there meet the criterion. You can be as specific as you like too. You could make it such that they're good for specific products or you could make them invalid for specific products... --Ferg Mike | NZSolutions Ltd wrote: >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 > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:225827 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=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

