Jump to content

Cart view to page


Tom Wilson

Recommended Posts

21 hours ago, Tom Wilson said:

I've created a custom page for web hosting , however, when you go to Store and then Web Hosting, it goes to the cart grid view.

that implies that you've got a product group called "Web Hosting" because that Store dropdown menu is effectively just a foreach loop through the product groupnames... with MC Products Groups, domain reg/trans etc added to the end.

21 hours ago, Tom Wilson said:

How do I make it go to the page?

if the above is true, then you'd need to use a hook to change the link...

there's a much quicker way to do it than the hook below, but i'm covering you needing to change multiple links to this array and reducing the chances of errors...

<?php

# Change Store Navbar Links Hook
# Written by brian!

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function(MenuItem $primaryNavbar)
{
	$Store = $primaryNavbar->getChild("Store");
	if (empty($Store)) {
		return;
	}
	$StoreChildren = $Store->getChildren();
	$kidslinks = array("Web Hosting", "VPS Servers");
	foreach($StoreChildren as $key => $Store_details_child) {
		if (in_array($key, $kidslinks)) {
			if ($key === "Web Hosting"){$newlink = "webhosting.php";}
			elseif ($key === "VPS Servers"){$newlink = "vps.php";}
			$Store->getChild($key)->setUri($newlink);
		}
	}
});

you can remove the VPS stuff - that's only there to show you how to add more than just Web Hosting to your changed links... change the values of $newlink to the appropriate filenames or URLs.

Link to comment
Share on other sites

2 hours ago, brian! said:

that implies that you've got a product group called "Web Hosting" because that Store dropdown menu is effectively just a foreach loop through the product groupnames... with MC Products Groups, domain reg/trans etc added to the end.

if the above is true, then you'd need to use a hook to change the link...

there's a much quicker way to do it than the hook below, but i'm covering you needing to change multiple links to this array and reducing the chances of errors...


<?php

# Change Store Navbar Links Hook
# Written by brian!

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function(MenuItem $primaryNavbar)
{
	$Store = $primaryNavbar->getChild("Store");
	if (empty($Store)) {
		return;
	}
	$StoreChildren = $Store->getChildren();
	$kidslinks = array("Web Hosting", "VPS Servers");
	foreach($StoreChildren as $key => $Store_details_child) {
		if (in_array($key, $kidslinks)) {
			if ($key === "Web Hosting"){$newlink = "webhosting.php";}
			elseif ($key === "VPS Servers"){$newlink = "vps.php";}
			$Store->getChild($key)->setUri($newlink);
		}
	}
});

you can remove the VPS stuff - that's only there to show you how to add more than just Web Hosting to your changed links... change the values of $newlink to the appropriate filenames or URLs.

Thank you!

Now I wan to add Web Hosting back to the Store drop, how do I do this?

Link to comment
Share on other sites

19 hours ago, Tom Wilson said:

Now I want to add Web Hosting back to the Store drop, how do I do this?

why? fou4.gif

if you wanted both a link to your web hosting page AND a link to those web hosting products in the cart, then the above hook is redundant - there's no point in changing an existing link, they have to recreate it again using the original URL... that would be insane.

you could leave the cart link as is, and just add a new link to the Store dropdown as shown in the thread below...

https://docs.whmcs.com/Client_Area_Navigation_Menus_Cheatsheet#Adding_a_Menu_Item

... but where that hook uses 'Support', change that to 'Store' and then adjust the other parts to suit your need... you can't have two children with the same name, so where it says... ->addChild('Emergency Contacts', - you can't use "Web Hosting" in there if your product group is called "Web Hosting" - call it something different and then you can set it's label to be "Web Hosting" or whatever.

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