[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
RE: [ic] Calculating quantity of items
At 05:38 PM 6/13/01 , you wrote:
>Hi Mike:
>
>Thanks, that's not so hard after all! The only thing is, however, I would
>like to put items with the same SKU on a different line UNLESS they have the
>same options. My options each have their own unique code, is there a way to
>do this?
>
You could use a custom usertag like the one below.
Set seperateitems to yes in catalog.cfg
and add the tag [basket_combine] at the top of the
basket page.
Note: this worked with MV 3 and 4, have not tried with IC, but
I believe it should work.
UserTag basket_combine Order quantity
UserTag basket_combine 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++) {
# now check if 'code' (sku) matches
next REMAIN unless ($$cart[$x]{code} eq $$cart[$y]{code});
foreach (keys %{ $$cart[$y] }) {
# now check that all attributes match (except qty of course)
next REMAIN unless ($_ =~ /quantity/i ||
$$cart[$x]{$_} eq $$cart[$y]{$_});
}
# we have checked all atb's match, so combine item qty's
$$cart[$x]{quantity} += $$cart[$y]{quantity};
# now remove this duplicate
splice(@$cart, $y, 1);
}
}
return '';
}
EOR
Kyle Cook