Jump to content

Can I access cart item count (and other smart variables?) from hooks?


LeonardChallis

Recommended Posts

I am modifying my primary and secondary menu, as suggested in the Editing Client Area Menus documentation. I Want to move the View Cart link down in to the secondary navbar, along with a cart icon and a badge with the number of items. It's that last part I'm stuck with. So far I have this:

 

$secondaryNavbar->addChild('View Cart')->setLabel(Lang::trans('viewcart'))->setUri('/cart.php?a=view')->setOrder(20)->setIcon('fa-shopping-cart')->setBadge('X');

 

Where 'X' is, I wish to put the cart items count. I see in header.tpl there is $cartitemcount, but I can't seem to find out a way, or even if it's possible, to access this information? I saw in the documentation the use of Lang::trans, so I can only hope there are more available to me. If so, I'd really appreciate a link to the documentation for this - even if it's just general smarty stuff.

 

Many thanks

Link to comment
Share on other sites

I was wondering if anyone had any further information on the availability of (template) variables in hooks for me?

depends on what variable you want to reference and on what type of hook! :)

 

e.g the clientareapage action hook has access to the smarty variables, but I don't believe the navigation hooks do.

 

so, if you're thinking purely of the navigation hooks, then forget Smarty - you need to find alternative routes to the value you want; as in the above code, using the session might be one solution... for other purposes, you might be able to use the WHMCS Class variables (http://docs.whmcs.com/classes/namespaces/WHMCS.html) or query the database... there are nearly always other paths to the info you want. :idea:

 

tbh, the documentation on the navigation hooks isn't great - and I wouldn't even guarantee that all of their example hooks are coded correctly and work without issue.

 

anyway, the chances are that whatever you want to do with the nav hooks has already been posted in these forums (or a previous solution could be applied to your situation).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated