Jump to content

Order Summary in non cart pages


Recommended Posts

Hi Chris,

 

Is there any way to display "Order Summary" block (or any other mini cart block) in other WHMCS pages but not in sidebar as I don't use sidebar in my page?

outside of the cart? I suppose if you could access the session variables, you'd have a fighting chance...

 

but if all you wanted to do was show the number of items in the cart and/or cart value, then you could use Data Feeds.

 

ideally, what are you trying to do ?

Link to comment
Share on other sites

....what are you trying to do ?

 

That's a very good question Brian :) ...... Well in fact I'm trying to add some stuff in my eShop. Keeping the engine I'm redesigning the Shop section by adding dedicated page for each product with a lot of needing (for Coders/Designer) details. If you see the screenshots at: https://forum.whmcs.com/showthread.php?128935-e-Shop&p=515618 you'll get my meaning.

Link to comment
Share on other sites

That's a very good question Brian :) ...... Well in fact I'm trying to add some stuff in my eShop. Keeping the engine I'm redesigning the Shop section by adding dedicated page for each product with a lot of needing (for Coders/Designer) details. If you see the screenshots at: https://forum.whmcs.com/showthread.php?128935-e-Shop&p=515618 you'll get my meaning.

i'm struggling to see the link between the addon and the details within ordersummary. :?:

 

I suspect ordersummary requires cart.php to function properly (e.g provide the variables/arrays), so outside of cart you would effectively have to reproduce the arrays for it (or something similar to work), and as the cart is session based, you'd need to access that too.

 

perhaps it will make more sense to me when you post images from the client side of the addon.

Link to comment
Share on other sites

i'm struggling to see the link between the addon and the details within ordersummary. :?:.

 

Not everything can be perfect. This is the dark point but comparing with the benefits of having a dedicated and full of details page, it seems to be uninmportant.

I'll manually modify 1 or 2 templates. Actually is the categories block which I think that I can replace with my own with a hook, and that "Order Summary" which has a link to "Continue Shopping". Just keep in mind that clicking "Buy Now" will redirects to normal cart page. I'm not replacing the functionality. When I released my old mod it had double (maybe more) sales than the forum module.

Link to comment
Share on other sites

oh ok, you've updated the order now button link to go to the cart (it wasn't before)... now it makes some sense!

 

Yes, I activated the link. From that point everything will follows normal WHMCS procedure. The only that I'll change are the categories block links to point at shop.php instead of cart.php so if someone wants to browse categories to go to my pages. The second change is to find and change any "Continue Shopping" links to point to my pages. That's all.

 

But as you maybe seen the advantages are much more than disadvantages.

 

PS: I mean advantages for those who want to show product details. eg Hosting providers don't need them.

Link to comment
Share on other sites

Hi Chris,

 

three thoughts/suggestions on this if I may...

 

1. the currency format of the e-shop pricing is different from the cart pricing format...

 

jzJcgme.png

 

I don't mean the actual pricing, e.g €25 in one, €35 in the other - I specifically mean that the e-shop would show it as €35.00 but the cart would show it as €35,00 - though going from the admin screenshots, that might just be a typo on your part... :?:

 

also, can e-shop handle products being priced in multiple currencies ??

 

2. the order summary issue... looking at the design, I suppose you could put the order summary into a panel... I still suspect you'd need to query the session and then run those values into a db search if you wanted to get product names etc, but i'm sure it could be done (if you had to!).

 

3. from the client side, is there any reason why the output has to be a separate page and outside of the cart ?? I get what you say about if you're selling hosting, you can use the cart, and if selling software etc, use e-shop... but there might be those who want to do both and to have two separate systems might be a little confusing to end-users...

 

i'm wondering if it would be simpler to create a custom orderform template - all you would likely need is a custom products.tpl template (using your current output) and then for other pages it falls back to standard_cart - though if there are no domains/product configurations, then they'll only see products.tpl, viewcart and checkout... the advantage to that is that you're in the cart so will have easier access to cart variables rather than having to try to recreate them from outside... and for the end-user, they can easily switch from ordering hosting products/domains/software all in the same cart...

 

if it were a separate orderform template, then you could assign specific templates to the appropriate product groups.. e.g domains use standard_cart, VPS hosting uses one of the ugly comparison templates and software uses the e-shop template...

 

though I assume your addon isn't adding products to the standard db tables as such but to a custom table... perhaps if it could add the basic information to the default tblproducts table and then pull additional information from the custom table, that might be a way to make them work together.

 

anyway, as you say, there are pros & cons to your method, and there are also pros & cons too to having it as an orderform template... but I think it's worth at least giving some thought to it.

Link to comment
Share on other sites

Hi Chris,

 

three thoughts/suggestions on this if I may...

 

