Jump to content

Monthly / anual pricing display


raymonde1323

Recommended Posts

Hello Everyone.

 

I'm just getting started with whmcs and have gotten the basic setup working good.

 

I am having trouble figuring out how to diplay the product prices the way I want them

 

In my case I have 3 different shared plans with recurring monthly and anual billing options.

 

I am using the "premium comparison" order theme.

 

Problem: The cart shows monthly billing prices for all plans.

 

for each of the 3 plans the anual billing option gives the customer a much cheaper monthly price, but the customer does not see this because the cart is showing the monthly price for the monthly billing option instead.

 

In the cart I want customers too see the monthly price according to the annual billing cycle first before they select a plan and be shown monthly billing cycle price after.

 

Custom coding or theme development would be far over my head. Can someone point out how to solve this in the gui?

 

Have I missed some options or does whmcs not have this feature yet?

 

Any pointers would be great.

Thanks

Link to comment
Share on other sites

Custom coding or theme development would be far over my head. Can someone point out how to solve this in the gui?

it can't be done in the gui - you could enable "Monthly Pricing Breakdown" in setup -> general settings -> ordering and that would show the equivalent monthly price... but the WHMCS templates are coded to show the minimum cycle with a price - that's not necessarily the cheapest price, but the smallest cycle in order (monthly, quarterly, semi etc)..

 

Have I missed some options or does whmcs not have this feature yet?

I don't think it's ever had the feature! :roll:

 

technically, it wouldn't be difficult for WHMCS to add it so that the cheapest price is shown regardless of cycle - even thinking about it as an action hook or Smarty in the template, it would be quite easy to do... perhaps i'll come back and take a closer look one day. :idea:

 

but for your issue, you could do it simply by modifying one line in the premium_comparison/products.tpl template and change ~line 85

 

{$product.pricing.minprice.cycleText}

to...

 

{if $product.pricing.rawpricing.annually neq -1}<span>{$currency.prefix}{($product.pricing.rawpricing.annually/12)|string_format:"%.2f"}{$currency.suffix}</span>/mo{else}{$product.pricing.minprice.cycleText}{/if}

