Tom Wilson Posted April 27, 2019 Share Posted April 27, 2019 Hello! I've created a custom page for web hosting , however, when you go to Store and then Web Hosting, it goes to the cart grid view. How do I make it go to the page? Thanks! 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted April 28, 2019 Share Posted April 28, 2019 21 hours ago, Tom Wilson said: I've created a custom page for web hosting , however, when you go to Store and then Web Hosting, it goes to the cart grid view. that implies that you've got a product group called "Web Hosting" because that Store dropdown menu is effectively just a foreach loop through the product groupnames... with MC Products Groups, domain reg/trans etc added to the end. 21 hours ago, Tom Wilson said: How do I make it go to the page? if the above is true, then you'd need to use a hook to change the link... there's a much quicker way to do it than the hook below, but i'm covering you needing to change multiple links to this array and reducing the chances of errors... <?php # Change Store Navbar Links Hook # Written by brian! use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function(MenuItem $primaryNavbar) { $Store = $primaryNavbar->getChild("Store"); if (empty($Store)) { return; } $StoreChildren = $Store->getChildren(); $kidslinks = array("Web Hosting", "VPS Servers"); foreach($StoreChildren as $key => $Store_details_child) { if (in_array($key, $kidslinks)) { if ($key === "Web Hosting"){$newlink = "webhosting.php";} elseif ($key === "VPS Servers"){$newlink = "vps.php";} $Store->getChild($key)->setUri($newlink); } } }); you can remove the VPS stuff - that's only there to show you how to add more than just Web Hosting to your changed links... change the values of $newlink to the appropriate filenames or URLs. 0 Quote Link to comment Share on other sites More sharing options...
Tom Wilson Posted April 28, 2019 Author Share Posted April 28, 2019 2 hours ago, brian! said: that implies that you've got a product group called "Web Hosting" because that Store dropdown menu is effectively just a foreach loop through the product groupnames... with MC Products Groups, domain reg/trans etc added to the end. if the above is true, then you'd need to use a hook to change the link... there's a much quicker way to do it than the hook below, but i'm covering you needing to change multiple links to this array and reducing the chances of errors... <?php # Change Store Navbar Links Hook # Written by brian! use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function(MenuItem $primaryNavbar) { $Store = $primaryNavbar->getChild("Store"); if (empty($Store)) { return; } $StoreChildren = $Store->getChildren(); $kidslinks = array("Web Hosting", "VPS Servers"); foreach($StoreChildren as $key => $Store_details_child) { if (in_array($key, $kidslinks)) { if ($key === "Web Hosting"){$newlink = "webhosting.php";} elseif ($key === "VPS Servers"){$newlink = "vps.php";} $Store->getChild($key)->setUri($newlink); } } }); you can remove the VPS stuff - that's only there to show you how to add more than just Web Hosting to your changed links... change the values of $newlink to the appropriate filenames or URLs. Thank you! Now I wan to add Web Hosting back to the Store drop, how do I do this? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted April 29, 2019 Share Posted April 29, 2019 19 hours ago, Tom Wilson said: Now I want to add Web Hosting back to the Store drop, how do I do this? why? if you wanted both a link to your web hosting page AND a link to those web hosting products in the cart, then the above hook is redundant - there's no point in changing an existing link, they have to recreate it again using the original URL... that would be insane. you could leave the cart link as is, and just add a new link to the Store dropdown as shown in the thread below... https://docs.whmcs.com/Client_Area_Navigation_Menus_Cheatsheet#Adding_a_Menu_Item ... but where that hook uses 'Support', change that to 'Store' and then adjust the other parts to suit your need... you can't have two children with the same name, so where it says... ->addChild('Emergency Contacts', - you can't use "Web Hosting" in there if your product group is called "Web Hosting" - call it something different and then you can set it's label to be "Web Hosting" or whatever. 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.