Thank you for your time to post these suggestions.

 

 

1. the currency format of the e-shop pricing is different from the cart pricing format...

 

jzJcgme.png

 

I don't mean the actual pricing, e.g €25 in one, €35 in the other - I specifically mean that the e-shop would show it as €35.00 but the cart would show it as €35,00 - though going from the admin screenshots, that might just be a typo on your part... :?:

 

Price is a free text input. eg in this example I've used:

€35<sup>.00</sup>

 

As I said these pages, at least for now, are just for product presentation and nothing more.

 

also, can e-shop handle products being priced in multiple currencies ??

On the way that the system works now, no is not possible, unless if you manually enter all the prices in the price field. Not so professional.

 

2. the order summary issue... looking at the design, I suppose you could put the order summary into a panel... I still suspect you'd need to query the session and then run those values into a db search if you wanted to get product names etc, but i'm sure it could be done (if you had to!).

I left it as last task todo. First I need to finish all other elements in the page.

 

3. from the client side, is there any reason why the output has to be a separate page and outside of the cart ?? I get what you say about if you're selling hosting, you can use the cart, and if selling software etc, use e-shop... but there might be those who want to do both and to have two separate systems might be a little confusing to end-users...

Everybody can use it. It's just my opinion that maybe those who're selling hosting packages don't need it. ef what to add as Photo Gallery etc?

 

i'm wondering if it would be simpler to create a custom orderform template - all you would likely need is a custom products.tpl template (using your current output) and then for other pages it falls back to standard_cart - though if there are no domains/product configurations, then they'll only see products.tpl, viewcart and checkout... the advantage to that is that you're in the cart so will have easier access to cart variables rather than having to try to recreate them from outside... and for the end-user, they can easily switch from ordering hosting products/domains/software all in the same cart...

 

if it were a separate orderform template, then you could assign specific templates to the appropriate product groups.. e.g domains use standard_cart, VPS hosting uses one of the ugly comparison templates and software uses the e-shop template...

I've added a few only fields in tblproducts table. But I can add all there and in this case I can use the default templates. But what about php queries? Not sure but I think that in my previous version I was using PHP in templates. New Smarty version has by default PHP disabled. I seen that there is an option to activate it but don't know how many webmasters will be happy to do it.

 

So if I can't use PHP in templates means that I must run some queries by hooks. I'm not familiar with hooks and don't know if this can be done easy or not (if it can be done at all).

 

though I assume your addon isn't adding products to the standard db tables as such but to a custom table... perhaps if it could add the basic information to the default tblproducts table and then pull additional information from the custom table, that might be a way to make them work together.

Correct. I tried to use the minimum additions. Most data are storing in separate tables.

 

Thank you for your time

Chris

 

- - - Updated - - -

 

........addition...........

 

In my previous version I was getting almost all pricing with queris. eg to get addons list I was using:

// AddOns
$browse_addons = array();
$sql_addons = mysql_query("SELECT * FROM tbladdons");
while($addon = mysql_fetch_array($sql_addons)) {
            $split = explode(",", $addon["packages"]);
            if(in_array($productid, $split))
            {
               $activeaddonid = $addon["id"];
               $sql_addon_price = mysql_query("SELECT * FROM tblpricing WHERE type='addon' AND relid=$activeaddonid LIMIT 1");
               $rlt_addon_price = mysql_fetch_assoc($sql_addon_price);
               $addon["setup"] = getFormatPrice($rlt_addon_price["msetupfee"]);
               $addon["amount"] = getFormatPrice($rlt_addon_price["monthly"]);
               array_push($browse_addons, $addon);
            }
}

but almost all clients asked me to let pricing in manual enter mode.

Link to comment
Share on other sites

I've added a few only fields in tblproducts table. But I can add all there and in this case I can use the default templates. But what about php queries? Not sure but I think that in my previous version I was using PHP in templates. New Smarty version has by default PHP disabled. I seen that there is an option to activate it but don't know how many webmasters will be happy to do it.

no you don't want to be asking users to enable that option. :)

 

So if I can't use PHP in templates means that I must run some queries by hooks. I'm not familiar with hooks and don't know if this can be done easy or not (if it can be done at all).

well I would imagine you know enough about the two core features of hooks that you'll need - namely using PHP and querying the database... the only things you'll need to figure out is the v7 way to query the db and then returning the results back to the template. :idea:

 

as a very rough demo, imagine you want to access the addons table in the template, e.g querying tbladdons..

 

<?php

use Illuminate\Database\Capsule\Manager as Capsule;

function demo_addons_hook($vars) {

   $productid = '2';
   $sql_addons = Capsule::table('tbladdons')
               ->join('tblpricing', 'tbladdons.id', '=', 'tblpricing.relid')
               ->where('tbladdons.packages',$productid)
               ->where('tblpricing.type','addon')
               ->groupBy('tbladdons.id')
               ->get();

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

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

that will create a Smarty array of addons ($myaddons) for a given product, along with it's pricing etc... and you can either output that array in the template, access specific values... or even modify it in the hook further (using PHP) before you pass the array(s) back to the template.

Link to comment
Share on other sites

Brrrr.... json :) .... Ok, I got it. Meanwhile I gave a look at order templates. My God, seems that they're more than all clientarea templates. Do I need to modify all of them? Needs years :P

What templates used on these pages (I think that I need only these 2 pages);

https://www.teriakis.com/cart.php

https://www.teriakis.com/cart.php?a=confproduct&i=0

 

In the 2nd page, which is the most important if I need to add product details there, I must:

1.- Remove sidebar

2.- Add Breadcrumb so user can move back

3.- Place configure (main section) on the right, over Order Summary. This way I'll have space to show product details.

Link to comment
Share on other sites

Brrrr.... json :) .... Ok, I got it. Meanwhile I gave a look at order templates. My God, seems that they're more than all clientarea templates. Do I need to modify all of them? Needs years :P

What templates used on these pages (I think that I need only these 2 pages);

https://www.teriakis.com/cart.php

https://www.teriakis.com/cart.php?a=confproduct&i=0

front page of the cart is products.tpl, second link will be configureproduct.tpl

 

In the 2nd page, which is the most important if I need to add product details there, I must:

1.- Remove sidebar

2.- Add Breadcrumb so user can move back

3.- Place configure (main section) on the right, over Order Summary. This way I'll have space to show product details.

sidebar could effectively be removed by removing the includes to the sidebar templates (if you want it gone completely).

Link to comment
Share on other sites

front page of the cart is products.tpl,

 

Seems that is not so easy job even for simple things. eg when I seen in the template {$product.name} I thought that all tblproducts data are available so by using for example {$product.mod_eshop_logo} I'll have the product's logo.

Unfortunatelly seems that in the cart.php there "JOIN TABLES" and in the array $products there are only few values avaiable. I add in the {$product|@print_r} template to see the array's values and what I got is:

Array (     [pid] => 2     [bid] => 0     [type] => other     [name] => Social Blog     [description] => This is the description     [features] => Array         (         )      [featuresdesc] => This is the description
    [paytype] => recurring     [pricing] => Array         (             [type] => recurring             [semiannually] => €15,00EUR Semi-Annually + €20,00EUR Setup Fee             [hasconfigoptions] =>              [cycles] => Array                 (                     [semiannually] => €15,00EUR Semi-Annually + €20,00EUR Setup Fee                 )              [rawpricing] => Array                 (                     [msetupfee] => 0.00                     [qsetupfee] => 0.00                     [ssetupfee] => 20.00                     [asetupfee] => 0.00                     [bsetupfee] => 0.00                     [tsetupfee] => 0.00                     [monthly] => -1.00                     [quarterly] => -1.00                     [semiannually] => 15.00                     [annually] => -1.00                     [biennially] => -1.00                     [triennially] => -1.00                 )              [minprice] => Array                 (                     [price] => WHMCS\View\Formatter\Price Object                         (                             [price:protected] => 15                             [currency:protected] => Array                                 (                                     [id] => 1                                     [code] => EUR                                     [prefix] => €                                     [suffix] => EUR                                     [format] => 3                                     [rate] => 1.00000                                 )                              [defaultFormat:protected] => {PREFIX}{PRICE}{SUFFIX}                             [defaultCurrencyDescriptor:protected] => Array                                 (                                     [format] => 1                                     [prefix] =>                                      [suffix] =>                                  )                          )                      [setupFee] => WHMCS\View\Formatter\Price Object                         (                             [price:protected] => 20                             [currency:protected] => Array                                 (                                     [id] => 1                                     [code] => EUR                                     [prefix] => €                                     [suffix] => EUR                                     [format] => 3                                     [rate] => 1.00000                                 )                              [defaultFormat:protected] => {PREFIX}{PRICE}{SUFFIX}                             [defaultCurrencyDescriptor:protected] => Array                                 (                                     [format] => 1                                     [prefix] =>                                      [suffix] =>                                  )                          )                      [cycle] => semiannually                     [simple] => €15,00                     [cycleText] => €15,00/6 mo                     [cycleTextWithCurrency] => €15,00EUR/6 mo                 )          )      [freedomain] =>      [freedomainpaymentterms] => Array         (         )      [qty] =>      [isFeatured] =>  ) 1

 

I tried some other combinations eg {$product.products.mod_eshop_logo} but didn't worked eighter. As cart.php is encoded I can't see what variable names are used there and I can't say that I'm Mantis to find them.

 

