Jump to content

Adding product IP address to My Products and Services TPL


HostMyApple

Recommended Posts

Hello,

I am trying to add the IP address for a customers service in the clientareaproducts.tpl page I have added a column for IP address on this page however I am unable to determine the variable needed to get the IP address for each service to show up.

I have this working when a customer clicks into the service (clientareaproductdetails.tpl) with the variable {$dedicatedip} however that variable does not work on the clientareaproducts.tpl since that page is trying to list ever product a customer has so multiple IPs should be displaying if they have multiple services

I have tried {$service.dedicatedIp} and  {$dedicatedip} to no avail.

My trouble is when i have a customer and they go to My Products and  Services if they have many servers they might see 10+ services and not know which is which because they cant see the IP for each service. They only see the service description price, next due date and status.

Please let me know if anyone has any idea here.

Link to comment
Share on other sites

19 minutes ago, HostMyApple said:

Please let me know if anyone has any idea here.

using {$service.server.ipaddress} might be an option - but if you add {debug} to the template, you'll get a popup window of available variables... if you can find what you want in there, you're in business... if not, you'd have to modify the array with a hook.

Link to comment
Share on other sites

Hi Brian,

Thanks for the reply. I tried {$service.server.ipaddress}  and it's simply returning the IP address of my provisioning server and not the customers assigned product IP address. I checked {debug} and the only IP I see listed is still my provisioning server.

I found this post here of someone trying to do the same thing but on an invoice tpl:

https://stackoverflow.com/questions/49162313/display-dedicated-ip-into-viewinvoice-tpl-and-invoicepdf-tpl-in-whmcs?noredirect=1&lq=1

This seems to be along the lines of what you were mentioning of using a hook to pull the IP.

Also I found a previous post that you made which I also tried and didn't seem to work:

 

It seems to be having trouble with the PHP section of it because when i paste that in the template under "foreach from=$services item=service" the entire page dies and only loads white.

Any help you can offer on this would be greatly appreciated. I've attempted to tackle this for several years now and i'm just not great with PHP (pretty terrible actually).

If you have any idea's please let me know, I really do appreciate it 🙂

Thank You

 

Link to comment
Share on other sites

20 hours ago, HostMyApple said:

This seems to be along the lines of what you were mentioning of using a hook to pull the IP.

it's along the lines...

20 hours ago, HostMyApple said:

Also I found a previous post that you made which I also tried and didn't seem to work

that's the problem with quoting threads that are 4+ years old... times change and the required coding changes. 🙂

I suspect I could make that old code work if I had to, but it would have to be totally rewritten.

20 hours ago, HostMyApple said:

It seems to be having trouble with the PHP section of it because when i paste that in the template under "foreach from=$services item=service" the entire page dies and only loads white.

{php} was removed from Smarty years ago and whilst you can still use it in WHMCS (for now), doing so is frowned upon and best avoided.

20 hours ago, HostMyApple said:

Any help you can offer on this would be greatly appreciated. I've attempted to tackle this for several years now and i'm just not great with PHP (pretty terrible actually).

to do the equivalent of the above code as a hook for the Products/Services page would be...

<?php

# Add Dedicated IP To The Services Array Hook
# Written by brian! 

use Illuminate\Database\Capsule\Manager as Capsule;

function clients_services_add_dedicatedip_hook($vars) {

	$client = Menu::context('client');
	$services = $vars['services'];
	foreach($services as $key => $service) {
		$dedicatedip = Capsule::table('tblhosting')->where('userid',$client->id)->where('id',$service['id'])->value('dedicatedip');
		if ($dedicatedip) {
			$services[$key]['dedicatedip'] = $dedicatedip;
		}
	}	
	return array("services" => $services);
}
add_hook("ClientAreaPageProductsServices", 1, "clients_services_add_dedicatedip_hook");
?>

this basically takes the $services Smarty array from the Products/Services page, loops though it and checks if the current service has a dedicated IP value stored for it - if so, it adds an entry to the array, if not, it doesn't... and then returns the updated array back to the template.

what that should give you is a variable in the template that you can use anywhere inside the foreach loop - {$service.dedicatedip}...

01MnYhB.png

in the template, you could possibly use it this way...

{if $service.dedicatedip}<br />{$service.dedicatedip}{/if}

but if it exists for a service, the {$service.dedicatedip} variable will be there for you to use however/wherever you want to. thanks.png

Link to comment
Share on other sites

  • 1 year later...
19 hours ago, unknownsolo said:

This no longer works - any chance someone has an update to display dedicated IP in product list?

on which WHMCS version? I just tried in v8.0.4 and it works fine.... did you remember to add the suggested template change ??

there would be ways to do this without making the template change required, but the above hook still does what it's supposed to.

dmuxWfa.png

Link to comment
Share on other sites

Thank you for getting back to me. I am on 8.0.4 and have tested this on a fresh install with fresh six template. I created a file called show_ip.php under includes/hooks/ as follows:

image.thumb.png.41f34d74568cb6b601aa12917a0dc089.png

and edited "clientareaproducts.tpl like so:

image.thumb.png.7afa7b6531ed8b0b82d4d67d63dd8bbb.png


But I get nothing:

image.png.40c56c9a88dd007c85d11c01f144a602.png

These two test products do have IPs in the dedicated IP field. The dedicated IP also doesn't show in the {debug} page. Not sure what I am not doing correctly.

image.png.e5970d2542fcf8e50c583dfe0097aee4.png
  

Link to comment
Share on other sites

  • 3 weeks later...
On 12/12/2020 at 15:51, VNIT said:

anyone tell me how to add dedicate IP to related product in client submit ticket /

you could use a hook to append the values in the related services dropdown to include a DIP value - e.g looping through the array, and where it's a service, checking if a DIP value is available and appending the name of the related service to include it.

Link to comment
Share on other sites

  • 9 months later...
  • 2 years later...
On 17/12/2020 at 8:07 PM, brian! said:

you could use a hook to append the values in the related services dropdown to include a DIP value - e.g looping through the array, and where it's a service, checking if a DIP value is available and appending the name of the related service to include it.

This is not working for me.. I still get the "-" after domain  where as the database have DIP for the product.

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