Jump to content

Notification Bar in WHMCS


innovativeweb

Recommended Posts

On 11/12/2019 at 06:54, innovativeweb said:

that screenshot is just a ClientAreaHomepage hook...

it's just a case of working out the html to be added to the hook, e.g a bootstrap alert or other div layout, and then building any conditions on what message is shown and to whom.

Link to comment
Share on other sites

22 hours ago, innovativeweb said:

then buy the Client Notifications addon! 🙄

<?php
add_hook('ClientAreaHomepage', 1, function($vars) {
    return '<div class="alert alert-success"><div class="row"><div class="col-sm-1"><i class="fab fa-whmcs fa-3x"></i></div><div class="col-sm-11">Welcome to WHMCS!<br><small>buy the addon!</small></div></div></div>';
});

MrAOILr.png

you could always log into their demo if you want to steal their div layout code, but you'd likely have to copy and adapt their css too. headshake.gif

Link to comment
Share on other sites

  • 2 months later...
On 12/13/2019 at 10:15 PM, brian! said:

then buy the Client Notifications addon! 🙄


<?php
add_hook('ClientAreaHomepage', 1, function($vars) {
    return '<div class="alert alert-success"><div class="row"><div class="col-sm-1"><i class="fab fa-whmcs fa-3x"></i></div><div class="col-sm-11">Welcome to WHMCS!<br><small>buy the addon!</small></div></div></div>';
});

MrAOILr.png

you could always log into their demo if you want to steal their div layout code, but you'd likely have to copy and adapt their css too. headshake.gif

Hi @brian! Sorry I bump this thread.

How to be displayed on specific products? for example I want to display for certain packages used by the user and displayed on the service details page

Edited by kang28ivan
Link to comment
Share on other sites

4 hours ago, kang28ivan said:

How to be displayed on specific products? for example I want to display for certain packages used by the user and displayed on the service details page

then you wouldn't use this hook, you would instead use ClientAreaProductDetailsOutput hook and specify what output occurs with specific service(s).

<?php

add_hook('ClientAreaProductDetailsOutput', 1, function($service) {
        $serviceID = $service['service']->Id;
		if ($serviceID == '600') {
			$output .= '<div class="alert alert-success" role="alert"><div class="row"><div class="col-sm-1"><i class="fab fa-whmcs fa-3x"></i></div><div class="col-sm-11">Welcome to WHMCS!<br><small>buy the addon!</small></div></div></div>';
		}
		if ($output) {
			return $output;
		}
});

tyfwdxc.png

it's worth noting that the location of this specific hook output is determined by the Smarty template and not the hook itself - if you were displaying MarketConnect banners on that page, it would display below them.

if you have an unpaid/overdue invoice, then there is a default alert shown at the top of the page...

2cJXjTK.png

... but that output is specified in the template itself and only triggered if/when  hardcoded conditions are passed to the template.

if you wanted to output your alert elsewhere on the page, you would be looking at either editing the template to define exactly where the output should be (you could still trigger it, and specify it's content, with a hook), or using another output hook, containing JS to specify the exact location of the output (though can be difficult depending on where you want to output).

zPnibuO.png

Link to comment
Share on other sites

35 minutes ago, kang28ivan said:

For serviceID this can multiple service ID separated by commas??

two options, you could either use OR or in_array - OR is ok if you only have two values to test against, but once you get beyond two, then it's simpler to use in_array.

if (in_array($serviceID, array('573','600'))) {
Edited by brian!
Link to comment
Share on other sites

  • 2 weeks later...
On 2/17/2020 at 10:20 PM, brian! said:

two options, you could either use OR or in_array - OR is ok if you only have two values to test against, but once you get beyond two, then it's simpler to use in_array.


if (in_array($serviceID, array('573','600'))) {

Hi @brian! sorry I'm bumping this thread again.

once again I want to ask how to display notifications based on the package/product ID or group ID not service ID?

Link to comment
Share on other sites

9 minutes ago, kang28ivan said:

once again I want to ask how to display notifications based on the package/product ID or group ID not service ID?

<?php

add_hook('ClientAreaProductDetailsOutput', 1, function($service) {
	$serviceID = $service['service']->Id;
	$productID = $service['service']->packageId;
	$groupID = $service['service']->product->productGroupId;
	if (in_array($groupID, array('10','12'))) {
		$output .= '<div class="alert alert-success" role="alert"><div class="row"><div class="col-sm-1"><i class="fab fa-whmcs fa-3x"></i></div><div class="col-sm-11">Welcome to WHMCS!<br><small>buy the addon! ;-)</small></div></div></div>';
	}
	if ($output) {
		return $output;
	}
});

just change/duplicate the if statement to use the correct variable for your needs, e.g serviceID, productID, or groupID...

Link to comment
Share on other sites

  • 1 year later...
On 3/3/2020 at 9:45 AM, brian! said:

<?php

add_hook('ClientAreaProductDetailsOutput', 1, function($service) {
	$serviceID = $service['service']->Id;
	$productID = $service['service']->packageId;
	$groupID = $service['service']->product->productGroupId;
	if (in_array($groupID, array('10','12'))) {
		$output .= '<div class="alert alert-success" role="alert"><div class="row"><div class="col-sm-1"><i class="fab fa-whmcs fa-3x"></i></div><div class="col-sm-11">Welcome to WHMCS!<br><small>buy the addon! ;-)</small></div></div></div>';
	}
	if ($output) {
		return $output;
	}
});

just change/duplicate the if statement to use the correct variable for your needs, e.g serviceID, productID, or groupID...

Heyy,

Question, Cn i move this notification bar, for example above Quick shortcuts section or all the way on the top at the beginning? By default showed all the way on the bottom.

Thanks!

Link to comment
Share on other sites

  • 1 month later...
On 16/08/2021 at 17:05, Businezz said:

Question, Cn i move this notification bar, for example above Quick shortcuts section or all the way on the top at the beginning? By default showed all the way on the bottom.

technically, that location is defined in the template - so you could move its location (the hookouput foreach) by editing the template, or use a more generic output hook point and use JS to define the ideal location you want.

Link to comment
Share on other sites

2 minutes ago, brian! said:

technically, that location is defined in the template - so you could move its location (the hookouput foreach) by editing the template, or use a more generic output hook point and use JS to define the ideal location you want.

Thanks 🙂

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