This means that even for the simpliest tasks I need to add queries with hooks.

Link to comment
Share on other sites

$products is a complicated array that pulls content from a number of different tables (plus some additional tweaking to the results) and would take some effort to reproduce as is... if you've modified tblproducts with additional fields, and they aren't being shown in the array, then that would imply that the query that creates $products is only selecting specific fields (which would make some sense).

 

{debug} will show you what's available to the template.

 

for the simplest task, the hook will likely be simple too... :)

 

getting one value from a database (e.g logo filename) is potentially just one line within a hook and then at the end of the hook, you just pass all the variables/arrays you've created back to the template for outputting.

Link to comment
Share on other sites

$products is a complicated array that pulls content from a number of different tables (plus some additional tweaking to the results) and would take some effort to reproduce as is... if you've modified tblproducts with additional fields, and they aren't being shown in the array, then that would imply that the query that creates $products is only selecting specific fields (which would make some sense).

The "Greek" way :)

use Illuminate\Database\Capsule\Manager as Capsule;

function ct_product_list($vars) {
   $gid = $_REQUEST["gid"];
   if (!$gid || $gid < 1)
   {
       $sql_ct_products = Capsule::table('tblproducts')
               ->where('hidden','0')
               ->get();
   } else {
       $sql_ct_products = Capsule::table('tblproducts')
               ->where('gid',$gid)
               ->where('hidden','0')
               ->get();        
   }
   $encodedata = json_encode($sql_ct_products);
   $decodedata = json_decode($encodedata, true);

   return array("ct_browse_products" => $decodedata);
}

// If Cart page
if ($filename=="cart")
{

   add_hook("ClientAreaPage",1,"ct_product_list");
}

so I've the array that I want :)

 

{debug} will show you what's available to the template.

Does not works. Have started another thread. I tried many combination but does not works. And the strange is that I'm using {debug} very often in my PHP scripts.

 

- - - Updated - - -

 

Edited.....

A quick question:

->order('order','DESC')
->order('updated_at','DESC')
->order('created_at','DESC')

should works like:

ORDER BY 'order' ASC, updated_at DESC, created_at DESC

Link to comment
Share on other sites

The "Greek" way :)

if you're writing this for WHMCS v7+, then use ClientAreaPageCart instead of ClientAreaPage in your hook and you won't need to check the filename... other than that, hook looks fine to me.

 

Does not works. Have started another thread. I tried many combination but does not works. And the strange is that I'm using {debug} very often in my PHP scripts.

if you're not seeing the window, and assuming your modification to smarty.class isn't causing this (and you shouldn't need to edit it), then my first thought would be to see if the browser/firewall/av is stopping the popup window launching.

 

- - - Updated - - -

 

Edited.....

A quick question:

->order('order','DESC')
->order('updated_at','DESC')
->order('created_at','DESC')

should works like:

ORDER BY 'order' ASC, updated_at DESC, created_at DESC

you want to be using orderBy not order...

 

->orderBy('order','desc')
->orderBy('updated_at','desc')
->orderBy('created_at','desc')

Link to comment
Share on other sites

The first (little) step to the glory :)

https://www.teriakis.com/cart.php?gid=1

The image is there !!

 

- - - Updated - - -

 

Also I seen that user currency is on the session so I can make it multi currency. If I knew the function name to format the price should be fine. Otherwise I need to build my own function. Not a big deal, but I want to shorten the developing time.

Link to comment
Share on other sites

The first (little) step to the glory :)

https://www.teriakis.com/cart.php?gid=1

The image is there !!

well done! :idea:

 

btw - Firefox is showing this popup error...

 

KvKbv2d.png

 

so it's trying to show the {debug} popup window but your browser will be blocking it - if you can tweak your browser to allow popup windows from your site, you should start seeing the debug window. :idea:

 

Also I seen that user currency is on the session so I can make it multi currency. If I knew the function name to format the price should be fine. Otherwise I need to build my own function. Not a big deal, but I want to shorten the developing time.

https://developers.whmcs.com/advanced/currency-formatting/ :)

Link to comment
Share on other sites

Nice :) ....... Now I must keep a bit silence to think about an issue. Like "To be or not to be" ...... To use product configuration template to show product details or design a separate template? I tested and (even with some difficulties) I can use product configuration. The problem is that when user goes to that page to read the details the product is added to the cart. Not good solution. Imagine a user who visited 10 products to read the details. He'll see them on his cart. So most probably I'll insert a separate page between product listing and product configuration. The only that I can do is to add a setting in product table when to use this extra page or goes directly to configuration. In simple words, in product listing the user will see one of:

1.- Order Now (as works now) and he'll redirect to configuration page

2.- More Details which will redirects him to that special page.

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