robinhood791 Posted December 19, 2019 Share Posted December 19, 2019 Hello, I'm currently working on our new web design for our WHMCS,and made a hook that gets some information about our product groups. That is the name and the product tagline. This hook only works on the home page but needs to work on all of the pages. This might be really stupid, but I really didn't see the solution. The hook: <?php use Illuminate\Database\Capsule\Manager as Capsule; function hook_getProductGroups($vars){ # Get Product Groups $getProductGroups = Capsule::table('tblproductgroups') ->where('tblproductgroups.hidden', '0') ->select('id', 'name', 'tagline') ->orderBy('order', 'asc') ->get(); $encodedata = json_encode($getProductGroups); $decodedata = json_decode($encodedata, true); return array("productgroups" => $decodedata); } add_hook("ClientAreaPageHome", 1, "hook_getProductGroups"); The code: {foreach $productgroups as $pgroup} <a href="cart.php?gid={$pgroup.id}">{$pgroup.name} {if $pgroup.tagline} <br> <p>{$pgroup.tagline} <i style="margin-left: 1rem;" class="fas fa-arrow-right"></i></p> {/if} </a> {/foreach} I think it has something to do with the add_hook thing, but I haven't found it yet. Hope someone can help me here. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted December 20, 2019 Share Posted December 20, 2019 13 hours ago, robinhood791 said: I'm currently working on our new web design for our WHMCS,and made a hook that gets some information about our product groups. I recognise that hook! 🙂 13 hours ago, robinhood791 said: This might be really stupid, but I really didn't see the solution. you would just need to change ClientAreaPageHome to ClientAreaPage - if you do that, the hook will run on (virtually) every client area page. generally, I tend to suggest only running hooks on the pages where they're needed (to avoid unnecessary resource usage) - but if it's only one hook, it shouldn't make much difference. 0 Quote Link to comment Share on other sites More sharing options...
robinhood791 Posted December 20, 2019 Author Share Posted December 20, 2019 Thanks, that worked! 0 Quote Link to comment Share on other sites More sharing options...
robinhood791 Posted December 20, 2019 Author Share Posted December 20, 2019 I'm currently making a modal to display the shopping cart in. But how do you pull and show the item name(s), price('s), and quantity(s) in that modal (that has to be accessed across all pages)? It the shopping cart stored in a $_SESSION and if so, how do you echo that? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted December 21, 2019 Share Posted December 21, 2019 15 hours ago, robinhood791 said: But how do you pull and show the item name(s), price('s), and quantity(s) in that modal (that has to be accessed across all pages)? with a lot of work... 😓 15 hours ago, robinhood791 said: It the shopping cart stored in a $_SESSION and if so, how do you echo that? the contents of the basket are available in the session (in a limited way) - but from memory, I don't think it will include product names (only their IDs) or prices.. if you're doing this in the template, then you can access the cart session array using {$smarty.session.cart|print_r) - the print_r just expands the array so you can see what's inside it... it might also be helpful to take a look at the cartnumitems.php data feed code in the feeds directory as that accesses the session and can be used on any page when you want to show the number of items in the cart... that should help you too with access the session in php. 0 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.