30ml Posted September 16, 2013 Share Posted September 16, 2013 (edited) hi, I have a hook in "hookDisplayProductButtons". There, I am going to control total products in cart. How can I detect these information from prestashop. I have seen all available variable in smarty but how can I use these's smarty variable in php file. My below code trying to use smarty variable. Here, I need to do some stuff smarty variable's value in php. public function hookDisplayProductButtons($params) { global $smarty; $myCart = new CartCore(); $this->context->smarty->assign(array( 'output' => $this->context->smarty->cart_qties>value; )); return $this->display(__FILE__, 'views/templates/front/displayProductButtons.tpl', $this->getCacheId('subscriber')); } Here, I got this error while I try to use smarty vaiable. Notice: Undefined property: Smarty::$cart_qties in C:\xampp\htdocs\prestashop\tools\smarty\Smarty.class.php on line 676 Notice: Trying to get property of non-object in C:\xampp\htdocs\prestashop\modules\subscriber\subscriber.php on line 409 That would be milestone if you give some hint and thanks you dud Edited September 17, 2013 by 30ml (see edit history) Link to comment Share on other sites More sharing options...
PascalVG Posted September 16, 2013 Share Posted September 16, 2013 Probably something like this: public function hookDisplayProductButtons($params) { $this->smarty->assign(array( 'cart_qties' => $this->context->cart->nbProducts() )); return $this->display(__FILE__, 'views/templates/front/displayProductButtons.tpl'); } Hope this does the trick (didn't try the code, but expect this to do something...) pascal N.B. Never use the xxxCore class, always use the xxx, like $cart = new Cart(), NOT $cart = new CartCore() Link to comment Share on other sites More sharing options...
PascalVG Posted September 16, 2013 Share Posted September 16, 2013 Also, when developing for PrestaShop, have a good look here first... http://doc.prestashop.com/display/PS15/Developer+Guide Link to comment Share on other sites More sharing options...
30ml Posted September 17, 2013 Author Share Posted September 17, 2013 Also, when developing for PrestaShop, have a good look here first... http://doc.prestashop.com/display/PS15/Developer+Guide thanks it works. $this->context->cart->nbProducts() Link to comment Share on other sites More sharing options...
PascalVG Posted September 17, 2013 Share Posted September 17, 2013 Good to hear! I'll mark the topic as solved :-) Happy selling, pascal Link to comment Share on other sites More sharing options...
30ml Posted September 17, 2013 Author Share Posted September 17, 2013 Good to hear! I'll mark the topic as solved :-) Happy selling, pascal Yes, sure normally I can not from here to mark as solved. Link to comment Share on other sites More sharing options...
PascalVG Posted September 17, 2013 Share Posted September 17, 2013 30ml, You can do this (next time) yourself, by editing your very first post of the topic. Then click Full Editor. The title field will be editable then. Add [sOLVED] at the front of your original title and save. pascal 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