Jump to content

Can you set the default template per Group ID?


logart

Recommended Posts

I have various types of products in my system, some of which are better off with the comparison template, and some with other types of templates.

 

I can send visitors to the correct template by adding carttpl= to the URL, but when I do that, all of the other product groups will show up with that same template if they click on other product groups.

 

Is there a way to configure product groups to default to a certain template? Or even specific products?

 

Or do I just have to deal with the customers seeing non-optimal templates for product groups?

Link to comment
Share on other sites

  • 7 months later...

We did all this with our site by creating a design/coding it and implementing whmcs and its code into it, not taking whmcs and making something around it.

 

I suggest hiring someone to make a template if you want options to change the front end of whmcs. Theres no simple solution.

Link to comment
Share on other sites

A bit of a hack, but heres some working code you can add to the top of your whmcs header.tpl file. Just need to modify the switch statement to reflect your group id's and which templates you want to load with them.

 

{if $gid}
   <script>
   {literal}
       var gid = {/literal}{$gid}{literal};

       switch (gid) {
           case 1:
               var carttpl = 'boxes';
               break;
           case 2:
               var carttpl = 'web20cart';
               break;
           default:
               var carttpl = 'modern';
               break;
       }

       var dontreload = 0;
       var cartset = 0;
       var output = [];
       var qs = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
       for (var i = 0; i < qs.length; i++) {
           var q = qs[i].split('=');
           if (q[0] == 'carttpl') {
               cartset = 1;
               output.push('carttpl='+carttpl);
               if (q[1] == carttpl) {
                   dontreload = 1;
               }
           } else {
               output.push(q[0]+'='+q[1]);
           }
       }
       if (!cartset) {
           output.push('carttpl='+carttpl);
       }
       var url = window.location.href.substr(0, window.location.href.indexOf('?'))+'?'+output.join('&');
       if (!dontreload) {
           location.href = url;
       }
   {/literal}
   </script>
{/if}

 

 

EDIT: This has not been fully tested and probably has at least a bug or two. use at your own risk.

Edited by laszlof
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