Jump to content

Product Info on Custom Pages


BAJI26

Recommended Posts

I've done a few pages so far but I have a page with 2 groups, so I did this

->where('tblproducts.gid', '13,2')

but group 2 doesn't show!

How can I have 2 groups on 1 page?

 

 

Also how to show the domain pricing on homepage?

Edited by BAJI26
Link to comment
Share on other sites

I've done a few pages so far but I have a page with 2 groups, so I did this
->where('tblproducts.gid', '13,2')

but group 2 doesn't show!

How can I have 2 groups on 1 page?

you could try using wherein..

 

->whereIn('tblproducts.gid',[13,2])

 

Also how to show the domain pricing on homepage?

that's not easy and frankly you would be better off using a feed for that...

 

a feed I wrote to show the prices in the old v6 table (without categories) is in the thread below...

 

https://forum.whmcs.com/showthread.php?122790-After-upgrading-to-v7-domain-suggessions-have-gone&p=498618#post498618

 

and if you wanted to use a separate page and query the database...

 

https://forum.whmcs.com/showthread.php?119130-WHMCS-v7-explore-domain-TLDs

 

btw - in v7.2, the register domain page will show the pricing table... but I doubt you could use it outside of the cart.

Link to comment
Share on other sites

Question:

Is there a way to have just enter the smarty tag with the product ids.... like for product 1= {$myproduct.pid=18}, product 2= {$myproduct.pid=19}

So if I have more than one groups on the page I can just enter the PID for the product.??

Link to comment
Share on other sites

I wanna use it for my homepage where I have those 6 or so domains!

there's nothing to stop you from using a hook to get those six amounts from the database - it wouldn't be a million miles away from the hook for products, but you'd be querying the domain tables instead... I suspect it would be much faster than using a feed too.

 

I can see your page is doing 5 separate calls to the feed - if you were going to use a feed, i'd have just called it once and have it output all five prices at the same time.

 

Question:

Is there a way to have just enter the smarty tag with the product ids.... like for product 1= {$myproduct.pid=18}, product 2= {$myproduct.pid=19}

So if I have more than one groups on the page I can just enter the PID for the product.??

i'm tempted to say the short answer would be no! :)

 

the longer answer would be that you theoretically could do something similar to that (not like your code though), but it would complicate the hook coding just for the sake of simplifying the smarty...

 

in an ideal world, you should never really need to do that - you should be looping through the newly created array in the template, so referencing a variable directly in the way you describe shouldn't be necessary... the only reason I told you to reference them directly was because I could see you had already designed your layout, and it would probably have taken longer for you to try and integrate a foreach loop into it, so it was simpler to tell you how to reference the array directly.

 

going forward, you should probably bear this in mind when designing your pages - incorporate the loop into it from the start, rather than design the page and they try to fit the array into the output by accessing directly like a feed... you can do that, I just wouldn't make a habit of doing it.

Link to comment
Share on other sites

In WHMCS Admin you can put extensions on [highlight]sale[/highlight], I only want to display 6 manually chosen extensions with their prices.

Like I have on my homepage!

Edited by BAJI26
Link to comment
Share on other sites

In WHMCS Admin you can put extensions on [highlight]sale[/highlight], I only want to display 6 manually chosen extensions with their prices.

Like I have on my homepage!

... and that hook you posted was remarkably close to what it should be - i'll give you 6/10 as i'll knock 4 marks off because the table you chose is wrong (as is the join), you don't need the hidden line, nor the groupBy... and ultimately, you'll need to join a 3rd table to it too! :idea:

 

I quickly wrote the rough hook before lunch and then realised how potentially useful it is - especially for v7.2 - so i'll be working on expanding it to multiple flavours over the weekend in anticipation of the eventual v7.2 launch.

 

with regards to sale, you can either specify the TLDs individually as you have done, or just use a where to specify the sale group... though you might as well stick to using feeds for now.

Link to comment
Share on other sites

  • 2 months later...
  • 2 years later...
 
 
 
 
On 5/11/2017 at 5:03 PM, brian! said:
On 5/11/2017 at 5:03 PM, brian! said:

<?php

use Illuminate\Database\Capsule\Manager as Capsule;

function homepage_products_hook($vars) {

   $products = Capsule::table('tblproducts')
                       ->join('tblpricing', 'tblproducts.id', '=', 'tblpricing.relid')
                       ->select('tblproducts.*','tblpricing.*')
                       ->where('tblproducts.gid','x')
                       ->where('tblpricing.type', 'product')
                       ->get();

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

   return array("myproducts" => $decodedata);
}
add_hook("ClientAreaPage", 1, "homepage_products_hook");
?>  

Hey brian!,

How do I change the hook so that I could use  {$myproducts.'pid'.name} instead of {$myproducts.0.name}

Edited by cyben76
Link to comment
Share on other sites

  • 2 years later...
On 5/11/2017 at 12:23 PM, BAJI26 said:

Thanks! So I can use what you did and apply it to other pages just create another hook php file correct?

@brian!

Hi there, digging up an old post here bud. Based on the Hook below how can I get the pricing options so that when the client chooses a price option and click buy that chose get transferred to the cart!

 

						<select name="billingcycle" class="">
							<option value="monthly">1 Month - $15.99</option>
							<option value="quarterly">3 Months - $47.97</option>
							<option value="semiannually">6 Months - $95.94</option>
							<option value="annually">1 Year  - $191.88</option>
		    			</select>
<?php

use Illuminate\Database\Capsule\Manager as Capsule;

function RG_cloud_hosting_hooks($vars) {

if ($vars['templatefile'] == "cloud_hosting")
    {
    $myproducts = Capsule::table('tblproducts')
                        ->join('tblpricing', 'tblproducts.id', '=', 'tblpricing.relid')
                        ->select('tblproducts.*','tblpricing.*')
                        ->where('tblpricing.type', 'product')
                        ->where('tblproducts.hidden','0')
                        ->where('tblproducts.gid', '36') 
                        ->groupBy('tblproducts.id')
                        ->get();
                
    $encodedata = json_encode($myproducts);
    $decodedata = json_decode($encodedata, true);
    
    return array("myproducts" => $decodedata);
    }
}
add_hook("ClientAreaPage", 1, "RG_cloud_hosting_hooks");
?>

 

Link to comment
Share on other sites

  • 2 months later...
  • 1 year later...

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.

×
×
  • 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