tsiedsma Posted February 6, 2019 Share Posted February 6, 2019 Testing the 7.7.0 release in my dev environment and it appears that the cancellation and upgrade options are missing from the sidebar. Is anyone else able to confirm this? I'm testing using the six theme. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 6, 2019 Share Posted February 6, 2019 11 hours ago, tsiedsma said: Is anyone else able to confirm this? I'm testing using the six theme. i'm not seeing it on my v7.7 dev (clean install with duplicated database)... 0 Quote Link to comment Share on other sites More sharing options...
tsiedsma Posted February 6, 2019 Author Share Posted February 6, 2019 Thanks Brian, I was afraid of that. Time to do some digging! 0 Quote Link to comment Share on other sites More sharing options...
tsiedsma Posted February 6, 2019 Author Share Posted February 6, 2019 Found the issue, if a product is Free or one-time like a Free Trial, it doesn't show the cancellation option. As for the upgrade option missing, the specific product I was viewing had no upgrades so that makes sense 😛 This was non-existent in 7.6.2 and now exists in 7.7.0 but I do not remember reading about this change or seeing an option to disable it. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 6, 2019 Share Posted February 6, 2019 19 minutes ago, tsiedsma said: This was non-existent in 7.6.2 and now exists in 7.7.0 but I do not remember reading about this change it's listed in the v7.7 changelog... Quote CORE-12870 - Do not display cancellation option for One Time products in client area i'm assuming that it's just removing the link in the sidebar and it would theoretically still be possible to cancel a trial product if you generated the link yourself. 19 minutes ago, tsiedsma said: or seeing an option to disable it. this is v7.7... "option to disable"?... i'm not sure anyone at WHMCS Towers understands that concept! I daresay if you wanted to, you could add the cancellation link back in with a sidebar hook... e.g check if cancel link already exists, if not, optionally check that it's a trial product and add link child to sidebar... it's just a link to clientarea.php?action=cancel&id=x where x is the serviceID. 0 Quote Link to comment Share on other sites More sharing options...
tsiedsma Posted February 6, 2019 Author Share Posted February 6, 2019 3 minutes ago, brian! said: it's listed in the v7.7 changelog... i'm assuming that it's just removing the link in the sidebar and it would theoretically still be possible to cancel a trial product if you generated the link yourself. this is v7.7... "option to disable"?... i'm not sure anyone at WHMCS Towers understands that concept! I daresay if you wanted to, you could add the cancellation link back in with a sidebar hook... e.g check if cancel link already exists, if not, optionally check that it's a trial product and add link child to sidebar... it's just a link to clientarea.php?action=cancel&id=x where x is the serviceID. Yep, I totally over looked it. I hate that I have to hack in so much stuff via hooks! It gets frustrating. Disabling something without the option to turn it back on is not a feature, it’s a bug! 0 Quote Link to comment Share on other sites More sharing options...
tsiedsma Posted February 6, 2019 Author Share Posted February 6, 2019 I don’t disagree that SSL doesn’t need a cancel option, but I if someone signs up for a free trial and wants to cancel it early, now I will be getting tickets where as before I didn’t. So now this “feature” is going to create more work! 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 6, 2019 Share Posted February 6, 2019 1 hour ago, tsiedsma said: I hate that I have to hack in so much stuff via hooks! It gets frustrating. I was helping someone with a v5 installation yesterday and it's remarkable how simple it was to do some things back then. fwiw - this quick hook should add the Request Cancellation button back if it doesn't already exist for all Active products... <?php # Add Cancel Sidebar Link If Missing For Active Products Hook # Written by brian! use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar) { GLOBAL $smarty; $ServiceActions = $primarySidebar->getChild('Service Details Actions'); if (empty($ServiceActions)) { return; } if (is_null($ServiceActions->getChild('Cancel'))) { $serviceID = $smarty->getTemplateVars('id'); $servicestatus = $smarty->getTemplateVars('status'); if ($servicestatus == "Active") { $ServiceActions->addChild('Cancel')->setLabel(Lang::trans('clientareacancelrequestbutton'))->setURI('clientarea.php?action=cancel&id='.$serviceID)->setOrder(40); } } }); ... feel free to expand it to suit your needs. 0 Quote Link to comment Share on other sites More sharing options...
tsiedsma Posted February 6, 2019 Author Share Posted February 6, 2019 LOL, aren't you helpful :D Thanks, I was thinking I'd just add text that Free Trials do not require cancellation since they auto cancel at the end of the trial period but this can work too! 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 6, 2019 Share Posted February 6, 2019 it was easier to spend a couple of minutes on it now while it was still fresh in my mind rather than returning to it in a few weeks time! 🙂 0 Quote Link to comment Share on other sites More sharing options...
tsiedsma Posted February 6, 2019 Author Share Posted February 6, 2019 3 minutes ago, brian! said: it was easier to spend a couple of minutes on it now while it was still fresh in my mind rather than returning to it in a few weeks time! 🙂 FYI, getVariable('var') is deprecated, you should use getTemplateVars('var') https://www.smarty.net/docs/en/api.get.template.vars.tpl 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 6, 2019 Share Posted February 6, 2019 6 minutes ago, tsiedsma said: YI, getVariable('var') is deprecated, you should use getTemplateVars('var') updated. 0 Quote Link to comment Share on other sites More sharing options...
tsiedsma Posted February 6, 2019 Author Share Posted February 6, 2019 The hook doesn't work for me, both id and status are not in the list of smarty variables. They must get added after the hook is called! Either way, "Cancel" is not being added to the side bar, I can dump the variables in the hook so I know it's running. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 6, 2019 Share Posted February 6, 2019 14 minutes ago, tsiedsma said: The hook doesn't work for me, both id and status are not in the list of smarty variables. They must get added after the hook is called! dammit - it's failing on cPanel products (didn't have a trial cpanel product, only active ones - so didn't see this) but working on non-cpanel products... leave it with me. 0 Quote Link to comment Share on other sites More sharing options...
tsiedsma Posted February 6, 2019 Author Share Posted February 6, 2019 (edited) Got it! It doesn't show up on the "Cancellation" page but that's fine. The status variable is missing there and the serviceid is just id. This works for my purposes and doesn't require "GLOBAL", I hate using globals. add_hook('ClientAreaPageProductDetails', 1, function($vars) { $primarySidebar = Menu::primarySidebar(); $ServiceActions = $primarySidebar->getChild('Service Details Actions'); if (empty($ServiceActions)) { return; } if (is_null($ServiceActions->getChild('Cancel'))) { $serviceID = $vars['serviceid']; $servicestatus = $vars['status']; if ($servicestatus == "Active") { $ServiceActions->addChild('Cancel')->setLabel(Lang::trans('clientareacancelrequestbutton'))->setURI('clientarea.php?action=cancel&id='.$serviceID)->setOrder(40); } } }); Edited February 6, 2019 by tsiedsma 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 6, 2019 Share Posted February 6, 2019 30 minutes ago, tsiedsma said: Got it! well done... though if you have access to $vars, there's no need for $smarty... <?php # Add Cancel Sidebar Link If Missing For Active Products Hook # Written by brian! add_hook('ClientAreaPageProductDetails', 1, function($vars) { $primarySidebar = Menu::primarySidebar(); $ServiceActions = $primarySidebar->getChild('Service Details Actions'); if (empty($ServiceActions)) { return; } if (is_null($ServiceActions->getChild('Cancel'))) { if ($vars['status'] == "Active") { $ServiceActions->addChild('Cancel')->setLabel(Lang::trans('clientareacancelrequestbutton'))->setURI('clientarea.php?action=cancel&id='.$vars['id'])->setOrder(100); } } }); 0 Quote Link to comment Share on other sites More sharing options...
tsiedsma Posted February 6, 2019 Author Share Posted February 6, 2019 Ok, for anyone else looking to add back the Request Cancellation functionality, this is my final product. It works on the Service Details page, and when you click Cancel, it adds the menu item and makes it active. This just completes the look. <?php add_hook('ClientAreaPage', 1, function ($vars) { $primarySidebar = Menu::primarySidebar(); $ServiceActions = $primarySidebar->getChild('Service Details Actions'); if (empty($ServiceActions)) { return; } if (is_null($ServiceActions->getChild('Cancel'))) { if ($vars['status'] === "Active") { $ServiceActions->addChild('Cancel')->setLabel(Lang::trans('clientareacancelrequestbutton'))->setURI('clientarea.php?action=cancel&id=' . $vars['id'])->setOrder(40); } else if ($vars['clientareaaction'] === 'cancel') { $ServiceActions->addChild('Cancel')->setLabel(Lang::trans('clientareacancelrequestbutton'))->setURI('clientarea.php?action=cancel&id=' . $vars['id'])->setOrder(40)->setClass('list-group-item active'); } } }); < 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 6, 2019 Share Posted February 6, 2019 8 minutes ago, tsiedsma said: Ok, for anyone else looking to add back the Request Cancellation functionality, this is my final product. It works on the Service Details page, and when you click Cancel, it adds the menu item and makes it active. This just completes the look. for me, it's already setting the active class when clicked upon... also, you wouldn't really want to use ClientAreaPage for this as that will run on every client area page, whereas you only need this to work on the product details page. 0 Quote Link to comment Share on other sites More sharing options...
tsiedsma Posted February 6, 2019 Author Share Posted February 6, 2019 1 minute ago, brian! said: for me, it's already setting the active class when clicked upon... also, you wouldn't really want to use ClientAreaPage for this as that will run on every client area page, whereas you only need this to work on the product details page. It wasn't setting the active class on the cancel page. It has it's own page hook, so I guess if you notice a performance issue running this tiny bit of code on every page load, you could have two separate hooks for ClientAreaPageProductDetails and ClientAreaPageCancellation 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 6, 2019 Share Posted February 6, 2019 8 minutes ago, tsiedsma said: It wasn't setting the active class on the cancel page. it is for me - though i've got a dev using clean "Six" templates, and you may be using customised templates. 9 minutes ago, tsiedsma said: It has it's own page hook, so I guess if you notice a performance issue running this tiny bit of code on every page load, you could have two separate hooks for ClientAreaPageProductDetails and ClientAreaPageCancellation for a one-off hook, I wouldn't be concerned about page load... but WHMCS can require a lot of hooks, so I prefer them to only run when required. 0 Quote Link to comment Share on other sites More sharing options...
tsiedsma Posted February 6, 2019 Author Share Posted February 6, 2019 Just now, brian! said: it is for me - though i've got a dev using clean "Six" templates, and you may be using customised templates. for a one-off hook, I wouldn't be concerned about page load... but WHMCS can require a lot of hooks, so I prefer them to only run when required. Considering the Cancellation link isn't present without the hook, there is no way it will be present and active on the cancellation page without adding it which your hook does not do. WHMCS loads a ton of crap including hooks, so I am 100% in agreement that you don't want to run more than necessary. I don't see this specific one running on every client area page load causing much of a problem based on what it actually does. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 6, 2019 Share Posted February 6, 2019 <?php # Add Cancel Sidebar Link If Missing For Active Products Hook # Written by brian! add_hook('ClientAreaPage', 1, function ($vars) { $primarySidebar = Menu::primarySidebar(); $ServiceActions = $primarySidebar->getChild('Service Details Actions'); if (empty($ServiceActions)) { return; } if (is_null($ServiceActions->getChild('Cancel'))) { if ($vars['status'] === 'Active' || $vars['clientareaaction'] === 'cancel') { $ServiceActions->addChild('Cancel')->setLabel(Lang::trans('clientareacancelrequestbutton'))->setURI('clientarea.php?action=cancel&id='.$vars['id'])->setOrder(100)->setClass(( ! isset($_GET['modop']) ? 'active' : '')); } } }); 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 11, 2019 Share Posted February 11, 2019 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.