[ic] Calculating quantity of items

Tim Mirecki interchange-users@lists.akopia.com
Thu Jun 14 11:46:02 2001


Hey Kyle:

Thanks it works quite well with Interchange 4.7.2! However there is one very
minor issue. I have links that are updating another frame on the site to add
them to the cart. (using something like this:  a
href="mv_order_item=code&mv_action=return" target="top") This allows the
user to rapidly add items to the cart. Sometimes it will combine SOME of the
items, but not all. I even got it into three groups once, so that the same
item was listed 3 times, each one with a different quantity (This is fine,
however, since the total quantity is correct).

I can live with this, I don't really see it as being a problem...we'll see.

If you have any suggestions, please let me know. Thanks for the help!

Tim

-----Original Message-----
From: interchange-users-admin@developer.akopia.com
[mailto:interchange-users-admin@developer.akopia.com]On Behalf Of
kyle@invisio.com
Sent: Wednesday, June 13, 2001 3:35 PM
To: interchange-users@developer.akopia.com
Subject: 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

_______________________________________________
Interchange-users mailing list
Interchange-users@lists.akopia.com
http://lists.akopia.com/mailman/listinfo/interchange-users