[ic] order same items several time

Kyle Cook interchange-users@interchange.redhat.com
Tue Sep 4 01:51:00 2001


At 03:34 PM 9/3/01, you wrote:
>On Mon, 3 Sep 2001, Xiaowen Wu wrote:
>
>XW>>Hi there, I have a simple question: when the user orders the same item
>XW>>several time, they are shown as difference order entries in the basket,
>XW>>are there anyway to combine them as one ?
>
>In catalog.cfg there is an option for 'SeparateItems'
>
>HOWEVER!!!!
>
>I have an item in my store that is available in white, red and blue, as
>well as small, medium, and large - all at the same price.
>
>A customer wanted a blue one in large, and a red one in medium. He
>couldn't do it because it was combining the items. His only option was
>to place 2 separate orders.
>
>I have since turned that option off.
>
>
>-= Jim =-


Maybe someone can use something like the following which will
combine only if the attributes match, use it with SeperateItems yes
and put the [recombine] tag on top of the basket page.

(Note was written for old MV3.xx, but should still work in IC.)

Kyle

UserTag recombine Routine <<EOR
sub {
my $cart = $Vend::Items;
# Combine all similar products if attributes match
for (my $x=0;$x < @$cart;$x++) {
   REMAIN: for (my $y=$x+1;$y < @$cart;$y++) {
     next REMAIN unless ($$cart[$x]{code} eq $$cart[$y]{code});
     foreach (keys %{ $$cart[$y] }) {
       next REMAIN unless ($_ =~ /quantity|mv_price/i || $$cart[$x]{$_} eq 
$$cart[$y]{$_});
     }
     # we have checked all attributes, so combine items
     $$cart[$x]{quantity} += $$cart[$y]{quantity};
     splice(@$cart, $y, 1);
   }
}
return '';
}
EOR