[ic] Non Standard Pricing

quzax me@quzax.com
Thu, 26 Apr 2001 22:34:58 -0600

All of the items that will be placed in the shopping cart have the same
price and price breaks are based on how many items you buy.  Ie:  buy 3 get
1 free.  I had it figured out in theory how to make this happen but things
seem to be failing me at step one in implementation.

This is a little script that will count the number of items in the cart &
display some extra items they may get for free if they bought more than 3

[perl interpolate=1]
  my $var = [nitems] || 0;
  my @items = ();
  my $items = '';
  my $out = '';
  foreach (@items) {
    $items = $items . " $_";
  if ( ($var >= 3) && !($items =~ /F/) ) {
    $out = '
       For purchasing 3 items you may choose a FREE item:
                [order 001F]Free Item #1[/order],
                [order 002F]Free Item #2[/order],
                [order 003F]Free Item #3[/order],
                [order 004F]Free Item #4[/order],
                [order 005F]Free Item #5[/order],

It's not exactly what you want but I think it will give you a good start. in
this example the free items were entered as seperate products in the
database with a cost of $0.

The [nitems] tag returns either the total number of items in the cart or the
number of unique items (doesn't account for quantitys) I don't remember
which & I didn't see an explanation in the docs, but I recall that it does
one or the other. Sorry I don't remember which.

This is very strange as I am not echoing the variable in my code.  This of
course could be entirely skipped if I could get a list of all of the
variables available to me and just pull the total number of unique items
from interchange.  ( is there such a list somewhere? )

If I remember right there is a thing in the perl tag that if there is only 1
variable used it is automatically returned.