Jump to content
Sign in to follow this  
raymonde1323

Monthly / anual pricing display

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

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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}

 

 

Share this post


Link to post
Share on other sites

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>

Share this post


Link to post
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.

Sign in to follow this  

  • 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