massimopasquali Posted July 21, 2017 Share Posted July 21, 2017 (edited) Hello, I have crete a button in the template Shopping-cart-tpl "RESET CART" for empting the cart. I read a lot of article, how used to create a module and how used to create an hook. in particolar I found this example, but I didn't find an explain how to run an Hook from an action button : class OneProductCart extends Module { public function __construct() { $this->name = 'oneproductcart'; $this->tab = 'front_office_features'; $this->version = '1.0'; $this->author = 'SJousse'; $this->need_instance = 0; parent::__construct(); $this->displayName = $this->l('One Product Cart'); $this->description = $this->l('Keep only last product in cart.'); } public function install() { return (parent::install() && $this->registerHook('actionCartSave')); } public function hookActionCartSave($params) { $cart = $params['cart']; $last = $cart->getLastProduct(); $prods = $cart->getProducts(); foreach ($prods as $prod) if ($prod['id_product'] != $last['id_product']) $cart->deleteProduct($prod['id_product']); [spam-filter] can you tell me a link where I can undestood the Hook? Futhermore, could you tell me how you think to solve the problem thanks in advance Edited July 24, 2017 by massimopasquali (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now