Jump to content

separate Page for Product Categories


Sybille

Recommended Posts

Hi,

 

When you go to the shop, WHMCS shows automatically the products of the first category referred to the order in the WHMCS Admin backend.

 

I would prefer to show a separate page with just the categories, whit an appealing layout, where I show a description to each categories as well.

 

Not till then the user get forwarded to the relevant products.

 

Thanks in advanced for your support.

Sybille

Link to comment
Share on other sites

Sybille,

 

before the release of v6.2 last year, one possible answer would have been to use the "Slider" orderform template on the first product group - because it would show all product groups as boxes and then you could select the product group you were interested in.

 

i'm assuming that you've only started using WHMCS after this date and don't have access to the "Slider" template, but the way it worked was by adding some code to the beginning of products.tpl to check if a groupID or productID was being called and if not, to show the product groups... though the layout was probably not exciting as you would want! :)

 

0lRc5iS.png

 

the code used was...

 

<div id="order-slider">

{if !$smarty.get.gid && !$smarty.post.pid && !$smarty.get.pid && !$smarty.post.pid}

<h1>{$LANG.cartproductselection}</h1>

<br /><br />

{foreach key=num item=productgroup from=$productgroups}
<div class="prodcats"><div><a href="cart.php?gid={$productgroup.gid}">{$productgroup.name}</a></div></div>
{/foreach}
{if $loggedin}
{if $gid neq "addons"}<div class="prodcats"><div><a href="cart.php?gid=addons">{$LANG.cartproductaddons}</a></div></div>{/if}
{if $renewalsenabled && $gid neq "renewals"}<div class="prodcats"><div><a href="cart.php?gid=renewals">{$LANG.domainrenewals}</a></div></div>{/if}
{/if}
{if $registerdomainenabled && $domain neq "register"}<div class="prodcats"><div><a href="cart.php?a=add&domain=register">{$LANG.registerdomain}</a></div></div>{/if}
{if $transferdomainenabled && $domain neq "transfer"}<div class="prodcats"><div><a href="cart.php?a=add&domain=transfer">{$LANG.transferdomain}</a></div></div>{/if}

<div class="clear"></div>

<br />

{else}
blah blah
{/if}

fundamentally, that would still work in modern or standard_cart - though obviously all the div classes will be different and you'll have to restyle the output based on your template... until then, you'll just get a list of groups.

 

descriptions would be another issue because they're not passed in Smarty for all product groups - only for the selected group... if you wanted to add descriptions, that might require a hook to pull the values from the database (if you intend to use the group headline/tagline values) or maybe language overrides (if the description needed to be multilingual and you wanted to avoid using a hook).

Link to comment
Share on other sites

Hi brian!

 

Many thanks. The code was very useful. After I redesigned the layout a little it looks quite good.

 

In the admin tool I made different categories and related my products to.

Eg. Network which includes WLAN and LAN

I generated also a category “Bundles” where I relate all mi bundles / packages to.

 

In the user shop I made a headline and displayed all categories I offer. But I excluded the category bundles.

 

For the bundles I made a separate headline and now I like to list the name of each bundle.

With my script it only works when the category “bundle” is the first one listed in the admin tool. But I would prefer, that it would also work independent form the order in de admin tool.

 

I could explain well enough what the issue is.

 

 

<div id="order-standard_cart">
	<div class="row">
		<div class="col-md-12">
			<div class="header-lined">
				<h1>{$LANG.singleproduct}</h1>
			</div>
		</div>
	</div>
	<div class="row">
		{foreach key=num item=productgroup from=$productgroups}
			{if $productgroup.name !== 'Bundles'}
				<div class="col-md-3">
					<div class="category">
						<a href="cart.php?gid={$productgroup.gid}">{$productgroup.name}</a>
					</div>
				</div>
			{/if}
		{/foreach}
	</div>
</div>
<div id="order-standard_cart">
	<div class="row">
		{if $productgroup.name = 'Bundles'}
			<div class="col-md-12">
				<div class="header-lined">
					<h1>{$LANG.bundledeal}</h1>
				</div>
			</div>
			{foreach $products as $product}
				<div class="col-md-3">
					<div class="bundles">
						<a href="cart.php?gid={$productgroup.gid}">{$product.name}</a>
					</div>
				</div>
			{/foreach}
		{/if}
	</div>
</div>

 

Kategorien.png

Link to comment
Share on other sites

Hi Sybille,

 

For the bundles I made a separate headline and now I like to list the name of each bundle.

With my script it only works when the category “bundle” is the first one listed in the admin tool. But I would prefer, that it would also work independent form the order in de admin tool.

that will be because the cart variables only contain information about the current product group, not products from other groups.

you would have to query the database to get the names of your product bundles - the easiest method being an action hook...

 

<?php

use Illuminate\Database\Capsule\Manager as Capsule;

function bundle_product_names_hook($vars) {

   $bundles = Capsule::table('tblbundles')
               ->select('id','name')
               ->where('showgroup','1')
               ->get();

   $encodedata = json_encode($bundles);
   $decodedata = json_decode($encodedata, true);

   return array("bundlenames" => $decodedata);
}
add_hook("ClientAreaPageCart", 1, "bundle_product_names_hook");
?>

that will create a $bundlenames array (containing product names and bundle id) and pass it to the Cart...

 

