Jump to content

Remove 'Request Cancellation' button for specific products/product groups


akust0m

Recommended Posts

Hey!

I'm looking for a way via a hook to remove the 'Request Cancellation' button for specific product ID or product groups. Or, perhaps to update the link for this button for specific product ID or product groups?

image.png.b4b3f9685ddd24886499a3464d55a85e.png

Does anyone happen to have a hook snippet handy?

Thank you in advance 🙂

Edited by akust0m
Link to comment
Share on other sites

hello
I have written it now and tested it for you
this is for specific product IDs

<?php
if (!defined("WHMCS"))
    die("This file cannot be accessed directly");

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar)
{
    $pid_to_hide = array(5); // product id you want to hide cancel button for
	$service = Menu::context('service');    
	$pid = (int) $service->packageId;
  
	if (in_array($pid,$pid_to_hide))
	{
        if (!is_null($primarySidebar->getChild('Service Details Actions'))) {
            $primarySidebar->getChild('Service Details Actions')
            ->removeChild('Cancel');
        }
	}
});

 

 

Edited by AladdinJ
Link to comment
Share on other sites

and this one for Product group also if you want
 

add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar)

{
    $productGroupId_to_hide = array(2); // product groupe ids you want to hide cancel button for
	$service = Menu::context('service');    
	$product = $service->product;
    $productGroupId	= $product->productGroupId;
	if (in_array($productGroupId,$productGroupId_to_hide))
	{
        if (!is_null($primarySidebar->getChild('Service Details Actions'))) {
            $primarySidebar->getChild('Service Details Actions')
            ->removeChild('Cancel');
        }
	}
});

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated