Jump to content

Display Hosting Packages on homepage


Innovere UK

Recommended Posts

Hi everyone,

I need little help from the community get my site going.  I have three web hosting packages configured on my WHMCS and I would like to display them on the home page.

Now looking at the possible ways, I can use product data feed, but it passed as JavaScript, which absolutely no no for me.  Other option is using hook but there is not enough official documentation out there.  I notice, WHMCS official documentation, they have examples on pretty much everything except displaying products data elsewhere (exception in client area when user logged in).

 

i hope some can write simple guide using example.com as my site from connecting to db to writing sql to get my he data out of the db and display it on the homepage.tpl using hook or directly on the page.

thank you in advance for help.

Link to comment
Share on other sites

On 17/01/2019 at 08:09, Innovere UK said:

Now looking at the possible ways, I can use product data feed, but it passed as JavaScript, which absolutely no no for me.

that's a shame because that would by far be the simplest way to do it.

On 17/01/2019 at 08:09, Innovere UK said:

Other option is using hook but there is not enough official documentation out there.  I notice, WHMCS official documentation, they have examples on pretty much everything except displaying products data elsewhere (exception in client area when user logged in).

you could use the hook I posted in the thread below as a starting point....

<?php

use Illuminate\Database\Capsule\Manager as Capsule;

function homepage_products_hook($vars)
{
	$products = Capsule::table('tblproducts')
		->join('tblpricing', 'tblproducts.id', '=', 'tblpricing.relid')
		->where('tblpricing.type', 'product')
		->where('tblproducts.hidden','0')
		->where('tblproducts.gid','3')	
		->select('tblproducts.id','tblproducts.name','tblproducts.description','tblpricing.monthly')
		->orderBy('tblproducts.order')						
		->groupBy('tblproducts.id')
		->get();
	$results = json_decode(json_encode($products), true);
	return array("myproducts" => $results);
}
add_hook("ClientAreaPageHome", 1, "homepage_products_hook");
?>

the above should create a Smarty array {$myproducts} which contains the id,name,description and monthly price (no currency prefix/suffix*) of the three products in your "Unlimited Hosting" product group.

* you could pass a currency in the query and then either tweak the hook to format the output to include currency prefix/suffix, or add them manually in the output.

the output is the tricky part because i've got no idea how you want to output them - but you're either going to do it in a foreach loop, or hard code the output and use specific variables (name, price etc) in specific parts of the output - I think I outlined both ways in the above thread.

 

 

 

Link to comment
Share on other sites

Thank you Brian.  Using JS is fine with me but, JS is always disliked by Apple and beside that there is always million dollar question “what if the JS is turned off by user”?

Anyhow, I have decided to HTML code the product in to the homepage.tpl, not greatest thing to do but for time being it’ll do the job while I experiment with your hook solution.

While on that subject, how can manipulate the primary nav items.  I looked at document on Whmcs 

https://docs.whmcs.com/Editing_Client_Area_Menus

again it has lot of things but misses the existing problems, like how can I move existing items from parent level to a child level?  For example, let’s say you “Announcements” on the parent level, but I want to move that to child level under Newly created parent “Support”.  I have Magee to do it using method described in the cheat sheet documentation but it requires you to set URI of each link and that poses problem of its own, meaning you have to think of URL rewriting rules etc...

is there any other ways....?

Link to comment
Share on other sites

17 hours ago, Innovere UK said:

Thank you Brian.  Using JS is fine with me but, JS is always disliked by Apple and beside that there is always million dollar question “what if the JS is turned off by user”?

simple - they wouldn't be able to use your site as WHMCS requires JS to be enabled in order for it to work successfully - certainly for most of the available themes and cart templates! headshake.gif

17 hours ago, Innovere UK said:

Anyhow, I have decided to HTML code the product in to the homepage.tpl, not greatest thing to do but for time being it’ll do the job while I experiment with your hook solution.

it's the simplest solution and will get the job done for now. 🙂

17 hours ago, Innovere UK said:

is there any other ways....?

short answer is that you don't "move" them - basically, what you do is remove them from where they are, and recreate them where you want them... so you don't "move" Announcements to a child menu, you have to copy it's values across (recreate) and delete the original link in the parent.

for most links that is straightforward, but there are some links that are conditional... "Affiliates" being the obvious one, "Domain Reg/Tran" in Store being another... and so if you wanted to "move" one of these, then you'd ideally need to recreate the conditional statements that show them... but they are not listed anywhere, so you need to figure them out for yourself.... be grateful that you weren't here 3 years ago when all this 'using hooks to change menus' nonsense was introduced! 🙄

if you don't want to mess around with hooks, and want to buy an addon to manage the navbar menus, then the best that i've used is Advanced Menu Manager - basically, it recreates the existing navbar as a JavaScript menu (looks exactly the same), which then gives you the option of created nested multilevel submenus (which you cannot do with hooks)... also, you can drag&drop the items, so you literally can move them with this. 🙂

mKwUwuC.png

personally, I still tend to do everything in hooks and probably more advanced situations would have to use hooks, but if you don't want the hassle of using them, then using the above addon might be an option...btw - it works in v7.6.1, but I haven't tried it in the v7.7 dev, though it will likely work as I don't think anything has changed with regards to the menus (but check first before buying if you are unsure).

Link to comment
Share on other sites

Thank you again for quick response.  I think I’ll experiment with hook even though it will be pain in neck, for two reasons:

1. It will generate proper HTML output, good for SEO..

2. I get to sharpen up my PHP coding skills, I haven’t used PHP for ages, at least this will be my motivation.

Thank you...

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