From: Guido Sohne To: interchange-users@interchange.redhat.com Subject: [ic] HOWTO: minimum and batch quantities I've recently implemented batch and minimum quantities for an Interchange store. There may be others who one day could need to implement this same functionality. Here's how I did it ... Definitions: minimum quantity is the least number of items for a given sku than can be ordered. batch quantity always exactly divides the number of items (above the minimum quantity) that must be ordered at once Step One: Change your products database to include two extra fields: min_qty and batch_qty For a SQL database, you can use this: ALTER TABLE PRODUCTS ADD COLUMN min_qty VARCHAR(4); ALTER TABLE PRODUCTS ADD COLUMN batch_qty VARCHAR(4); Step Two: In your shopping cart page (usually ord/basket.html or similar file), add a [batch] tag before the [item-list] tag. If you would like to display a message to the user of the catalog when quantities have to be adjusted to meet the minimum and batch quantity requirement, then include the code below in your shopping cart page at the location you want the message to appear. [perl]$Items->[[item-increment]-1]->{message}[/perl] Step Three: Edit your catalog.cfg and add the code below to it. You may want to customize the message that will be displayed when quantities are adjusted by [batch] UserTag batch Routine <[$index]{code}; my $oqty = $Vend::Items->[$index]{quantity}; my $base = $Vend::Items->[$index]{mv_ib}; my $nqty = $oqty; my $batches = undef; my $min = Vend::Data::database_field($base, $code, "min_qty", undef); my $batch = Vend::Data::database_field($base, $code, "batch_qty", undef); $batch = 1 if $batch <= 1; $min = 1 if $min <= 1; $nqty = 0 if $nqty <= $min; $nqty = $nqty - $min if $nqty > $min; $batches = int($nqty / $batch); $nqty = $min + $batches * $batch; my $message = <

You must order at least $min items.

Additional items must ordered in multiples of $batch.

EOM $Vend::Items->[$index]{quantity} = $nqty; $Vend::Items->[$index]{message} = $message if $oqty != $nqty; $Vend::Items->[$index]{message} = "" if $oqty == $nqty; }} EOR Voila!!!! Minimum and batch quantities. Shaken, not stirred. __________________________________________________ Terrorist Attacks on U.S. - How can you help? Donate cash, emergency relief information http://dailynews.yahoo.com/fc/US/Emergency_Information/ _______________________________________________ interchange-users mailing list interchange-users@interchange.redhat.com http://interchange.redhat.com/mailman/listinfo/interchange-users