krt463 Posted April 10, 2018 Share Posted April 10, 2018 Hello, I searched the marketplace and couldn't find anything and I'm surprised even searching the forums something didn't turn up. Is there such thing as a module we can associate to a product/service that links the customer to an external URL when they click on it? For example, if you have a hosted product that uses the plesk module, they currently click to "open control panel". I'd like to have a product so they have the option to click and it goes to AnyURLxxxwhatever.com Is there such an animal? Thanks in advance! Ken Link to comment Share on other sites More sharing options...
brian! Posted April 10, 2018 Share Posted April 10, 2018 Hi Ken, 3 hours ago, krt463 said: Is there such thing as a module we can associate to a product/service that links the customer to an external URL when they click on it? For example, if you have a hosted product that uses the plesk module, they currently click to "open control panel". I'd like to have a product so they have the option to click and it goes to AnyURLxxxwhatever.com Is there such an animal? i'm really confused - where and when is this link shown?? during ordering ? after purchase from the client area?? if I could picture how this is to be used, I might be able to make a useful suggestion. Link to comment Share on other sites More sharing options...
krt463 Posted April 11, 2018 Author Share Posted April 11, 2018 Thank you for the reply. Currently, if you have a hosted product, customers can go to the "active" product and click to "open control panel". Id like to create A product and when the customer goes to this product with in the control panel there is a button or a link within the product to click to get access to the URL does this help? Link to comment Share on other sites More sharing options...
brian! Posted April 11, 2018 Share Posted April 11, 2018 10 hours ago, krt463 said: Id like to create A product and when the customer goes to this product with in the control panel there is a button or a link within the product to click to get access to the URL does this help? slightly - though still struggling to picture it.... screenshot might help. with regards to the button/link, where do you want this to be - on the (product details page I assume) itself... or as a link in the Actions sidebar?? Link to comment Share on other sites More sharing options...
krt463 Posted April 11, 2018 Author Share Posted April 11, 2018 47 minutes ago, brian! said: slightly - though still struggling to picture it.... screenshot might help. with regards to the button/link, where do you want this to be - on the (product details page I assume) itself... or as a link in the Actions sidebar?? Thank you again for your reply! I didn't think about the "actions menu", I would say both spots would be ideal. To me more descriptive, when the product is created.....you choose the "Custom URL Module" and from there you can enter "Text" and "External URL" as options so when a user is signed up for that product, they can continue to use WHMCS as the main access portal for all their services with a "click" and it brings them to the desired location externally. I'd say there's no API information passed, just something simple to bring them to the external page. Link to comment Share on other sites More sharing options...
brian! Posted April 11, 2018 Share Posted April 11, 2018 27 minutes ago, krt463 said: Thank you again for your reply! I didn't think about the "actions menu", I would say both spots would be ideal. ok, i'm starting to picture it now... the sidebar option would require an action hook... product details page probably will, but depends where this link information is stored. 29 minutes ago, krt463 said: To me more descriptive, when the product is created.....you choose the "Custom URL Module" and from there you can enter "Text" and "External URL" as options so when a user is signed up for that product, they can continue to use WHMCS as the main access portal for all their services with a "click" and it brings them to the desired location externally. I'd say there's no API information passed, just something simple to bring them to the external page. with regards to these text and external url fields, and just to be sure i've got it right... YOU are defining those two fields and they're the same for all clients - or are the external URL's different per client ? Link to comment Share on other sites More sharing options...
krt463 Posted April 11, 2018 Author Share Posted April 11, 2018 2 minutes ago, brian! said: with regards to these text and external url fields, and just to be sure i've got it right... YOU are defining those two fields and they're the same for all clients - or are the external URL's different per client ? Yes I am defining the Text and the URL associated with the product link. The text/url link would be the SAME for each product, but could be different on different products. Product-1 would send the customer to someurl1.com and Product-2 would send the customer to someURL2.com Link to comment Share on other sites More sharing options...
brian! Posted April 11, 2018 Share Posted April 11, 2018 51 minutes ago, krt463 said: Yes I am defining the Text and the URL associated with the product link. The text/url link would be the SAME for each product, but could be different on different products. Product-1 would send the customer to someurl1.com and Product-2 would send the customer to someURL2.com as a sidebar hook, it wouldn't be a million miles away from the one I posted in the thread below... <?php # Product Details Link Sidebar # Written by brian! use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar) { $service = Menu::context('service'); $productID = $service->product->id; $validgroup1 = ['45','46','47']; $validgroup2 = ['1','2','4']; if (!in_array($productID,$validgroup1) and !in_array($productID,$validgroup2)) { return; } if (in_array($productID,$validgroup1)) { $linkurl = 'http://www.google.com'; } elseif (in_array($productID,$validgroup2)) { $linkurl = 'http://www.whmcs.com'; } if (!is_null($primarySidebar->getChild('Service Details Actions'))) { $primarySidebar->getChild('Service Details Actions') ->addChild('customlink', array( 'label' => 'Custom Link', 'uri' => $linkurl, 'order' => 999, 'attributes' => array( 'target' => '_blank' ))); } }); in the example hook, you have two arrays of product IDs (you can add more arrays if you have to)... one will add a link to Google, the other array will add a link to WHMCS - if current product ID not in either array, no link is added. the only other thing you should need to change is the value of 'label' => 'Custom Link' to whatever you want the text in the sidebar to be. Link to comment Share on other sites More sharing options...
krt463 Posted April 11, 2018 Author Share Posted April 11, 2018 Wow this looks amazing! Now for the newb..... Can you provide integration instructions? I see in my templates/mycurrenttemplate/sidebar.tpl But I'm not sure where to copy/paste etc. I have a dev setup so I'm not afraid to break stuff. Link to comment Share on other sites More sharing options...
brian! Posted April 11, 2018 Share Posted April 11, 2018 Just now, krt463 said: Can you provide integration instructions? create a new .php file in /includes/hooks, give it a relevant filename so you know what it does (e.g linksidebar.php) and paste the above code into it... save... log in as a client who has one of these valid products (after you've changed the product ID values to suit your own needs), and the custom link in the sidebar should be there on the product details page. 1 Link to comment Share on other sites More sharing options...
krt463 Posted April 11, 2018 Author Share Posted April 11, 2018 I must be missing something, I don't see any drop-down menu for any of the products. I only see options under the domains. Also, if my product ID = 20, where is that defined in the code? Link to comment Share on other sites More sharing options...
brian! Posted April 11, 2018 Share Posted April 11, 2018 5 hours ago, krt463 said: I must be missing something, I don't see any drop-down menu for any of the products. I only see options under the domains. who mentioned dropdowns? click on one of those active products, assuming it's a valid product for this hook, and on that next page (the product details page - the one in your original screenshot), there will be a sidebar (probably on the left) which will contain a custom link. 5 hours ago, krt463 said: Also, if my product ID = 20, where is that defined in the code? add 20 to one of the two arrays, and remove any numbers that aren't valid for your needs. $validgroup1 = ['45','46','47']; $validgroup2 = ['1','2','4']; Link to comment Share on other sites More sharing options...
krt463 Posted April 13, 2018 Author Share Posted April 13, 2018 Can you find where I'm going wrong here? Product ID is 20 (according to the links in the product > Links section) Screenshot of the code (only thing altered was the product 20) and the product page from the customer perspective Link to comment Share on other sites More sharing options...
brian! Posted April 13, 2018 Share Posted April 13, 2018 I don't suppose you have another hook that is removing the Service Details Action sidebar ? if not, can you try it again with a product id that does already include the sidebar. Link to comment Share on other sites More sharing options...
krt463 Posted April 16, 2018 Author Share Posted April 16, 2018 On 4/13/2018 at 11:22 AM, brian! said: I don't suppose you have another hook that is removing the Service Details Action sidebar ? if not, can you try it again with a product id that does already include the sidebar. Your script works with a product that uses the plesk module. (shows the custom link at the bottom of the actions list) The products I need a custom link for are "other products or services". Thank you again for your replies and advice. Link to comment Share on other sites More sharing options...
brian! Posted April 16, 2018 Share Posted April 16, 2018 27 minutes ago, krt463 said: Your script works with a product that uses the plesk module. which is the example you gave. 29 minutes ago, krt463 said: The products I need a custom link for are "other products or services". which may or may not have an Actions sidebar... to keep things simple, we'll just create a new sidebar and you can adapt the labels to suit your own needs... <?php # Product Details Link Sidebar # Written by brian! use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar) { $service = Menu::context('service'); $productID = $service->product->id; $validgroup1 = ['16']; $validgroup2 = ['67']; if (!in_array($productID,$validgroup1) and !in_array($productID,$validgroup2)) { return; } if (in_array($productID,$validgroup1)) { $linkurl = 'http://www.google.com'; } elseif (in_array($productID,$validgroup2)) { $linkurl = 'http://www.whmcs.com'; } $primarySidebar->addChild('Custom Actions', array( 'label' => 'Custom Actions', 'icon' => 'fa-wrench', 'order' => 30, )); $primarySidebar->getChild('Custom Actions') ->addChild('Custom Link', array( 'label' => 'Custom Link', 'uri' => $linkurl, 'attributes' => array( 'target' => '_blank' ))); }); 1 Link to comment Share on other sites More sharing options...
krt463 Posted April 16, 2018 Author Share Posted April 16, 2018 WOW AMAZING! This worked perfectly, Thank you! Link to comment Share on other sites More sharing options...
krt463 Posted April 16, 2018 Author Share Posted April 16, 2018 Is there an easy way to get multiple links if it matches one group? Ex: a product matches validgroup1, so it bringsup a list of three links on the left. If it's validgroup2, a different set/combination of links show up. Link to comment Share on other sites More sharing options...
brian! Posted April 16, 2018 Share Posted April 16, 2018 Hi Ken, 9 minutes ago, krt463 said: Is there an easy way to get multiple links if it matches one group? Ex: a product matches validgroup1, so it bringsup a list of three links on the left. If it's validgroup2, a different set/combination of links show up. I would move the sidebar creation into the if statements and do something like this... <?php # Product Details Link Sidebar # Written by brian! use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar) { $service = Menu::context('service'); $productID = $service->product->id; $validgroup1 = ['16']; $validgroup2 = ['67']; if (!in_array($productID,$validgroup1) and !in_array($productID,$validgroup2)) { return; } if (is_null($primarySidebar->getChild('Service Details Actions'))) { $primarySidebar->addChild('Service Details Actions',array( 'order' => 30, 'label' => Lang::trans('actions'), 'icon' => 'fa-wrench', )); } if (in_array($productID,$validgroup1)) { $primarySidebar->getChild('Service Details Actions') ->addChild('Custom Link1', array( 'label' => 'Custom Link1', 'uri' =>'http://www.google.com', 'attributes' => array( 'target' => '_blank' ))); $primarySidebar->getChild('Service Details Actions') ->addChild('Custom Link2', array( 'label' => 'Custom Link2', 'uri' =>'http://www.facebook.com', 'attributes' => array( 'target' => '_blank' ))); } elseif (in_array($productID,$validgroup2)) { $primarySidebar->getChild('Service Details Actions') ->addChild('Custom Link1', array( 'label' => 'Custom Link1', 'uri' =>'http://www.whmcs.com', 'attributes' => array( 'target' => '_blank' ))); $primarySidebar->getChild('Service Details Actions') ->addChild('Custom Link2', array( 'label' => 'Custom Link2', 'uri' =>'http://www.apple.com', 'attributes' => array( 'target' => '_blank' ))); } }); i've changed the hook so that is uses the Actions sidebar if it's there, and if it isn't, it creates it... that should cut down on the number of sidebars and keep it consistent for hosting and non-hosting products. there's a neater way to do it using loops, but the above should be easier for you to follow and edit. 1 Link to comment Share on other sites More sharing options...
krt463 Posted April 17, 2018 Author Share Posted April 17, 2018 Wow amazing!!!! Thank you! Link to comment Share on other sites More sharing options...
Recommended Posts