so this works by first checking if the annual price is enabled on the product (if it isn't, it will equal -1 and the minimum cycle price will be shown); if it is, then it calculates the equivalent monthly price (e.g annual price divided by 12 and formats it to 2 decimal places), surrounds it in the current currency and displays the result.

 

unfortunately, WHMCS doesn't calculate the equivalent monthly prices for other cycles in a string format that is handy for your purpose - so we'd either have to modify the string it does create, or perform the calculation ourselves - it's probably simpler to do the calculation! :idea:

 

btw - the above code doesn't check if the monthly price is less than the monthly price breakdown for annual... it could easily be made to do so, but you already know that your annual prices are cheaper, so it shouldn't be necessary for this.

Link to comment
Share on other sites

but for your issue, you could do it simply by modifying one line in the premium_comparison/products.tpl template and change ~line 85

 

{$product.pricing.minprice.cycleText}

to...

 

{if $product.pricing.rawpricing.annually neq -1}<span>{$currency.prefix}{($product.pricing.rawpricing.annually/12)|string_format:"%.2f"}{$currency.suffix}</span>/mo{else}{$product.pricing.minprice.cycleText}{/if}

 

Thank you so much for taking the time to answer this post. By the looks of it your code works perfectly and it only took me 5 minutes to do. Much appreciated. :D:D:D

This was exactly what I wanted.

Link to comment
Share on other sites

  • 4 years later...

Thank you also. really appreciated this as it pointed me in the right direction.

I expanded this a little to suit my needs as below and thought I woudl share.

If the product has an annual fee and a monthly fee (annual payment is more cost effective that monthly payment. both are displayed, but if only monthly or only annually then the rel event price is displayed.

{if $product.pricing.rawpricing.annually neq -1}
   <span>{$currency.prefix}{($product.pricing.rawpricing.annually)|string_format:"%.2f"}</span>
   <br><strong>(Annually)</strong><br>Or
   <br><strong>{$currency.prefix}{($product.pricing.rawpricing.monthly)|string_format:"%.2f"}(Monthly)</strong>
<br> 
   {if product.pricing.minprice.setupFee}                           
      <small>{$product.pricing.minprice.setupFee->toPrefixed()} {$LANG.ordersetupfee}</small>{/if}
{else} 
{$product.pricing.minprice.cycleText}{/if}

 

 

Link to comment
Share on other sites

  • 2 months later...

a Little add on to have it display annual cycle when you click order, and after you select domain...

line 95 > 97

 

after>  a=add   insert>   &amp;billingcycle=annually

from:

                                                <a href="{$smarty.server.PHP_SELF}?a=add&amp;{if $product.bid}bid={$product.bid}{else}pid={$product.pid}{/if}" class="order-button" id="product{$product@iteration}-order-button">
                                                    {$LANG.ordernowbutton}
                                                </a>

to:

                                                <a href="{$smarty.server.PHP_SELF}?a=add&amp;billingcycle=annually&amp;{if $product.bid}bid={$product.bid}{else}pid={$product.pid}{/if}" class="order-button" id="product{$product@iteration}-order-button">
                                                {$LANG.ordernowbutton}
                                                </a>

Link to comment
Share on other sites

  • 11 months later...
On 3/02/2016 at 9:43 PM, brian! said:

it can't be done in the gui - you could enable "Monthly Pricing Breakdown" in setup -> general settings -> ordering and that would show the equivalent monthly price... but the WHMCS templates are coded to show the minimum cycle with a price - that's not necessarily the cheapest price, but the smallest cycle in order (monthly, quarterly, semi etc)..

 

I don't think it's ever had the feature! :roll:

 

technically, it wouldn't be difficult for WHMCS to add it so that the cheapest price is shown regardless of cycle - even thinking about it as an action hook or Smarty in the template, it would be quite easy to do... perhaps i'll come back and take a closer look one day. :idea:

 

but for your issue, you could do it simply by modifying one line in the premium_comparison/products.tpl template and change ~line 85

 

 


{$product.pricing.minprice.cycleText}
 

 

to...

 

 


{if $product.pricing.rawpricing.annually neq -1}<span>{$currency.prefix}{($product.pricing.rawpricing.annually/12)|string_format:"%.2f"}{$currency.suffix}</span>/mo{else}{$product.pricing.minprice.cycleText}{/if}
 

 

so this works by first checking if the annual price is enabled on the product (if it isn't, it will equal -1 and the minimum cycle price will be shown); if it is, then it calculates the equivalent monthly price (e.g annual price divided by 12 and formats it to 2 decimal places), surrounds it in the current currency and displays the result.

 

unfortunately, WHMCS doesn't calculate the equivalent monthly prices for other cycles in a string format that is handy for your purpose - so we'd either have to modify the string it does create, or perform the calculation ourselves - it's probably simpler to do the calculation! :idea:

 

btw - the above code doesn't check if the monthly price is less than the monthly price breakdown for annual... it could easily be made to do so, but you already know that your annual prices are cheaper, so it shouldn't be necessary for this.

Thanks, this is working good, except its not showing the $currency.prefix and making hard to guess what is the currency, plz advise.Capture.png

Link to comment
Share on other sites

21 hours ago, bs1 said:

Thanks, this is working good, except its not showing the $currency.prefix and making hard to guess what is the currency, plz advise.

it is a 5-year old thread! 🙂

{if $product.pricing.rawpricing.annually neq -1}<span>{$activeCurrency.prefix}{($product.pricing.rawpricing.annually/12)|string_format:"%.2f"}{$activeCurrency.suffix}</span>/mo{else}{$product.pricing.minprice.cycleText}{/if}
Link to comment
Share on other sites

54 minutes ago, brian! said:

it is a 5-year old thread! 🙂


{if $product.pricing.rawpricing.annually neq -1}<span>{$activeCurrency.prefix}{($product.pricing.rawpricing.annually/12)|string_format:"%.2f"}{$activeCurrency.suffix}</span>/mo{else}{$product.pricing.minprice.cycleText}{/if}

Thanks much Brian, but this is still seems to be an issue, can you please advise.

https://cprod.webhost365.net/index.php?rp=/store/general-hosting-us

Link to comment
Share on other sites

2 hours ago, brian! said:

which version of WHMCS are you using ? I seem to recall there was an issue with the first v8.0 versions, so hopefully it's not one of them.

8.0.4,  is that the issue ? is there some work around ?

Link to comment
Share on other sites

  • 2 weeks later...
  • 10 months later...

Hi Brian!

You're the star around here. Thanks for all your contributions.

I was wondering if you had a similar solution but for the "PricingPlan" theme, as I can't locate the same line of code as the one from "Premium Comparison", i.e.:

{$product.pricing.minprice.cycleText}

Also, I have a monthly, annual, biennial and triennial. The longer the billing cycle the cheaper the monthly rate. I'd love to have the triennial monthly price display by default instead of the monthly rate.

I am using WHMCS V8.4.1.

Hope you're able to help!

Link to comment
Share on other sites

  • 1 month later...
On 13/04/2022 at 16:48, MacZil said:

You're the star around here. Thanks for all your contributions.

a faded star - i've moved on to a happier life no longer thinking about WHMCS. 😎

On 13/04/2022 at 16:48, MacZil said:

I was wondering if you had a similar solution but for the "PricingPlan" theme, as I can't locate the same line of code as the one from "Premium Comparison", i.e.:

is "PricingPlan" a third-party theme? if so, then contacting it's developer might be useful.. or perhaps add {debug} to the code within the relevant template (I guess it would be products.tpl) and refresh the page - it should generate a popup window of (most) of the available variables... hopefully the variable you want will be in there... and then don't forget to remove {debug} from the template code when you're finished.

On 13/04/2022 at 16:48, MacZil said:

Also, I have a monthly, annual, biennial and triennial. The longer the billing cycle the cheaper the monthly rate. I'd love to have the triennial monthly price display by default instead of the monthly rate.

depending on the theme, this might be a case of editing the template (if the cycle options are shown via multiple IF statements), or reversing the array if it's a loop - I will no doubt have posted solutions previous to both options... perhaps do a search on "triennial" or "triennially" and using my author name as a search option... don't go to far back, i'm pretty sure the reversing the array option would have been posted in 2018-2020... I can remember it was for an Indian poster.

if I was familiar with the theme you were mentioning, then I could give a more useful reply.

On 13/04/2022 at 16:48, MacZil said:

I am using WHMCS V8.4.1.

I never got around to installing v8.4 - got the files, just not the inclination, or need, to install it - perhaps when v8.5 goes GA, i'll take a look at that version... or perhaps not. 🙂

Link to comment
Share on other sites

Thanks @brian! you're a legend! That helped get me on the track and now it's working 100%.

On 5/29/2022 at 1:55 PM, brian! said:

a faded star - i've moved on to a happier life no longer thinking about WHMCS. 😎

Happy for you but sad to see you go; you've been a real community treasure here! Wishing you all the best on your new adventure and hope you continue to visit here occasionally.

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