Jump to content
New posts are now disabled in this board - V7.7 Release Board Read more... ×
tsiedsma

Client Area Product Details missing sidebar links?

Recommended Posts

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.

lh-iWcJV.png

Share this post


Link to post
Share on other sites
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)...

gUMWLkK.png

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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! celestial5.gif

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.

Share this post


Link to post
Share on other sites
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! celestial5.gif

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!

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

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! 🙂

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
6 minutes ago, tsiedsma said:

YI, getVariable('var') is deprecated, you should use getTemplateVars('var')

updated. thanks.png

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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 by tsiedsma

Share this post


Link to post
Share on other sites
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);
        }
    }
});

Share this post


Link to post
Share on other sites

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');
        }
    }
});

<

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
<?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' : ''));
        }
    }
});

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

By using this site, you agree to our Terms of Use & Guidelines