[ic] Discount to one instance of an item_code

Susan Misnick smisnick at aireagal.com
Wed Mar 3 13:14:30 EST 2004


I've gone round in circles trying to do this several ways, and there 
must be something simple I'm missing.
I'm trying to add a discount to a line item, not to an item-code.  

The basic need is for a buy-one, get one at 50% off.  It's currently in 
place, but uses "item_code", and doesn't work for multiple quantities of 
the same item where one may be discounted and the other not 
(www.aireagal.com).

For marketing, we don't want to show just the average, we want to show 
one line item at full price, and one line item at 50% off.  

 I've got code in my test catalog which takes the multiple quantities 
ordered for one item and separates it into separate line items of 
quantity 1 each.

###
  foreach my $item (@$Items)
  {
     $current_code = $item->{code};
     $current_quantity = $item->{quantity};
     if ($current_quantity > 1)
     {
         $item->{quantity} = 1;
         for ($i=1;$i<$current_quantity;$i++)
         {
           $move = {%$item};
           $move->{quantity} = 1;
           $move->{mv_price} = $Tag->data('inventory', 
'price',$current_code);
           push (@$Items, {%$move});
        }
     }
  }
####

 I can then sort the resulting cart by highest price to lowest price and 
indicate that this line item gets a discount by setting a cart variable 
for this line item.

###
  foreach my $item (sort {$b->{price} <=> $a->{price} } @$Items)
  {
     $even_checker = $loop_counter++ % 2;
     $item->{gets_discount} = !($even_checker);
  }
####

But then, outside of perl,  in my item-list loop for the cart, I don't 
want to set a discount by item_code because it could be that only one 
instance of that item-code is getting discounted.  

So, when I'm not in Perl, what can I check other than [if discount 
[item-code]] to see if my variable has been set.

I also need to change some of the other page logic to look at my 
variable and not "item_code" .

Any hints?




More information about the interchange-users mailing list