in your code, where you previously had...

 

    <div id="order-standard_cart">
       <div class="row">
           {if $productgroup.name = 'Bundles'}
               <div class="col-md-12">
                   <div class="header-lined">
                       <h1>{$LANG.bundledeal}</h1>
                   </div>
               </div>
               {foreach $products as $product}
                   <div class="col-md-3">
                       <div class="bundles">
                           <a href="cart.php?gid={$productgroup.gid}">{$product.name}</a>
                       </div>
                   </div>
               {/foreach}
           {/if}
       </div>
   </div>

you should now be able to use...

 

    <div id="order-standard_cart">
       <div class="row">
           {if $productgroup.name = 'Bundles'}
               <div class="col-md-12">
                   <div class="header-lined">
                       <h1>{$LANG.bundledeal}</h1>
                   </div>
               </div>
               {foreach $bundlenames as $bundle}
                   <div class="col-md-3">
                       <div class="bundles">
                           <a href="cart.php?a=add&bid={$bundle.id}">{$bundle.name}</a>
                       </div>
                   </div>
               {/foreach}
           {/if}
       </div>
   </div>

currently, the hook will create an array of bundles that are assigned to be shown in any product group (not just one called "Bundles") and might potentially include expired bundles - if/when you want to change this, you can specify which group or hide expired bundles by tweaking the action hook (using 'where') - but for now, it should be enough to get you started with this... :idea:

Link to comment
Share on other sites

  • 2 months later...
Sybille,

 

before the release of v6.2 last year, one possible answer would have been to use the "Slider" orderform template on the first product group - because it would show all product groups as boxes and then you could select the product group you were interested in.

 

i'm assuming that you've only started using WHMCS after this date and don't have access to the "Slider" template, but the way it worked was by adding some code to the beginning of products.tpl to check if a groupID or productID was being called and if not, to show the product groups... though the layout was probably not exciting as you would want! :)

 

0lRc5iS.png

 

the code used was...

 

<div id="order-slider">

{if !$smarty.get.gid && !$smarty.post.pid && !$smarty.get.pid && !$smarty.post.pid}

<h1>{$LANG.cartproductselection}</h1>

<br /><br />

{foreach key=num item=productgroup from=$productgroups}
<div class="prodcats"><div><a href="cart.php?gid={$productgroup.gid}">{$productgroup.name}</a></div></div>
{/foreach}
{if $loggedin}
{if $gid neq "addons"}<div class="prodcats"><div><a href="cart.php?gid=addons">{$LANG.cartproductaddons}</a></div></div>{/if}
{if $renewalsenabled && $gid neq "renewals"}<div class="prodcats"><div><a href="cart.php?gid=renewals">{$LANG.domainrenewals}</a></div></div>{/if}
{/if}
{if $registerdomainenabled && $domain neq "register"}<div class="prodcats"><div><a href="cart.php?a=add&domain=register">{$LANG.registerdomain}</a></div></div>{/if}
{if $transferdomainenabled && $domain neq "transfer"}<div class="prodcats"><div><a href="cart.php?a=add&domain=transfer">{$LANG.transferdomain}</a></div></div>{/if}

<div class="clear"></div>

<br />

{else}
blah blah
{/if}

fundamentally, that would still work in modern or standard_cart - though obviously all the div classes will be different and you'll have to restyle the output based on your template... until then, you'll just get a list of groups.

 

descriptions would be another issue because they're not passed in Smarty for all product groups - only for the selected group... if you wanted to add descriptions, that might require a hook to pull the values from the database (if you intend to use the group headline/tagline values) or maybe language overrides (if the description needed to be multilingual and you wanted to avoid using a hook).

 

Sorry fr being a dunce but on what template does this code go?

Link to comment
Share on other sites

Cheers. I can get the Product Groups to display but the gid=1 group is still below. Any attempt to remove code seems to remove products from each group page. Any pointers?

you've probably come unstuck with the "Blah blah" bit of the code... I was taking a shortcut as we're not really supposed to post whole templates in the forum...

 

but let's say you were doing this for standard cart... products.tpl currently starts with...

 

{include file="orderforms/standard_cart/common.tpl"}

after that, you would add the code to show the product groups if no specific group is chosen... which i've quickly rewritten for stanrd_cart (rather than use the old slider code)...

 

{include file="orderforms/standard_cart/common.tpl"}

<div id="order-standard_cart">

{if !$smarty.get.gid && !$smarty.post.pid && !$smarty.get.pid && !$smarty.post.pid}

           <div class="products" id="products">
               <div class="row row-eq-height">
                   {foreach $productgroups as $productgroup}
                       <div class="col-md-4">
                           <div class="product clearfix" id="productgroup{$productgroup@iteration}">
                               <header>
                                   <span id="productgroup{$productgroup@iteration}-name"><a href="cart.php?gid={$productgroup.gid}">{$productgroup.name}</a></span>
                               </header>
                           </div>
                       </div>
                       {if $productgroup@iteration % 3 == 0}
                           </div>
                           <div class="row row-eq-height">
                       {/if}
                   {/foreach}
               </div>
           </div>
{else}

below this would be the rest of the existing products.tpl template starting with...

 

    <div class="row">

       <div class="pull-md-right col-md-9">

that's the blah blah bit... and then right at the end of the template, you add a closing {/if}

 

if you do that, you should get your product groups in boxes (3 per row), with each linked to the specific product group.

Link to comment
Share on other sites

  • 1 year later...
Guest
This topic is now closed to further replies.
  • 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