[ic] execute upon add to cart

Mike Heins interchange-users@icdevgroup.org
Tue Dec 3 10:51:00 2002


Quoting Chaim Klar (c_klar@c-cs.com):
> HI:
> 
> Can any body tell me how I to hook in code to be executed when ever an item
> is being added to cart.
> 
> (I want this piece of code to be executed no matter how an item is being
> added, so posting a special variable to the cart is not the best solution.)
> 

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.

-- 
Mike Heins
Perusion -- Expert Interchange Consulting    http://www.perusion.com/
phone +1.513.523.7621      <mike@perusion.com>

Any man who is under 30, and is not liberal, has not heart; and any man
who is over 30, and is not a conservative, has not brains.
 -- Winston Churchill