Jump to content

[SOLVED]find out total products in cart


30ml

Recommended Posts

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 by 30ml (see edit history)
Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...