Home | Features | Demo | Downloads | About Us | Support | Purchase

Using Bulk Requirements for Wholesalers Only

Here's a modification I had to make for a customer recently, that I thought others might find useful. Basically they needed to not only set different pricing for wholesale customers, they wanted to require them to purchase in bulk as well. But they also serviced normal retail customers as well, and wanted to not require any minimum purchase from them. CFWebstore has a function to require a minimum purchase amount as well as multiples of that amount (so you can force amounts like 6, 12, 18, etc.) but typically it applies to everyone. It's not hard however, to modify the store to make it apply to wholesalers only...you just have to know how! CFWebstore saves a setting to session memory for whether a user is a wholesaler or not, so you can easily use this variable in changing the code. Here's what you need to do:

First, go to the product/listings/put_orderbox.cfm file. This is where you will find the javascript validation routines that will warn the user about the quantity they are trying to buy. First, around line 152 find the line that determines and sets the minimum quantity that is required for this product. Change this line to read:

<cfset MinQuant = iif(qry_get_products.Min_Order GT 0 AND Session.Wholesaler, qry_get_products.Min_Order, 1)>

Now, open up shopping/basket/act_recalc.cfm. This file is where the shopping cart calculations are done and it will make sure that if the user has javascript turned off, or tries to manually edit the quantity, it will get rounded back to the necessary amounts. First change line 37 in the cfscript, which checks that the cart meets the minimum amount. The new line should read:

else if (Session.Wholesaler AND qry_Get_Basket.Min_Order GT 0 AND RowQuantity LT qry_Get_Basket.Min_Order)

And then change line 41 which checks for multiples of the minimum to read:

else if (Session.Wholesaler AND qry_Get_Basket.Min_Order GT 0 AND qry_Get_Basket.Mult_Min IS 1 AND RowQuantity MOD qry_Get_Basket.Min_Order GT 0) {

These changes will now ensure that wholesalers only need to buy in minimum amounts, but you may also want to tweak your product admin form where these amounts are entered (product/admin/products/dsp_price_form.cfm ) so that the merchant understands how they are being used.

Comments
Julie's Gravatar Hello Mary Jo,
I'm trying to implement these changes for wholesalers on our website and am getting an error on the put_orderbox.cfm page.

This is the error message:
   Missing argument name. When using named parameters to a function, every parameter must have a name.<p>The CFML compiler was processing:<ul><li>An expression beginning with iif, on line 154, column 24.This message is usually caused by a problem in the expressions structure.<li>A cfset tag beginning on line 154, column 7.<li>A cfset tag beginning on line 154, column 7.</ul> <br>The error occurred on line 142.

Did I mess something up or miss something?
Thanks for your help!
Julie
# Posted By Julie | 9/9/08 4:26 PM
Mary Jo Sminkey's Gravatar Sorry I missed your question....it's always best to email questions to me directly, not posted on the blog. I would probably need a copy of the code as you've modified it to make sure you have put the changes in the right place. Also make sure you are using this on a current version 6 release.
# Posted By Mary Jo Sminkey | 10/2/08 10:21 AM
 
BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.