Blesta Addons Posted March 27, 2016 Report Share Posted March 27, 2016 i have my own order_type , i want to make some extra validation when a cart is updated . in my order_type_xxxx.php i have the update item callabeck , but is not triggers when i update or edit the cart item . and to make sur is working , i have made a simple function , when a product is updated/edited the updateItem callback should normally empty the cart , but is not working !!! public function updateItem(EventObject $event) { $this->cart->emptyCart(); } is something i need to do or any error in my part ? ADDED : the same for remove item event , no result public function removeItem(EventObject $event) { // $params = $event->getParams(); $this->cart->emptyCart(); } Quote Link to comment Share on other sites More sharing options...
Tyson Posted March 28, 2016 Report Share Posted March 28, 2016 There are no event handlers for the Order plugin. Unless you defined your own event handlers for updating/removing from the cart, those methods you wrote would never be called. Michael 1 Quote Link to comment Share on other sites More sharing options...
Blesta Addons Posted March 28, 2016 Author Report Share Posted March 28, 2016 i'm talking about the order_types . if you look to order_type_domain.php you will find a events like public function prequeueItem(EventObject $event) {} and public function addItem(EventObject $event) {} and they are working and i'm using them . but the updateItem() and removeItem() event not working . from session cart componenets /** * Adds an item to the cart * * @param mixed $item The item to add to the cart * @return int The index the item was added to */ public function addItem($item) { $cart = $this->get(); $i = count($cart['items']); $cart['items'][$i] = $item; $this->setData("items", $cart['items']); $event = new EventObject("SessionCart." . $this->cart_name . ".addItem", array('item' => $item, 'index' => $i)); $this->Events->trigger($event); return $i; } /** * Update an item in the cart * * @param int $index The index to update * @param mixed $item The item to update at the given index */ public function updateItem($index, $item) { $cart = $this->get(); $cart['items'][$index] = $item; $this->setData("items", $cart['items']); $event = new EventObject("SessionCart." . $this->cart_name . ".updateItem", array('item' => $item, 'index' => $index)); $this->Events->trigger($event); } Quote Link to comment Share on other sites More sharing options...
Blesta Addons Posted March 28, 2016 Author Report Share Posted March 28, 2016 Hello Tyson , i found it , i should add the callback first in the order_type public function setCart(SessionCart $cart) { parent::setCart($cart); $this->cart->setCallback("prequeueItem", array($this, "prequeueItem")); $this->cart->setCallback("addItem", array($this, "addItem")); } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.