[ic] Re: intercept item insert in cart

Alessandro Poletto pollok at gmail.com
Fri Aug 12 10:59:36 EDT 2005


Many thanks to all for the help.

I'm starting with the modification of the add_item code

the original code is:
===================
sub add_item {
        my ($self,$cart,$item) = @_;

        push (@{$self->{actions}},
                  ['ADDITEM', {code => $item->{'code'},
                                           description =>
item_description($item),
                                           category => item_category($item)
                                          }]);
}
==================

and for me is not so simple to understand.... (sigh!)
in Mike's mail there's the sugget to modify this code inserting in
interchange.cfg

==================
GlobalSub override_track <<EOS
sub {
       package Vend::Track;
       sub add_item {
               whatever_you_want_to_do();
               return;
       }
}
EOS
==================

before making disasters I suppose to make this:

==================
GlobalSub override_track <<EOS
sub {
       package Vend::Track;
       sub add_item {
         my ($self,$cart,$item) = @_;

         push (@{$self->{actions}},
                  ['ADDITEM', {code => $item->{'code'},
                                           description =>
item_description($item),
                                           category => item_category($item)
                                          }]);


               whatever_you_want_to_do();
               return;
       }
}
EOS
==================

is the right way?
could someone explain me what exactly made the original code?

Again: many thanks to all


On 8/12/05, Mike Heins <mike at perusion.com> wrote:
> Quoting Ethan Rowe (ethan at endpoint.com):
> > Mike Heins wrote:
> > >Quoting Ethan Rowe (ethan at endpoint.com):
> > >>ic at 3edge.com wrote:
> > >>
> > >>>Alessandro Poletto writes:
> > >>>If you are using the foundation store I think you want to take a look in:
> > >>>templates/components/cart
> > >>>There's the information that is shown in the shopping cart ... and the
> > >>>SKU of the item in the basket is then [item-code] afaik.
> > >>>I would think though that on average the placing of an item in the
> > >>>shopping cart is logged (in some session files(?)) and you could
> > >>>probably write something to analyse those? But not sure about that.
> > >>>
> > >>>
> > >>>
> > >>I have a CartTrigger directive I'm planning on submitting to the core
> > >>group for inclusion in the main Interchange distribution once I've
> > >>tested it a bit more... it's only a week old or so.  It allows you to
> > >>specify subroutines to execute whenever the cart contents change; the
> > >>changes are passed to the subroutine such that the sub gets a reference
> > >>to the affected cart, the new row, the old row, the action that
> > >>occurred, and the cart name.  But it isn't ready just yet, and will of
> > >>course need review by the IC core group.  Thus far it's working
> > >>reasonably well, but my tests have been pretty simple.
> > >>
> > >>
> > >>
> > >
> > >Could you look at modifying the existing ItemAction directive
> > >for this?
> > >
> > >
> > >
> > Sure; if you have any words of wisdom on the subject, feel free to send
> > 'em along (either to me personally, here, or core list)...
> 
> I don't know that anyone uses ItemAction except for me. The problem with
> it is that you need a key based on SKU, which is kind of hard to
> generalize actions with.
> 
> Since it is a code reference, it is pretty flexible and it could be used
> directly. The existing one is called only during the "toss" routine.
> 
> Looking at your short description above, it may not make sense
> to try and use it. But if it does, with some sort of ALL_ITEMS
> key in ItemAction or something, please do.
> 
> --
> Mike Heins
> Perusion -- Expert Interchange Consulting    http://www.perusion.com/
> phone +1.765.647.1295  tollfree 800-949-1889 <mike at perusion.com>
> 
> I have a cop friend who thinks he ought be able to give a new ticket;
> "too dumb for conditions".
> _______________________________________________
> interchange-users mailing list
> interchange-users at icdevgroup.org
> http://www.icdevgroup.org/mailman/listinfo/interchange-users
>



More information about the interchange-users mailing list