[ic] execute upon add to cart

Chaim Klar interchange-users@icdevgroup.org
Tue Dec 3 15:42:01 2002


 > Quoting Mike Heins:
 >
 > There is an ItemAction facility. It allows a subroutine to be
 > attached to a particular item code, and is called upon the
 > "toss" portion, i.e. after something is added.
 >
 > It would be specified:
 >
 > ItemAction  os28004 <<EOR
 > sub {
 > 	my $item = shift;
 > 	Log("$item->{code} is in the cart");
 > }
 > EOR
 >
 > I have not trumpeted this, because it is not really generally useful.
 > What people understandably want is the ability to trigger an action
 > based on a category.
 >
 > I have thought of ways to specify routines for particular actions
 > ala Autoload, i.e.:
 >
 > 	PreAction  add_items <<EOR
 > 	sub {
 > 		some_stuff_prior_to_cart_add();
 > 	}
 > 	EOR
 >
 > 	PostAction  add_items <<EOR
 > 	sub {
 > 		some_stuff_prior_to_cart_add();
 > 	}
 > 	EOR
 >
 > You can also change the "order" and "process" actions via FormAction
 > if you want; or you can override Vend::Order::add_item and customize it.
 >

Thank You Mike.

The reason I need this hook is to log to my own session tracking table, So I
want to know when an item is being added to the cart. But the problem with
overriding "Vend::Order::add_item" is that I can only override it but I
don't know if I can inherit it.

In the end I am overriding "sub add_item" from "Vend::Track" which gets
called when adding an item to the cart.

But it would definitely be a much cleaner solution to have this action hooks
you mentioned.

Thank You
Chaim Klar