apeisa/Shop-for-ProcessWire — pull request #5 by somatonic (2013-09-24 09:32:48+00:00)
Title: moved actions to ready() to be able to hook into methods, made addProduc...

...tToCart hookable

As example for use of the hook. I have a hook to show a message on front-end when adding or removing item.

```
/**
* show message when product added to cart
*/
public function addToCartHook(HookEvent $event) {
$qty = $event->arguments("qty");
$product = $event->arguments("product");
if (strpos($product->template->name, "repeater_") === 0) {
$page = $product->getForPage(); // get page where repeater lives
$title = $page->title . ": " . $product->title;
} else {
$title = $product->title;
}
if($qty < 1 && $event->return == true) {
wire("session")->message("$title entfernt");
} elseif($event->return == true) {
wire("session")->message("$qty x $title hinzugefügt");
}
}
```