Jump to content

Tutorial: How to modify the Recurring Billing Cycle text.


brian!

Recommended Posts

When choosing a product that has a recurring billing cycle, WHMCS will show the price in one of two fixed ways – depending on whether the "Monthly Pricing Breakdown" checkbox is ticked in the "Ordering" settings tab within the Admin Area.

 

If it is not ticked, then the price will be displayed alongside the cycle names (taken from the language files) for the available cycles – if there are setup fees included for the cycle, they will be added to the end of the text (shown below on the left).

 

However, if the checkbox is ticked, then WHMCS will not display the total cost of the cycles, but will calculate an equivalent monthly price for each of them instead (shown below on the right).

 

billingcycle_01_default.png

 

A question was asked in the Community Forum by Ambarella about how to show the total price, the saving from the minimum cycle and also the monthly price for each cycle – e.g. for a layout such as this:

 

Monthly Cost $6.00

Annual Cost $60 (Save $12) - $5 P/m

Biennially Cost $96 (Save $48 ) - $4 P/m

 

http://forum.whmcs.com/showthread.php?84298-How-to-display-discounted-pricing-on-order-pages

 

I was intrigued to see if there was an answer to this question as it has previously been asked many times and as far as I could tell, never really answered.

 

Unfortunately, it is not possible to do this solely by changing any admin settings – the above two methods for displaying the cost of recurring billing cycles are hard-coded into WHMCS. If we were looking to only make a minor change to either layout, it would be possible to do so by slightly modifying the language files and tweaking the existing billing cycle variable in the template. However, Ambarella’s desired layout uses aspects of both methods and then additionally wishes to show the saving too - minor tweaking wouldn’t be sufficient to do this and so a more thorough solution has to be developed.

 

The final solution turned out to be far simpler, from a coding point of view, than I had first imagined as most of the required variables were easily obtainable. I have also tried to keep it flexible and simple enough for others to modify for their own needs.

 

This has been tested using the latest release of WHMCS as I write this, v5.3.4, and will work with all of the default order form templates (Ajaxcart, Boxes, Cart, Comparison, Modern, Slider, Verticalsteps and Web20Cart). If they’re similar in design to the default templates, I can see no reason why this solution shouldn’t work with customised order form templates either.

 

There are three steps to this solution, listed below, and I will go through each of them briefly before bringing them all together to show the completed result.

 

  1. Possible changes to the language file(s).
  2. Creation of the new variables to calculate and store the required values.
  3. Modifying the template to use these new variables.

 

Language Files

 

The two default methods for showing recurring billing cycles use existing language variables in their display. When “Monthly Pricing Breakdown” is enabled, the following variables are used. In the example below, this is their values from the english.php language file:

 

$_LANG['orderpaymentterm1month'] = "1 Month Price";
$_LANG['orderpaymentterm3month'] = "3 Month Price";
$_LANG['orderpaymentterm6month'] = "6 Month Price";
$_LANG['orderpaymentterm12month'] = "12 Month Price";
$_LANG['orderpaymentterm24month'] = "24 Month Price";
$_LANG['orderpaymentterm36month'] = "36 Month Price";

When disabled, it uses the following variables:

 

$_LANG['orderpaymenttermmonthly'] = "Monthly";
$_LANG['orderpaymenttermquarterly'] = "Quarterly";
$_LANG['orderpaymenttermsemiannually'] = "Semi-Annually";
$_LANG['orderpaymenttermannually'] = "Annually";
$_LANG['orderpaymenttermbiennially'] = "Biennially";
$_LANG['orderpaymenttermtriennially'] = "Triennially";

 

Ideally, if you can use any of the above groups of variables without modifying them, then it is probably easier to do so.

 

But if you feel that you need to modify any of them for use with this method, I would strongly urge you to consider the consequences carefully before doing so. The second group of variables (Monthly, Quarterly, Semi-Annually etc) are also used on the cart summary page, viewcart.tpl, and so any changes you make to them for use in the billing cycle page, will also affect their display on the cart summary page too.

billingcycle_03_default_viewcart.png

 

 

As an aside, I should probably add that if your WHMCS site only uses one language, then you could code the language directly in the template rather than using language variables – but for the sake of this tutorial, I will assume you are not and use the language files.

 

Using the example of Ambarella’s desired output of "Monthly Cost", "Quarterly Cost" etc, you might think that it would be easier to use the existing variable for "Monthly", add another variable to store "Cost" - then use them together.

 

While this might work in English, it would not necessary be grammatically correct in other languages – for example, in the French.php language file, the value for "Monthly" is:

 

$_LANG['orderpaymenttermmonthly'] = "Mensuel";

The French word for "Cost" is "coût" – so if we put them together, we would get "Mensuel coût". Using my (limited!) understanding of French, I think that it should really be "coût mensuel" – and this appears to be confirmed by Google Translate.

 

So to make things easier, we will start by creating six new language variables for use with this recurring billing cycle solution and add them to the language override file(s).

 

 

Language Overrides

 

Although we can edit the existing language files in WHMCS, it is recommended that you do not because when you update WHMCS, you will overwrite these language files – and subsequently lose any changes that you have made to them.

 

http://docs.whmcs.com/Language_Overrides

 

To create a Language Override file, we would follow this procedure:

 

  1. Create the folder 'overrides' within the 'lang' folder.
  2. Create or copy the language file you want to override. For example, to create an override for the French language you create ./lang/overrides/french.php
  3. Open the newly created file in your preferred editor.
  4. Start the file with a PHP tag '<?php' indicating PHP code is to be used.

 

Try to use variable names that make sense to where they’re being used, and have not previously been used. So, for our six recurring billing cycles, let’s use the following:

 

$_LANG['billingcyclemonth'] = "Monthly Cost";
$_LANG['billingcyclequart'] = "Quarterly Cost";
$_LANG['billingcyclesemi'] = "Semi-Annual Cost";
$_LANG['billingcycleannual'] = "Annual Cost";
$_LANG['billingcyclebienn'] = "Biennial Cost";
$_LANG['billingcycletrienn'] = "Triennial Cost"; 

To get Ambarella’s output, we will need two additional new language variables – one for “Saving” and another for “Per Month”.

 

$_LANG['cyclesaving'] = "Save";
$_LANG['permonth'] = "P/m"; 

Now that we have these language variables created, we can move on to making the calculations and saving

them for use in the display.

 

 

Calculations and Variables

 

 

As the template system used by WHMCS is based on Smarty, I have used only Smarty code for this solution. It would be possible to perform these calculations using PHP within the template, but it is often frowned upon to use {php} tags in the templates. Also, I believe that as of Smarty v3, the option to do use {php} has been removed. Although WHMCS currently uses Smarty v2, I am sure that at some point it will be upgraded.

 

Therefore, as it should be easier for others to follow, and hopefully avoid future upgrade complications, I decided to write the solution entirely using Smarty tags.

 

We need to calculate the saving of a recurring billing cycle compared to the minimum billing cycle – this would probably be the monthly cycle, but this is not always the case. Usefully, the variable that stores the minimum billing cycle is available to us and so we can use it in our calculations to determine the correct savings for each enabled recurring billing cycle based on the minimum cycle.

 

Additionally, we need to calculate the price per month of a recurring billing cycle – but this is simple as it is just the total price for the billing cycle divided by its total number of months.

 

So let’s start with the easier step first – calculating the price per month of a cycle. Obviously, we don’t have to calculate the price per month for the monthly cycle, so we just need to work out the other five.

For this we need two variables - the total billing cycle cost (which we can obtain from existing variables) and the number of months in each cycle (which we will define ourselves).

 

First, we create a new variable and give it a value of zero to ensure that any calculations are not added to any previous total. Then, using the {math} Smarty tag, we assign our result to this variable; define what the equation is; specify the variables we’re using in the equation and set the format of the resulting answer... and then repeat the same process for the remaining recurring billing cycles.

 

{assign var="qmonthprice" value=0}
{math assign="qmonthprice" equation="d / b" b=3 d=$pricing.rawpricing.quarterly format="%.2f"}
{assign var="smonthprice" value=0}
{math assign="smonthprice" equation="d / b" b=6 d=$pricing.rawpricing.semiannually format="%.2f"}
{assign var="amonthprice" value=0}
{math assign="amonthprice" equation="d / b" b=12 d=$pricing.rawpricing.annually format="%.2f"}
{assign var="bmonthprice" value=0}
{math assign="bmonthprice" equation="d / b" b=24 d=$pricing.rawpricing.biennially format="%.2f"}
{assign var="tmonthprice" value=0}
{math assign="tmonthprice" equation="d / b" b=36 d=$pricing.rawpricing.triennially format="%.2f"}    

The above code will create the price per month for each recurring billing cycle and store it to two decimal places.

 

Next we need to calculate the savings – this uses a similar method to the previous example, but there are more variables required and thus the equation itself is more complicated - we will also use an {if} statement to determine what the minimum billing cycle is.

 

To calculate the saving, we also take into account any setup fees for each cycle. For the previous “price per month” calculation, I have ignored any setup fees – but these could easily be added by modifying the previous equations if you wished to include them.

 

As the minimum billing cycle increases, there are fewer additional cycles available and so fewer calculations will be required. For "Monthly", there are five saving calculations to be made – but by the time the minimum cycle is "Biennial", there is only one calculation required. If the minimum billing cycle is "Triennial", then it will not necessary to calculate any savings as there will only be one recurring billing cycle available.

 

Here is a small example of the required code...

 

{if $pricing.minprice.cycle eq "monthly"}
{assign var="qsaving" value=0}
{math assign="qsaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.monthly b=3 c=$pricing.rawpricing.msetupfee d=$pricing.rawpricing.quarterly e=$pricing.rawpricing.qsetupfee format="%.2f"}
{/if}

The above code will calculate the savings for the quarterly billing cycle based on the minimum billing cycle being monthly, and store it to two decimal places.

 

So we have our modified language variables; we have created our equations to calculate the price per month / cycle savings and assigned them to new variables – the third step is to integrate these into the templates.

 

Template Modifications

 

As I stated earlier in this tutorial, this solution will work for all of the default order form templates and should work for customised order form templates too.

 

While there might be slight variations in the code used to create the billing cycle table in the different order form templates, the six important variables remain the same – and it is only these that you will need to replace with my new code.

 

{$pricing.monthly}, {$pricing.quarterly}, {$pricing.semi-annually}, {$pricing.annually}, {$pricing.biennially} and {$pricing.triennally}

 

If we use "Comparison" as an example and look at the current code for displaying the monthly cycle:

 

{if $pricing.monthly}<tr><td class="radiofield">
<input type="radio" name="billingcycle" id="cycle1" value="monthly"{if $billingcycle eq "monthly"} checked{/if} onclick="submit()" /></td><td class="fieldarea"><label for="cycle1">{$pricing.monthly}</label></td></tr>{/if}

To use the new modified code to display our customised layout, you need to replace the above with:

 

{if $pricing.monthly}<tr><td class="radiofield">

<input type="radio" name="billingcycle" id="cycle1" value="monthly"{if $billingcycle eq "monthly"} checked{/if} onclick="submit()" /></td><td class="fieldarea"><label for="cycle1">{$LANG.billingcyclemonth} {$currency.prefix}{$pricing.rawpricing.monthly}{$currency.suffix}{if $pricing.rawpricing.msetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.msetupfee}{$currency.suffix} {$LANG.ordersetupfee}{/if}</label></td></tr>{/if}

 

As you can see, the basics of the layout remain exactly the same, all we have done is replaced {$pricing.monthly} with the following:

 

{$LANG.billingcyclemonth} {$currency.prefix}{$pricing.rawpricing.monthly}{$currency.suffix}{if $pricing.rawpricing.msetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.msetupfee}{$currency.suffix} {$LANG.ordersetupfee}{/if}

 

Some of these variables you will recognise as we have created them previously – the others are defined by WHMCS, either to store price / setup fee values, or currency strings.

 

{$currency.prefix} - The prefix defined in your currency settings, e.g. $, £, € etc or left blank.

{$currency.suffix} - The suffix defined in your currency settings, e.g. USD, GBP, EUR etc or left blank.

 

If we take a look at the next billing cycle, in this case quarterly, you will see some additional code that will generate the saving text (which obviously is not used on the minimum billing cycle).

 

{if $pricing.quarterly}<tr><td class="radiofield">

<input type="radio" name="billingcycle" id="cycle2" value="quarterly"{if $billingcycle eq "quarterly"} checked{/if} onclick="submit()" /></td><td class="fieldarea"><label for="cycle2">{$LANG.billingcyclequart} {$currency.prefix}{$pricing.rawpricing.quarterly}{$currency.suffix} {if $pricing.rawpricing.qsetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.qsetupfee}{$currency.suffix} {$LANG.ordersetupfee}{/if} {if $qsaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$qsaving}{$currency.suffix}){/if} - {$currency.prefix}{$qmonthprice}{$currency.suffix} {$LANG.permonth}</label></td></tr>{/if}

 

After adding the code for the remaining billing cycles, the output using the Comparison order form would be as follows:

 

billingcycle_09_comparison.png

 

In the above examples, I’ve intentionally setup some billing cycles to have setup fees and others not – this was to thoroughly test the equations used.

 

So that’s a brief explanation of the theory, next we will assemble the three steps and bring them together for the finished solution.

 

 

  • Language Files

 

 

As I previously listed, here are the eight new language variables - if you want to use them, remember to add them to your language override file(s). Should you need to add more or change these, please do so!

 

$_LANG['billingcyclemonth'] = "Monthly Cost";
$_LANG['billingcyclequart'] = "Quarterly Cost";
$_LANG['billingcyclesemi'] = "Semi-Annual Cost";
$_LANG['billingcycleannual'] = "Annual Cost";
$_LANG['billingcyclebienn'] = "Biennial Cost";
$_LANG['billingcycletrienn'] = "Triennial Cost";
$_LANG['cyclesaving'] = "Save";
$_LANG['permonth'] = "P/m";

 

 

  • Calculations and Variables

 

If you require calculations and new variables for your solution, add them to the template before the lines in which these newly created variables are called.

 

For this solution, we will need to add the following to the 'configureproduct.tpl' order form template(s) *before* the template modifications of step 3.

 

{* Calculate the price per month *}
{assign var="qmonthprice" value=0}
{math assign="qmonthprice" equation="d / b" b=3  d=$pricing.rawpricing.quarterly format="%.2f"}
{assign var="smonthprice" value=0}
{math assign="smonthprice" equation="d / b" b=6  d=$pricing.rawpricing.semiannually format="%.2f"}
{assign var="amonthprice" value=0}
{math assign="amonthprice" equation="d / b" b=12 d=$pricing.rawpricing.annually format="%.2f"}
{assign var="bmonthprice" value=0}
{math assign="bmonthprice" equation="d / b" b=24 d=$pricing.rawpricing.biennially format="%.2f"}
{assign var="tmonthprice" value=0}
{math assign="tmonthprice" equation="d / b"  b=36 d=$pricing.rawpricing.triennially format="%.2f"}

{* Calculate the cycle savings *}                
{if $pricing.minprice.cycle eq "monthly"}
{assign var="qsaving" value=0}
{math assign="qsaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.monthly b=3 c=$pricing.rawpricing.msetupfee d=$pricing.rawpricing.quarterly e=$pricing.rawpricing.qsetupfee format="%.2f"}
{assign var="ssaving" value=0}
{math assign="ssaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.monthly b=6 c=$pricing.rawpricing.msetupfee d=$pricing.rawpricing.semiannually e=$pricing.rawpricing.ssetupfee format="%.2f"}
{assign var="asaving" value=0}
{math assign="asaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.monthly b=12 c=$pricing.rawpricing.msetupfee d=$pricing.rawpricing.annually e=$pricing.rawpricing.asetupfee format="%.2f"}
{assign var="bsaving" value=0}
{math assign="bsaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.monthly b=24 c=$pricing.rawpricing.msetupfee d=$pricing.rawpricing.biennially e=$pricing.rawpricing.bsetupfee format="%.2f"}
{assign var="tsaving" value=0}
{math assign="tsaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.monthly b=36 c=$pricing.rawpricing.msetupfee d=$pricing.rawpricing.triennially e=$pricing.rawpricing.tsetupfee format="%.2f"}
{elseif $pricing.minprice.cycle eq "quarterly"}
{assign var="ssaving" value=0}
{math assign="ssaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.quarterly b=2 c=$pricing.rawpricing.qsetupfee d=$pricing.rawpricing.semiannually e=$pricing.rawpricing.ssetupfee format="%.2f"}
{assign var="asaving" value=0}
{math assign="asaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.quarterly b=4 c=$pricing.rawpricing.qsetupfee d=$pricing.rawpricing.annually e=$pricing.rawpricing.asetupfee format="%.2f"}
{assign var="bsaving" value=0}
{math assign="bsaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.quarterly b=8 c=$pricing.rawpricing.qsetupfee d=$pricing.rawpricing.biennially e=$pricing.rawpricing.bsetupfee format="%.2f"}
{assign var="tsaving" value=0}
{math assign="tsaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.quarterly b=12 c=$pricing.rawpricing.qsetupfee d=$pricing.rawpricing.triennially e=$pricing.rawpricing.tsetupfee format="%.2f"}
{elseif $pricing.minprice.cycle eq "semiannually"}
{assign var="asaving" value=0}
{math assign="asaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.semiannually b=2 c=$pricing.rawpricing.ssetupfee d=$pricing.rawpricing.annually e=$pricing.rawpricing.asetupfee format="%.2f"}
{assign var="bsaving" value=0}
{math assign="bsaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.semiannually b=4 c=$pricing.rawpricing.ssetupfee d=$pricing.rawpricing.biennially e=$pricing.rawpricing.bsetupfee format="%.2f"}
{assign var="tsaving" value=0}
{math assign="tsaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.semiannually b=8 c=$pricing.rawpricing.ssetupfee d=$pricing.rawpricing.triennially e=$pricing.rawpricing.tsetupfee format="%.2f"}
{elseif $pricing.minprice.cycle eq "annually"}
{assign var="bsaving" value=0}
{math assign="bsaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.annually b=2 c=$pricing.rawpricing.asetupfee d=$pricing.rawpricing.biennially e=$pricing.rawpricing.bsetupfee format="%.2f"}
{assign var="tsaving" value=0}
{math assign="tsaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.annually b=3 c=$pricing.rawpricing.asetupfee d=$pricing.rawpricing.triennially e=$pricing.rawpricing.tsetupfee format="%.2f"}
{elseif $pricing.minprice.cycle eq "biennially"}
{assign var="tsaving" value=0}
{math assign="tsaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.biennially b=1.5 c=$pricing.rawpricing.bsetupfee d=$pricing.rawpricing.triennially e=$pricing.rawpricing.tsetupfee format="%.2f"}
{/if}  

 

 

  • Template Modifications

 

 

In the previous step, we modified the 'configureproduct.tpl' to calculate and assign some new variables. Next, we will replace the existing recurring billing cycle code in that same template file with the new code.

 

To make this solution complete, I will go through the default order form templates and show the existing code, plus the new code to replace it with.

 

 

Ajaxcart

 

 

billingcycle_06_ajaxcart.png

 

The default recurring billing cycle code for Ajaxcart (configureproduct.tpl) is...

 

{if $pricing.monthly}<option value="monthly"{if $billingcycle eq "monthly"} selected="selected"{/if}>{$pricing.monthly}</option>{/if}

{if $pricing.quarterly}<option value="quarterly"{if $billingcycle eq "quarterly"} selected="selected"{/if}>{$pricing.quarterly}</option>{/if}

{if $pricing.semiannually}<option value="semiannually"{if $billingcycle eq "semiannually"} selected="selected"{/if}>{$pricing.semiannually}</option>{/if}

{if $pricing.annually}<option value="annually"{if $billingcycle eq "annually"} selected="selected"{/if}>{$pricing.annually}</option>{/if}

{if $pricing.biennially}<option value="biennially"{if $billingcycle eq "biennially"} selected="selected"{/if}>{$pricing.biennially}</option>{/if}

{if $pricing.triennially}<option value="triennially"{if $billingcycle eq "triennially"} selected="selected"{/if}>{$pricing.triennially}</option>{/if}

 

Replace the above with the new modified code...

 

{if $pricing.monthly}<option value="monthly"{if $billingcycle eq "monthly"} selected="selected"{/if}>{$LANG.billingcyclemonth} {$currency.prefix}{$pricing.rawpricing.monthly}{$currency.suffix}{if $pricing.rawpricing.msetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.msetupfee}{$currency.suffix} {$LANG.ordersetupfee}{/if}</option>{/if}

 

{if $pricing.quarterly}<option value="quarterly"{if $billingcycle eq "quarterly"} selected="selected"{/if}>{$LANG.billingcyclequart} {$currency.prefix}{$pricing.rawpricing.quarterly}{$currency.suffix} {if $pricing.rawpricing.qsetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.qsetupfee}{$currency.suffix} {$LANG.ordersetupfee}{/if} {if $qsaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$qsaving}{$currency.suffix}){/if} - {$currency.prefix}{$qmonthprice}{$currency.suffix} {$LANG.permonth}</option>{/if}

 

{if $pricing.semiannually}<option value="semiannually"{if $billingcycle eq "semiannually"} selected="selected"{/if}>{$LANG.billingcyclesemi} {$currency.prefix}{$pricing.rawpricing.semiannually}{$currency.suffix} {if $pricing.rawpricing.ssetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.ssetupfee}{$currency.suffix} {$LANG.ordersetupfee}{/if} {if $ssaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$ssaving}{$currency.suffix}){/if} - {$currency.prefix}{$smonthprice}{$currency.suffix} {$LANG.permonth}</option>{/if}

 

{if $pricing.annually}<option value="annually"{if $billingcycle eq "annually"} selected="selected"{/if}>{$LANG.billingcycleannual} {$currency.prefix}{$pricing.rawpricing.annually}{$currency.suffix} {if $pricing.rawpricing.asetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.asetupfee}{$currency.suffix} {$LANG.ordersetupfee}{/if} {if $asaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$asaving}{$currency.suffix}){/if} - {$currency.prefix}{$amonthprice}{$currency.suffix} {$LANG.permonth}</option>{/if}

 

{if $pricing.biennially}<option value="biennially"{if $billingcycle eq "biennially"} selected="selected"{/if}>{$LANG.billingcyclebienn} {$currency.prefix}{$pricing.rawpricing.biennially}{$currency.suffix} {if $pricing.rawpricing.bsetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.bsetupfee}{$currency.suffix} {$LANG.ordersetupfee}{/if} {if $bsaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$bsaving}{$currency.suffix}){/if} - {$currency.prefix}{$bmonthprice}{$currency.suffix} {$LANG.permonth}</option>{/if}

 

{if $pricing.triennially}<option value="triennially"{if $billingcycle eq "triennially"} selected="selected"{/if}>{$LANG.billingcycletrienn} {$currency.prefix}{$pricing.rawpricing.triennially}{$currency.suffix} {if $pricing.rawpricing.tsetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.tsetupfee}{$currency.suffix} {$LANG.ordersetupfee}{/if} {if $tsaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$tsaving}{$currency.suffix}){/if} - {$currency.prefix}{$tmonthprice}{$currency.suffix} {$LANG.permonth}</option>{/if}

Please note: This code appeared not to work in v5.3.3, but following the v5.3.4 maintenance release, the pricing bugs have been fixed in WHMCS and this solution now works using Ajaxcart in v5.3.4

 

 

Boxes

 

 

billingcycle_07_boxes.png

The original code and the replacement code are the same as for Ajaxcart.

 

Cart

 

 

billingcycle_08_cart.png

 

The original code and the replacement code are the same as for Ajaxcart.

 

Comparison

 

 

The default recurring billing cycle code for Comparison (configureproduct.tpl) is...

 

<table width="100%" cellspacing="0" cellpadding="0" class="configtable">

{if $pricing.monthly}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle1" value="monthly"{if $billingcycle eq "monthly"} checked{/if} onclick="submit()" /></td><td class="fieldarea"><label for="cycle1">{$pricing.monthly}</label></td></tr>{/if}

 

{if $pricing.quarterly}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle2" value="quarterly"{if $billingcycle eq "quarterly"} checked{/if} onclick="submit()" /></td><td class="fieldarea"><label for="cycle2">{$pricing.quarterly}</label></td></tr>{/if}

 

{if $pricing.semiannually}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle3" value="semiannually"{if $billingcycle eq "semiannually"} checked{/if} onclick="submit()" /></td><td class="fieldarea"><label for="cycle3">{$pricing.semiannually}</label></td></tr>{/if}

 

{if $pricing.annually}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle4" value="annually"{if $billingcycle eq "annually"} checked{/if} onclick="submit()" /></td><td class="fieldarea"><label for="cycle4">{$pricing.annually}</label></td></tr>{/if}

 

{if $pricing.biennially}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle5" value="biennially"{if $billingcycle eq "biennially"} checked{/if} onclick="submit()" /></td><td class="fieldarea"><label for="cycle5">{$pricing.biennially}</label></td></tr>{/if}

 

{if $pricing.triennially}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle6" value="triennially"{if $billingcycle eq "triennially"} checked{/if} onclick="submit()" /></td><td class="fieldarea"><label for="cycle6">{$pricing.triennially}</label></td></tr>{/if}

</table>

Replace the above with the new modified code...

 

<table width="100%" cellspacing="0" cellpadding="0" class="configtable">

{if $pricing.monthly}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle1" value="monthly"{if $billingcycle eq "monthly"} checked{/if} onclick="submit()" /></td><td class="fieldarea"><label for="cycle1">{$LANG.billingcyclemonth} {$currency.prefix}{$pricing.rawpricing.monthly}{$currency.suffix}{if $pricing.rawpricing.msetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.msetupfee}{$currency.suffix} {$LANG.ordersetupfee}{/if}</label></td></tr>{/if}

 

{if $pricing.quarterly}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle2" value="quarterly"{if $billingcycle eq "quarterly"} checked{/if} onclick="submit()" /></td><td class="fieldarea"><label for="cycle2">{$LANG.billingcyclequart} {$currency.prefix}{$pricing.rawpricing.quarterly}{$currency.suffix} {if $pricing.rawpricing.qsetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.qsetupfee}{$currency.suffix} {$LANG.ordersetupfee}{/if} {if $qsaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$qsaving}{$currency.suffix}){/if} - {$currency.prefix}{$qmonthprice}{$currency.suffix} {$LANG.permonth}</label></td></tr>{/if}

 

{if $pricing.semiannually}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle3" value="semiannually"{if $billingcycle eq "semiannually"} checked{/if} onclick="submit()" /></td><td class="fieldarea"><label for="cycle3">{$LANG.billingcyclesemi} {$currency.prefix}{$pricing.rawpricing.semiannually}{$currency.suffix} {if $pricing.rawpricing.ssetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.ssetupfee}{$currency.suffix} {$LANG.ordersetupfee}{/if} {if $ssaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$ssaving}{$currency.suffix}){/if} - {$currency.prefix}{$smonthprice}{$currency.suffix} {$LANG.permonth}</label></td></tr>{/if}

 

{if $pricing.annually}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle4" value="annually"{if $billingcycle eq "annually"} checked{/if} onclick="submit()" /></td><td class="fieldarea"><label for="cycle4">{$LANG.billingcycleannual} {$currency.prefix}{$pricing.rawpricing.annually}{$currency.suffix} {if $pricing.rawpricing.asetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.asetupfee}{$currency.suffix} {$LANG.ordersetupfee}{/if} {if $asaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$asaving}{$currency.suffix}){/if} - {$currency.prefix}{$amonthprice}{$currency.suffix} {$LANG.permonth}</label></td></tr>{/if}

 

{if $pricing.biennially}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle5" value="biennially"{if $billingcycle eq "biennially"} checked{/if} onclick="submit()" /></td><td class="fieldarea"><label for="cycle5">{$LANG.billingcyclebienn} {$currency.prefix}{$pricing.rawpricing.biennially}{$currency.suffix} {if $pricing.rawpricing.bsetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.bsetupfee}{$currency.suffix} {$LANG.ordersetupfee}{/if} {if $bsaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$bsaving}{$currency.suffix}){/if} - {$currency.prefix}{$bmonthprice}{$currency.suffix} {$LANG.permonth}</label></td></tr>{/if}

 

{if $pricing.triennially}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle6" value="triennially"{if $billingcycle eq "triennially"} checked{/if} onclick="submit()" /></td><td class="fieldarea"><label for="cycle6">{$LANG.billingcycletrienn} {$currency.prefix}{$pricing.rawpricing.triennially}{$currency.suffix} {if $pricing.rawpricing.tsetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.tsetupfee}{$currency.suffix} {$LANG.ordersetupfee}{/if} {if $tsaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$tsaving}{$currency.suffix}){/if} - {$currency.prefix}{$tmonthprice}{$currency.suffix} {$LANG.permonth}</label></td></tr>{/if}

</table>

 

 

Modern & Slider

billingcycle_10_modern.png

 

The default recurring billing cycle code for Modern & Slider (configureproduct.tpl) is...

<table width="100%" cellspacing="0" cellpadding="0" class="configtable">

{if $pricing.monthly}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle1" value="monthly"{if $billingcycle eq "monthly"} checked{/if} onclick="recalctotals()" /></td><td class="fieldarea"><label for="cycle1">{$pricing.monthly}</label></td></tr>{/if}

{if $pricing.quarterly}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle2" value="quarterly"{if $billingcycle eq "quarterly"} checked{/if} onclick="recalctotals()" /></td><td class="fieldarea"><label for="cycle2">{$pricing.quarterly}</label></td></tr>{/if}

{if $pricing.semiannually}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle3" value="semiannually"{if $billingcycle eq "semiannually"} checked{/if} onclick="recalctotals()" /></td><td class="fieldarea"><label for="cycle3">{$pricing.semiannually}</label></td></tr>{/if}

{if $pricing.annually}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle4" value="annually"{if $billingcycle eq "annually"} checked{/if} onclick="recalctotals()" /></td><td class="fieldarea"><label for="cycle4">{$pricing.annually}</label></td></tr>{/if}

{if $pricing.biennially}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle5" value="biennially"{if $billingcycle eq "biennially"} checked{/if} onclick="recalctotals()" /></td><td class="fieldarea"><label for="cycle5">{$pricing.biennially}</label></td></tr>{/if}

{if $pricing.triennially}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle6" value="triennially"{if $billingcycle eq "triennially"} checked{/if} onclick="recalctotals()" /></td><td class="fieldarea"><label for="cycle6">{$pricing.triennially}</label></td></tr>{/if}

 

Replace the above with the new modified code...

<table width="100%" cellspacing="0" cellpadding="0" class="configtable">

{if $pricing.monthly}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle1" value="monthly"{if $billingcycle eq "monthly"} checked{/if} onclick="recalctotals()" /></td><td class="fieldarea"><label for="cycle1">{$LANG.billingcyclemonth} {$currency.prefix}{$pricing.rawpricing.monthly}{$c urrency.suffix}{if $pricing.rawpricing.msetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.msetupfee}{ $currency.suffix} {$LANG.ordersetupfee}{/if}</label></td></tr>{/if}

 

{if $pricing.quarterly}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle2" value="quarterly"{if $billingcycle eq "quarterly"} checked{/if} onclick="recalctotals()" /></td><td class="fieldarea"><label for="cycle2">{$LANG.billingcyclequart} {$currency.prefix}{$pricing.rawpricing.quarterly}{ $currency.suffix} {if $pricing.rawpricing.qsetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.qsetupfee}{ $currency.suffix} {$LANG.ordersetupfee}{/if} {if $qsaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$qsaving}{$currency.suffix}){/if} - {$currency.prefix}{$qmonthprice}{$currency.suffix} {$LANG.permonth}</label></td></tr>{/if}

 

{if $pricing.semiannually}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle3" value="semiannually"{if $billingcycle eq "semiannually"} checked{/if} onclick="recalctotals()" /></td><td class="fieldarea"><label for="cycle3">{$LANG.billingcyclesemi} {$currency.prefix}{$pricing.rawpricing.semiannuall y}{$currency.suffix} {if $pricing.rawpricing.ssetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.ssetupfee}{ $currency.suffix} {$LANG.ordersetupfee}{/if} {if $ssaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$ssaving}{$currency.suffix}){/if} - {$currency.prefix}{$smonthprice}{$currency.suffix} {$LANG.permonth}</label></td></tr>{/if}

 

{if $pricing.annually}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle4" value="annually"{if $billingcycle eq "annually"} checked{/if} onclick="recalctotals()" /></td><td class="fieldarea"><label for="cycle4">{$LANG.billingcycleannual} {$currency.prefix}{$pricing.rawpricing.annually}{$ currency.suffix} {if $pricing.rawpricing.asetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.asetupfee}{ $currency.suffix} {$LANG.ordersetupfee}{/if} {if $asaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$asaving}{$currency.suffix}){/if} - {$currency.prefix}{$amonthprice}{$currency.suffix} {$LANG.permonth}</label></td></tr>{/if}

 

{if $pricing.biennially}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle5" value="biennially"{if $billingcycle eq "biennially"} checked{/if} onclick="recalctotals()" /></td><td class="fieldarea"><label for="cycle5">{$LANG.billingcyclebienn} {$currency.prefix}{$pricing.rawpricing.biennially} {$currency.suffix} {if $pricing.rawpricing.bsetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.bsetupfee}{ $currency.suffix} {$LANG.ordersetupfee}{/if} {if $bsaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$bsaving}{$currency.suffix}){/if} - {$currency.prefix}{$bmonthprice}{$currency.suffix} {$LANG.permonth}</label></td></tr>{/if}

 

{if $pricing.triennially}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle6" value="triennially"{if $billingcycle eq "triennially"} checked{/if} onclick="recalctotals()" /></td><td class="fieldarea"><label for="cycle6">{$LANG.billingcycletrienn} {$currency.prefix}{$pricing.rawpricing.triennially }{$currency.suffix} {if $pricing.rawpricing.tsetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.tsetupfee}{ $currency.suffix} {$LANG.ordersetupfee}{/if} {if $tsaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$tsaving}{$currency.suffix}){/if} - {$currency.prefix}{$tmonthprice}{$currency.suffix} {$LANG.permonth}</label></td></tr>{/if}

</table>

 

 

Verticalsteps

 

 

billingcycle_11_vertical.png

 

The original code and the replacement code are the same as for Ajaxcart.

 

 

Web20Cart

 

billingcycle_12_web20cart.png

 

The original code and the replacement code are the same as for Ajaxcart.

 

 

Taking the solution to the next level

 

 

During this tutorial, I’ve shown how, instead of using either of the default WHMCS predefined displays of recurring billing cycles, we can define and use our own specified layout.

 

But, why stop there? Now that we are no longer constrained by hardcoded displays, we could take this further and make other changes... some trivial, others cosmetic and perhaps one or two that are very powerful!

 

Ok, let’s start off with something trivial that you can use on those templates that don’t have a dropdown to display the cycles – e.g., Comparison, Modern and Slider.

 

If you wanted to bold the billing cycle names, and perhaps highlight any potential savings by showing them in red, you could use the following code:

 

{if $pricing.monthly}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle1" value="monthly"{if $billingcycle eq "monthly"} checked{/if} onclick="submit()" /></td><td class="fieldarea"><label for="cycle1"><strong>{$LANG.billingcyclemonth}</strong> {$currency.prefix}{$pricing.rawpricing.monthly}{$currency.suffix}{if $pricing.rawpricing.msetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.msetupfee}{$currency.suffix} {$LANG.ordersetupfee}{/if}</label></td></tr>{/if}

 

{if $pricing.quarterly}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle2" value="quarterly"{if $billingcycle eq "quarterly"} checked{/if} onclick="submit()" /></td><td class="fieldarea"><label for="cycle2"><strong>{$LANG.billingcyclequart}</strong> {$currency.prefix}{$pricing.rawpricing.quarterly}{$currency.suffix} {if $pricing.rawpricing.qsetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.qsetupfee}{$currency.suffix} {$LANG.ordersetupfee}{/if} {if $qsaving gt 0}<font color="red">({$LANG.cyclesaving} {$currency.prefix}{$qsaving}{$currency.suffix})</font>{/if} - {$currency.prefix}{$qmonthprice}{$currency.suffix} {$LANG.permonth}</label></td></tr>{/if}

 

{if $pricing.semiannually}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle3" value="semiannually"{if $billingcycle eq "semiannually"} checked{/if} onclick="submit()" /></td><td class="fieldarea"><label for="cycle3"><strong>{$LANG.billingcyclesemi}</strong> {$currency.prefix}{$pricing.rawpricing.semiannually}{$currency.suffix} {if $pricing.rawpricing.ssetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.ssetupfee}{$currency.suffix} {$LANG.ordersetupfee}{/if} {if $ssaving gt 0}<font color="red">({$LANG.cyclesaving} {$currency.prefix}{$ssaving}{$currency.suffix})</font>{/if} - {$currency.prefix}{$smonthprice}{$currency.suffix} {$LANG.permonth}</label></td></tr>{/if}

 

{if $pricing.annually}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle4" value="annually"{if $billingcycle eq "annually"} checked{/if} onclick="submit()" /></td><td class="fieldarea"><label for="cycle4"><strong>{$LANG.billingcycleannual}</strong> {$currency.prefix}{$pricing.rawpricing.annually}{$currency.suffix} {if $pricing.rawpricing.asetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.asetupfee}{$currency.suffix} {$LANG.ordersetupfee}{/if} {if $asaving gt 0}<font color="red">({$LANG.cyclesaving} {$currency.prefix}{$asaving}{$currency.suffix})</font>{/if} - {$currency.prefix}{$amonthprice}{$currency.suffix} {$LANG.permonth}</label></td></tr>{/if}

 

{if $pricing.biennially}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle5" value="biennially"{if $billingcycle eq "biennially"} checked{/if} onclick="submit()" /></td><td class="fieldarea"><label for="cycle5"><strong>{$LANG.billingcyclebienn}</strong> {$currency.prefix}{$pricing.rawpricing.biennially}{$currency.suffix} {if $pricing.rawpricing.bsetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.bsetupfee}{$currency.suffix} {$LANG.ordersetupfee}{/if} {if $bsaving gt 0}<font color="red">({$LANG.cyclesaving} {$currency.prefix}{$bsaving}{$currency.suffix})</font>{/if} - {$currency.prefix}{$bmonthprice}{$currency.suffix} {$LANG.permonth}</label></td></tr>{/if}

 

{if $pricing.triennially}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle6" value="triennially"{if $billingcycle eq "triennially"} checked{/if} onclick="submit()" /></td><td class="fieldarea"><label for="cycle6"><strong>{$LANG.billingcycletrienn}</strong> {$currency.prefix}{$pricing.rawpricing.triennially}{$currency.suffix} {if $pricing.rawpricing.tsetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.tsetupfee}{$currency.suffix} {$LANG.ordersetupfee}{/if} {if $tsaving gt 0}<font color="red">({$LANG.cyclesaving} {$currency.prefix}{$tsaving}{$currency.suffix})</font>{/if} - {$currency.prefix}{$tmonthprice}{$currency.suffix} {$LANG.permonth}</label></td></tr>{/if}

billingcycle_13_enhanced.png

 

When originally working out the Smarty code for this tutorial, I did consider using combined variables as WHMCS currently does, e.g $pricing.monthly etc, where a number of variables are assembled together to create a single easily callable variable.

 

However, I decided against doing this for a number of reasons – firstly, I wanted to show all the component variables separately to make it easier for others to remove or add variables themselves; Secondly, because the variables are separate, each can be modified (either with Smarty code or as with the above html/css) individually and thirdly, in most circumstances I can foresee with this, I don’t think there’s any real advantage in doing so!

 

So we’ve modified the display a little, but why don’t we try to do something a little more powerful!

 

Up until this point, we have simply been replacing the default method of displaying the recurring billing cycles with our customised solution - but if we can create one solution, why not a second, a third or a hundred?

 

We are now in a position where, instead of WHMCS just using one recurring billing cycle display method for the entire site, we can specify different cycle displays for each product and/or product group.

 

Put simply – each individual product or product group can use its own method for displaying recurring billing cycles, as defined by you!

 

The code itself is straightforward and uses the variables for Group ID (gid) and Product ID (pid) – these values can be obtained from the “Direct Cart Links” section of the Product or Product Group in the Admin Area - http://docs.whmcs.com/Products_and_Services#Links_tab

 

As an example, let’s use Ajaxcart and specify a custom display method for one product – all other products will use the default method of display (in practice this could be another custom layout, but to save time and keep things simple, we’ll use the default display code).

 

in basic terms, this:

 

{if $productinfo.pid eq '34'}

*show custom display*

{else}

*show default display*

{/if}

 

In actual code...

 

{if $productinfo.pid eq '34'}

 

{if $pricing.monthly}<option value="monthly"{if $billingcycle eq "monthly"} selected="selected"{/if}>{$LANG.billingcyclemonth} {$currency.prefix}{$pricing.rawpricing.monthly}{$currency.suffix}{if $pricing.rawpricing.msetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.msetupfee}{$currency.suffix} {$LANG.ordersetupfee}{/if}</option>{/if}

 

{if $pricing.quarterly}<option value="quarterly"{if $billingcycle eq "quarterly"} selected="selected"{/if}>{$LANG.billingcyclequart} {$currency.prefix}{$pricing.rawpricing.quarterly}{$currency.suffix} {if $pricing.rawpricing.qsetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.qsetupfee}{$currency.suffix} {$LANG.ordersetupfee}{/if} {if $qsaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$qsaving}{$currency.suffix}){/if} - {$currency.prefix}{$qmonthprice}{$currency.suffix} {$LANG.permonth}</option>{/if}

 

{if $pricing.semiannually}<option value="semiannually"{if $billingcycle eq "semiannually"} selected="selected"{/if}>{$LANG.billingcyclesemi} {$currency.prefix}{$pricing.rawpricing.semiannually}{$currency.suffix} {if $pricing.rawpricing.ssetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.ssetupfee}{$currency.suffix} {$LANG.ordersetupfee}{/if} {if $ssaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$ssaving}{$currency.suffix}){/if} - {$currency.prefix}{$smonthprice}{$currency.suffix} {$LANG.permonth}</option>{/if}

 

{if $pricing.annually}<option value="annually"{if $billingcycle eq "annually"} selected="selected"{/if}>{$LANG.billingcycleannual} {$currency.prefix}{$pricing.rawpricing.annually}{$currency.suffix} {if $pricing.rawpricing.asetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.asetupfee}{$currency.suffix} {$LANG.ordersetupfee}{/if} {if $asaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$asaving}{$currency.suffix}){/if} - {$currency.prefix}{$amonthprice}{$currency.suffix} {$LANG.permonth}</option>{/if}

 

{if $pricing.biennially}<option value="biennially"{if $billingcycle eq "biennially"} selected="selected"{/if}>{$LANG.billingcyclebienn} {$currency.prefix}{$pricing.rawpricing.biennially}{$currency.suffix} {if $pricing.rawpricing.bsetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.bsetupfee}{$currency.suffix} {$LANG.ordersetupfee}{/if} {if $bsaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$bsaving}{$currency.suffix}){/if} - {$currency.prefix}{$bmonthprice}{$currency.suffix} {$LANG.permonth}</option>{/if}

 

{if $pricing.triennially}<option value="triennially"{if $billingcycle eq "triennially"} selected="selected"{/if}>{$LANG.billingcycletrienn} {$currency.prefix}{$pricing.rawpricing.triennially}{$currency.suffix} {if $pricing.rawpricing.tsetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.tsetupfee}{$currency.suffix} {$LANG.ordersetupfee}{/if} {if $tsaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$tsaving}{$currency.suffix}){/if} - {$currency.prefix}{$tmonthprice}{$currency.suffix} {$LANG.permonth}</option>{/if}

 

{else}

 

{if $pricing.monthly}<option value="monthly"{if $billingcycle eq "monthly"} selected="selected"{/if}>{$pricing.monthly} tom!</option>{/if}

{if $pricing.quarterly}<option value="quarterly"{if $billingcycle eq "quarterly"} selected="selected"{/if}>{$pricing.quarterly}</option>{/if}

{if $pricing.semiannually}<option value="semiannually"{if $billingcycle eq "semiannually"} selected="selected"{/if}>{$pricing.semiannually}</option>{/if}

{if $pricing.annually}<option value="annually"{if $billingcycle eq "annually"} selected="selected"{/if}>{$pricing.annually}</option>{/if}

{if $pricing.biennially}<option value="biennially"{if $billingcycle eq "biennially"} selected="selected"{/if}>{$pricing.biennially}</option>{/if}

{if $pricing.triennially}<option value="triennially"{if $billingcycle eq "triennially"} selected="selected"{/if}>{$pricing.triennially}</option>{/if}

 

{/if}

 

If you wanted to select product groups and individual products to use the same display method, then you could use...

 

{if $productinfo.pid eq '34' or $productinfo.gid eq '1'}

 

You can add as many products and/or groups you want to the above statement or use multiple {if} statements - just remember to end the block of code with a closing {/if},

 

{if $productinfo.pid eq '34'}

*show custom display*

{elseif $productinfo.gid eq '1' or $productinfo.gid eq '4' }

*show custom display 2*

{else}

*show default display*

{/if}

This advanced solution should hopefully allow you to make the shopping process slightly easier for your customers by enabling you to use more appropriate billing cycle text for each product and/or group.

 

I suspect that I've only scratched the surface of what is possible with this technique... so if anyone turns this into a commercial addon, I'd appreciate a share of the profits, a mention - or at the very least, a small glass of cooking sherry to get me through the day.*

 

* I'd add a smilie at this point, but I'm limited to ten images and can't add one! lol

Link to comment
Share on other sites

  • 2 weeks later...
excellent, but to display the text (free domain) for those products that have set? what would be the variable?

oh.. I never thought about free domains :roll: - but the principle is the same..

 

to show (Free Domain) in the correct language, you would need to add...

 

{if $productinfo.freedomain}
({$LANG.orderfreedomainonly})
{/if}

 

you can add it anywhere inside each cycle's code - the code will be the same for all billing cycles.

 

e.g., if you wanted to add it to the end of each cycle, you would paste the above code after {$LANG.permonth} - but remember to leave a space between them.

 

billingcycle_14_free_domain.png

Link to comment
Share on other sites

Hello brian!, thanks but this no work for me...

 

this code

{if $productinfo.freedomain}

({$LANG.orderfreedomainonly})

{/if}

 

always returns the text free domain...

 

the code:

{$productinfo.freedomain}

 

return the text: monthly,quarterly,semiannually,annually for example

 

i tried this:

 

{if $productinfo.freedomainpaymentterms|@strstr:',monthly'}({$LANG.orderfreedomainonly}){/if}

{if $productinfo.freedomainpaymentterms|@strstr:',annually'}({$LANG.orderfreedomainonly}){/if}

 

but if I have selected only the cycle semiannually the code:

{if $productinfo.freedomainpaymentterms|@strstr:',annually'}({$LANG.orderfreedomainonly}){/if} return true...

 

 

I hope you understand. That way I can resolve this Free domain more stably

 

thansk

Link to comment
Share on other sites

Hi,

 

apologies for this - you are absolutely correct, I only tried it on just one billing cycle, so only saw (free domain) once! :oops:

 

thankfully, the working solution is still simple! instead of using....

 

{if $productinfo.freedomain}
({$LANG.orderfreedomainonly})
{/if}

you will need to use...

 

{if (($productinfo.freedomain) and ($productinfo.freedomainpaymentterms|strstr:'quarterly'))}
({$LANG.orderfreedomainonly})
{/if}

the above code is for quarterly - replace "quarterly" with the correct terms for the other billing cycles.. so for monthly, you would use...

 

{if (($productinfo.freedomain) and ($productinfo.freedomainpaymentterms|strstr:'monthly'))}
({$LANG.orderfreedomainonly})
{/if}

we need to check for both "freedomain" and "freedomainpaymentterms" because if a free domain payment term is selected in your product settings, it will always be true - regardless of whether "freedomain" is set to none, once or recurring - therefore, we must check that "freedomain" exists (i.e once or recurring) and the correct payment term is selected.

 

for annual billing cycles, we need to be a little more specific (because of the clash with semiannually if just using strstr)...

 

{if (($productinfo.freedomain) and (($productinfo.freedomainpaymentterms eq "annually") or ($productinfo.freedomainpaymentterms|strstr:',annually')))}
({$LANG.orderfreedomainonly})
{/if}

this works by checking to see if 'freedomainpaymentterms' either equals "annually" (i.e it's the only free payment term for the product), or it contains ",annually" (i.e there are multiple payment terms, but semiannually wouldn't match this search string).

 

hopefully this solves your issue!

Edited by brian!
Link to comment
Share on other sites

  • 2 months later...

you could add the code below to modern/configureproduct.tpl

 

<div>
<h3>{$LANG.orderpromotioncode}</h3>
{if $promotioncode}{$promotioncode} - {$promotiondescription}<br /><a href="{$smarty.server.PHP_SELF}?a=removepromo">{$LANG.orderdontusepromo}</a>{else}<input type="text" name="promocode" size="20" value="" /> <input type="button" name="validatepromo" onclick="addtocart();" value="{$LANG.orderpromovalidatebutton}" />{/if}
</div>

where you add it will depend on whether you want it directly after the billing cycle text, or anywhere upto the end of the {customfields} block of code.

 

while testing, I added it directly after the recurring cycle code {if} block of code - my test product didn't have any config options or addons, but the above block of code should work after any of the {if} blocks.

Link to comment
Share on other sites

Thanks, is there any way to display billing cycle and coupon at the first stage (where plans are shown using slider)? Second stage - we want only payment options.

 

 

you could add the code below to modern/configureproduct.tpl

 

<div>
<h3>{$LANG.orderpromotioncode}</h3>
{if $promotioncode}{$promotioncode} - {$promotiondescription}<br /><a href="{$smarty.server.PHP_SELF}?a=removepromo">{$LANG.orderdontusepromo}</a>{else}<input type="text" name="promocode" size="20" value="" /> <input type="button" name="validatepromo" onclick="addtocart();" value="{$LANG.orderpromovalidatebutton}" />{/if}
</div>

where you add it will depend on whether you want it directly after the billing cycle text, or anywhere upto the end of the {customfields} block of code.

 

while testing, I added it directly after the recurring cycle code {if} block of code - my test product didn't have any config options or addons, but the above block of code should work after any of the {if} blocks.

Link to comment
Share on other sites

  • 4 weeks later...
  • 4 months later...

{if (($productinfo.freedomain) and (($productinfo.freedomainpaymentterms eq "annually") or ($productinfo.freedomainpaymentterms|strstr:',annually')))}

({$LANG.orderfreedomainonly})

{/if}

 

Above won't work annually,biennially,triennially needed to define as follows

 

{if (($productinfo.freedomain) and (($productinfo.freedomainpaymentterms|strpos:'annually'===0) or ($productinfo.freedomainpaymentterms eq 'annually') or ($productinfo.freedomainpaymentterms|strstr:',annually')))}({$LANG.orderfreedomainonly}){/if}

Link to comment
Share on other sites

  • 8 months later...

i am trying to do so the same as Ambarella but unable to do so as i am new to php and whmcs.

I am using modern orderform tempate. I have figured out where to add variable but don't know where to add the php code?

Please help me step by step procedure so it can be completed. thanks for your support

Link to comment
Share on other sites

to do this for v6, the steps are roughly the same - but the template code is slightly different..

 

Step 1: The "Language Overrides" section is exactly the same - follow the previous instructions.

 

Step 2: The "Calculations & Variables" is also the same (it could be slightly updated for Smarty v3, but the previous code works fine)... copy & paste it into /templates/orderforms/modern./configureproduct.tpl *before* the following line...

 

{if $pricing.type eq "recurring"}

 

Step 3: The "Template Modifications" will be different, so in configureproduct.tpl, replace the following...

 

<table width="100%" cellspacing="0" cellpadding="0" class="configtable">
{if $pricing.monthly}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle1" value="monthly"{if $billingcycle eq "monthly"} checked{/if} onclick="{if $configurableoptions}updateConfigurableOptions({$i}, this.value){else}recalctotals(){/if}" /></td><td class="fieldarea"><label for="cycle1" class="radio-inline">{$pricing.monthly}</label></td></tr>{/if}
{if $pricing.quarterly}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle2" value="quarterly"{if $billingcycle eq "quarterly"} checked{/if} onclick="{if $configurableoptions}updateConfigurableOptions({$i}, this.value){else}recalctotals(){/if}" /></td><td class="fieldarea"><label for="cycle2" class="radio-inline">{$pricing.quarterly}</label></td></tr>{/if}
{if $pricing.semiannually}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle3" value="semiannually"{if $billingcycle eq "semiannually"} checked{/if} onclick="{if $configurableoptions}updateConfigurableOptions({$i}, this.value){else}recalctotals(){/if}" /></td><td class="fieldarea"><label for="cycle3" class="radio-inline">{$pricing.semiannually}</label></td></tr>{/if}
{if $pricing.annually}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle4" value="annually"{if $billingcycle eq "annually"} checked{/if} onclick="{if $configurableoptions}updateConfigurableOptions({$i}, this.value){else}recalctotals(){/if}" /></td><td class="fieldarea"><label for="cycle4" class="radio-inline">{$pricing.annually}</label></td></tr>{/if}
{if $pricing.biennially}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle5" value="biennially"{if $billingcycle eq "biennially"} checked{/if} onclick="{if $configurableoptions}updateConfigurableOptions({$i}, this.value){else}recalctotals()"{/if} /></td><td class="fieldarea"><label for="cycle5" class="radio-inline">{$pricing.biennially}</label></td></tr>{/if}
{if $pricing.triennially}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle6" value="triennially"{if $billingcycle eq "triennially"} checked{/if} onclick="{if $configurableoptions}updateConfigurableOptions({$i}, this.value){else}recalctotals()"{/if} /></td><td class="fieldarea"><label for="cycle6" class="radio-inline">{$pricing.triennially}</label></td></tr>{/if}
</table>

with...

<table width="100%" cellspacing="0" cellpadding="0" class="configtable">
{if $pricing.monthly}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle1" value="monthly"{if $billingcycle eq "monthly"} checked{/if} onclick="{if $configurableoptions}updateConfigurableOptions({$i}, this.value){else}recalctotals(){/if}" /></td><td class="fieldarea"><label for="cycle1" class="radio-inline">{$LANG.billingcyclemonth} {$currency.prefix}{$pricing.rawpricing.monthly}{$currency.suffix}{if $pricing.rawpricing.msetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.msetupfee}{$currency.suffix} {$LANG.ordersetupfee}{/if} {if (($productinfo.freedomain) and ($productinfo.freedomainpaymentterms|strstr:'monthly'))}({$LANG.orderfreedomainonly}){/if}</label></td></tr>{/if}
{if $pricing.quarterly}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle2" value="quarterly"{if $billingcycle eq "quarterly"} checked{/if} onclick="{if $configurableoptions}updateConfigurableOptions({$i}, this.value){else}recalctotals(){/if}" /></td><td class="fieldarea"><label for="cycle2" class="radio-inline">{$LANG.billingcyclequart} {$currency.prefix}{$pricing.rawpricing.quarterly}{$currency.suffix} {if $pricing.rawpricing.qsetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.qsetupfee}{$currency.suffix} {$LANG.ordersetupfee}{/if} {if $qsaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$qsaving}{$currency.suffix}){/if} - {$currency.prefix}{$qmonthprice}{$currency.suffix} {$LANG.permonth} {if (($productinfo.freedomain) and ($productinfo.freedomainpaymentterms|strstr:'quarterly'))}({$LANG.orderfreedomainonly}){/if}</label></td></tr>{/if}
{if $pricing.semiannually}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle3" value="semiannually"{if $billingcycle eq "semiannually"} checked{/if} onclick="{if $configurableoptions}updateConfigurableOptions({$i}, this.value){else}recalctotals(){/if}" /></td><td class="fieldarea"><label for="cycle3" class="radio-inline">{$LANG.billingcyclesemi} {$currency.prefix}{$pricing.rawpricing.semiannually}{$currency.suffix} {if $pricing.rawpricing.ssetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.ssetupfee}{$currency.suffix} {$LANG.ordersetupfee}{/if} {if $ssaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$ssaving}{$currency.suffix}){/if} - {$currency.prefix}{$smonthprice}{$currency.suffix} {$LANG.permonth} {if (($productinfo.freedomain) and ($productinfo.freedomainpaymentterms|strstr:'semiannually'))}({$LANG.orderfreedomainonly}){/if}</label></td></tr>{/if}
{if $pricing.annually}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle4" value="annually"{if $billingcycle eq "annually"} checked{/if} onclick="{if $configurableoptions}updateConfigurableOptions({$i}, this.value){else}recalctotals(){/if}" /></td><td class="fieldarea"><label for="cycle4" class="radio-inline">{$LANG.billingcycleannual} {$currency.prefix}{$pricing.rawpricing.annually}{$currency.suffix} {if $pricing.rawpricing.asetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.asetupfee}{$currency.suffix} {$LANG.ordersetupfee}{/if} {if $asaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$asaving}{$currency.suffix}){/if} - {$currency.prefix}{$amonthprice}{$currency.suffix} {$LANG.permonth} {if (($productinfo.freedomain) and (($productinfo.freedomainpaymentterms|strpos:'annually'===0) or ($productinfo.freedomainpaymentterms eq 'annually') or ($productinfo.freedomainpaymentterms|strstr:',annually')))}({$LANG.orderfreedomainonly}){/if}</label></td></tr>{/if}
{if $pricing.biennially}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle5" value="biennially"{if $billingcycle eq "biennially"} checked{/if} onclick="{if $configurableoptions}updateConfigurableOptions({$i}, this.value){else}recalctotals()"{/if} /></td><td class="fieldarea"><label for="cycle5" class="radio-inline">{$LANG.billingcyclebienn} {$currency.prefix}{$pricing.rawpricing.biennially} {$currency.suffix} {if $pricing.rawpricing.bsetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.bsetupfee}{$currency.suffix} {$LANG.ordersetupfee}{/if} {if $bsaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$bsaving}{$currency.suffix}){/if} - {$currency.prefix}{$bmonthprice}{$currency.suffix} {$LANG.permonth} {if (($productinfo.freedomain) and ($productinfo.freedomainpaymentterms|strstr:'biennially'))}({$LANG.orderfreedomainonly}){/if}</label></td></tr>{/if}
{if $pricing.triennially}<tr><td class="radiofield"><input type="radio" name="billingcycle" id="cycle6" value="triennially"{if $billingcycle eq "triennially"} checked{/if} onclick="{if $configurableoptions}updateConfigurableOptions({$i}, this.value){else}recalctotals()"{/if} /></td><td class="fieldarea"><label for="cycle6" class="radio-inline">{$LANG.billingcycletrienn} {$currency.prefix}{$pricing.rawpricing.triennially }{$currency.suffix} {if $pricing.rawpricing.tsetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.tsetupfee}{$currency.suffix} {$LANG.ordersetupfee}{/if} {if $tsaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$tsaving}{$currency.suffix}){/if} - {$currency.prefix}{$tmonthprice}{$currency.suffix} {$LANG.permonth} {if (($productinfo.freedomain) and ($productinfo.freedomainpaymentterms|strstr:'triennially'))}({$LANG.orderfreedomainonly}){/if}</label></td></tr>{/if}
</table>

if you do that, then you should see your recurring billing cycles look similar to...

 

Screenshot_21.png

 

obviously, the prices, language and currencies will be determined by your settings.

Link to comment
Share on other sites

  • 4 months later...

for v6.2, you would need to modify the modern/configureproduct.tpl and change....

 

{if $pricing.type eq "recurring"}
<h3>{$LANG.cartchoosecycle}</h3>
<div class="billingcycle">
<table width="100%" cellspacing="0" cellpadding="0" class="configtable">
   {if $pricing.monthly}
       <tr>
           <td class="radiofield">
               <input type="radio" name="billingcycle" id="cycle1" value="monthly"{if $billingcycle eq "monthly"} checked{/if} onclick="{if $configurableoptions}updateConfigurableOptions({$i}, this.value){else}recalctotals(){/if}" />
           </td>
           <td class="fieldarea">
               <label for="cycle1" class="radio-inline">{$pricing.monthly}</label>
           </td>
       </tr>
   {/if}
   {if $pricing.quarterly}
       <tr>
           <td class="radiofield">
               <input type="radio" name="billingcycle" id="cycle2" value="quarterly"{if $billingcycle eq "quarterly"} checked{/if} onclick="{if $configurableoptions}updateConfigurableOptions({$i}, this.value){else}recalctotals(){/if}" />
           </td>
           <td class="fieldarea">
               <label for="cycle2" class="radio-inline">{$pricing.quarterly}</label>
           </td>
       </tr>
   {/if}
   {if $pricing.semiannually}
       <tr>
           <td class="radiofield">
               <input type="radio" name="billingcycle" id="cycle3" value="semiannually"{if $billingcycle eq "semiannually"} checked{/if} onclick="{if $configurableoptions}updateConfigurableOptions({$i}, this.value){else}recalctotals(){/if}" />
           </td>
           <td class="fieldarea">
               <label for="cycle3" class="radio-inline">{$pricing.semiannually}</label>
           </td>
       </tr>
   {/if}
   {if $pricing.annually}
       <tr>
           <td class="radiofield">
               <input type="radio" name="billingcycle" id="cycle4" value="annually"{if $billingcycle eq "annually"} checked{/if} onclick="{if $configurableoptions}updateConfigurableOptions({$i}, this.value){else}recalctotals(){/if}" />
           </td>
           <td class="fieldarea">
               <label for="cycle4" class="radio-inline">{$pricing.annually}</label>
           </td>
       </tr>
   {/if}
   {if $pricing.biennially}
       <tr>
           <td class="radiofield">
               <input type="radio" name="billingcycle" id="cycle5" value="biennially"{if $billingcycle eq "biennially"} checked{/if} onclick="{if $configurableoptions}updateConfigurableOptions({$i}, this.value){else}recalctotals(){/if}" />
           </td>
           <td class="fieldarea">
               <label for="cycle5" class="radio-inline">{$pricing.biennially}</label>
           </td>
       </tr>
   {/if}
   {if $pricing.triennially}
       <tr>
           <td class="radiofield">
               <input type="radio" name="billingcycle" id="cycle6" value="triennially"{if $billingcycle eq "triennially"} checked{/if} onclick="{if $configurableoptions}updateConfigurableOptions({$i}, this.value){else}recalctotals(){/if}" />
           </td>
           <td class="fieldarea">
               <label for="cycle6" class="radio-inline">{$pricing.triennially}</label>
           </td>
       </tr>
   {/if}
</table>
</div>
{/if}

to...

 

{if $pricing.type eq "recurring"}
<h3>{$LANG.cartchoosecycle}</h3>
<div class="billingcycle">
<table width="100%" cellspacing="0" cellpadding="0" class="configtable">
   {if $pricing.monthly}
       <tr>
           <td class="radiofield">
               <input type="radio" name="billingcycle" id="cycle1" value="monthly"{if $billingcycle eq "monthly"} checked{/if} onclick="{if $configurableoptions}updateConfigurableOptions({$i}, this.value){else}recalctotals(){/if}" />
           </td>
           <td class="fieldarea">
               <label for="cycle1" class="radio-inline">{$LANG.billingcyclemonth} {$currency.prefix}{$pricing.rawpricing.monthly}{$currency.suffix}{if $pricing.rawpricing.msetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.msetupfee}{$currency.suffix} {$LANG.ordersetupfee}{/if} {if (($productinfo.freedomain) and ($productinfo.freedomainpaymentterms|strstr:$billingcycle))}({$LANG.orderfreedomainonly}){/if}</label>
           </td>
       </tr>
   {/if}
   {if $pricing.quarterly}
       <tr>
           <td class="radiofield">
               <input type="radio" name="billingcycle" id="cycle2" value="quarterly"{if $billingcycle eq "quarterly"} checked{/if} onclick="{if $configurableoptions}updateConfigurableOptions({$i}, this.value){else}recalctotals(){/if}" />
           </td>
           <td class="fieldarea">
               <label for="cycle2" class="radio-inline">{$LANG.billingcyclequart} {$currency.prefix}{$pricing.rawpricing.quarterly}{$currency.suffix} {if $pricing.rawpricing.qsetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.qsetupfee}{ $currency.suffix} {$LANG.ordersetupfee}{/if} {if $qsaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$qsaving}{$currency.suffix}){/if} - {$currency.prefix}{$qmonthprice}{$currency.suffix} {$LANG.permonth} {if (($productinfo.freedomain) and ($productinfo.freedomainpaymentterms|strstr:$billingcycle))}({$LANG.orderfreedomainonly}){/if}</label>
           </td>
       </tr>
   {/if}
   {if $pricing.semiannually}
       <tr>
           <td class="radiofield">
               <input type="radio" name="billingcycle" id="cycle3" value="semiannually"{if $billingcycle eq "semiannually"} checked{/if} onclick="{if $configurableoptions}updateConfigurableOptions({$i}, this.value){else}recalctotals(){/if}" />
           </td>
           <td class="fieldarea">
               <label for="cycle3" class="radio-inline">{$LANG.billingcyclesemi} {$currency.prefix}{$pricing.rawpricing.semiannually}{$currency.suffix} {if $pricing.rawpricing.ssetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.ssetupfee}{ $currency.suffix} {$LANG.ordersetupfee}{/if} {if $ssaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$ssaving}{$currency.suffix}){/if} - {$currency.prefix}{$smonthprice}{$currency.suffix} {$LANG.permonth} {if (($productinfo.freedomain) and ($productinfo.freedomainpaymentterms|strstr:$billingcycle))}({$LANG.orderfreedomainonly}){/if}</label>
           </td>
       </tr>
   {/if}
   {if $pricing.annually}
       <tr>
           <td class="radiofield">
               <input type="radio" name="billingcycle" id="cycle4" value="annually"{if $billingcycle eq "annually"} checked{/if} onclick="{if $configurableoptions}updateConfigurableOptions({$i}, this.value){else}recalctotals(){/if}" />
           </td>
           <td class="fieldarea">
               <label for="cycle4" class="radio-inline">{$LANG.billingcycleannual} {$currency.prefix}{$pricing.rawpricing.annually}{$currency.suffix} {if $pricing.rawpricing.asetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.asetupfee}{ $currency.suffix} {$LANG.ordersetupfee}{/if} {if $asaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$asaving}{$currency.suffix}){/if} - {$currency.prefix}{$amonthprice}{$currency.suffix} {$LANG.permonth} {if (($productinfo.freedomain) and (($productinfo.freedomainpaymentterms|strpos:$billingcycle===0) or ($productinfo.freedomainpaymentterms eq $billingcycle) or ($productinfo.freedomainpaymentterms|strstr:',annually')))}({$LANG.orderfreedomainonly}){/if}</label>
           </td>
       </tr>
   {/if}
   {if $pricing.biennially}
       <tr>
           <td class="radiofield">
               <input type="radio" name="billingcycle" id="cycle5" value="biennially"{if $billingcycle eq "biennially"} checked{/if} onclick="{if $configurableoptions}updateConfigurableOptions({$i}, this.value){else}recalctotals(){/if}" />
           </td>
           <td class="fieldarea">
               <label for="cycle5" class="radio-inline">{$LANG.billingcyclebienn} {$currency.prefix}{$pricing.rawpricing.biennially} {$currency.suffix} {if $pricing.rawpricing.bsetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.bsetupfee}{ $currency.suffix} {$LANG.ordersetupfee}{/if} {if $bsaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$bsaving}{$currency.suffix}){/if} - {$currency.prefix}{$bmonthprice}{$currency.suffix} {$LANG.permonth} {if (($productinfo.freedomain) and (($productinfo.freedomainpaymentterms|strpos:$billingcycle===0) or ($productinfo.freedomainpaymentterms eq $billingcycle) or ($productinfo.freedomainpaymentterms|strstr:',biennially')))}({$LANG.orderfreedomainonly}){/if}</label>
           </td>
       </tr>
   {/if}
   {if $pricing.triennially}
       <tr>
           <td class="radiofield">
               <input type="radio" name="billingcycle" id="cycle6" value="triennially"{if $billingcycle eq "triennially"} checked{/if} onclick="{if $configurableoptions}updateConfigurableOptions({$i}, this.value){else}recalctotals(){/if}" />
           </td>
           <td class="fieldarea">
               <label for="cycle6" class="radio-inline">{$LANG.billingcycletrienn} {$currency.prefix}{$pricing.rawpricing.triennially}{$currency.suffix} {if $pricing.rawpricing.tsetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.tsetupfee}{ $currency.suffix} {$LANG.ordersetupfee}{/if} {if $tsaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$tsaving}{$currency.suffix}){/if} - {$currency.prefix}{$tmonthprice}{$currency.suffix} {$LANG.permonth} {if (($productinfo.freedomain) and (($productinfo.freedomainpaymentterms|strpos:$billingcycle===0) or ($productinfo.freedomainpaymentterms eq $billingcycle) or ($productinfo.freedomainpaymentterms|strstr:',triennially')))}({$LANG.orderfreedomainonly}){/if}</label>
           </td>
       </tr>
   {/if}
</table>
</div>
{/if}

 

for those wanting to do this with Standard Cart (and the other new slider and comparison templates), you can replace the following code in standard_cart/configure.tpl...

 

                        {if $pricing.type eq "recurring"}
                           <div class="field-container">
                               <div class="form-group">
                                   <label for="inputBillingcycle">{$LANG.cartchoosecycle}</label>
                                   <select name="billingcycle" id="inputBillingcycle" class="form-control select-inline" onchange="{if $configurableoptions}updateConfigurableOptions({$i}, this.value);{else}recalctotals();{/if}">
                                       {if $pricing.monthly}
                                           <option value="monthly"{if $billingcycle eq "monthly"} selected{/if}>
                                               {$pricing.monthly}
                                           </option>
                                       {/if}
                                       {if $pricing.quarterly}
                                           <option value="quarterly"{if $billingcycle eq "quarterly"} selected{/if}>
                                               {$pricing.quarterly}
                                           </option>
                                       {/if}
                                       {if $pricing.semiannually}
                                           <option value="semiannually"{if $billingcycle eq "semiannually"} selected{/if}>
                                               {$pricing.semiannually}
                                           </option>
                                       {/if}
                                       {if $pricing.annually}
                                           <option value="annually"{if $billingcycle eq "annually"} selected{/if}>
                                               {$pricing.annually}
                                           </option>
                                       {/if}
                                       {if $pricing.biennially}
                                           <option value="biennially"{if $billingcycle eq "biennially"} selected{/if}>
                                               {$pricing.biennially}
                                           </option>
                                       {/if}
                                       {if $pricing.triennially}
                                           <option value="triennially"{if $billingcycle eq "triennially"} selected{/if}>
                                               {$pricing.triennially}
                                           </option>
                                       {/if}
                                   </select>
                               </div>
                           </div>
                       {/if}

with...

 

                        {if $pricing.type eq "recurring"}
                           <div class="field-container">
                               <div class="form-group">
                                   <label for="inputBillingcycle">{$LANG.cartchoosecycle}</label>
                                   <select name="billingcycle" id="inputBillingcycle" class="form-control select-inline" onchange="{if $configurableoptions}updateConfigurableOptions({$i}, this.value);{else}recalctotals();{/if}">
                                       {if $pricing.monthly}
                                           <option value="monthly"{if $billingcycle eq "monthly"} selected{/if}>
                                               {$LANG.billingcyclemonth} {$currency.prefix}{$pricing.rawpricing.monthly}{$currency.suffix}{if $pricing.rawpricing.msetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.msetupfee}{$currency.suffix} {$LANG.ordersetupfee}{/if} {if (($productinfo.freedomain) and ($productinfo.freedomainpaymentterms|strstr:$billingcycle))}({$LANG.orderfreedomainonly}){/if}
                                           </option>
                                       {/if}
                                       {if $pricing.quarterly}
                                           <option value="quarterly"{if $billingcycle eq "quarterly"} selected{/if}>
                                               {$LANG.billingcyclequart} {$currency.prefix}{$pricing.rawpricing.quarterly}{$currency.suffix} {if $pricing.rawpricing.qsetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.qsetupfee}{ $currency.suffix} {$LANG.ordersetupfee}{/if} {if $qsaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$qsaving}{$currency.suffix}){/if} - {$currency.prefix}{$qmonthprice}{$currency.suffix} {$LANG.permonth} {if (($productinfo.freedomain) and ($productinfo.freedomainpaymentterms|strstr:$billingcycle))}({$LANG.orderfreedomainonly}){/if}
                                           </option>
                                       {/if}
                                       {if $pricing.semiannually}
                                           <option value="semiannually"{if $billingcycle eq "semiannually"} selected{/if}>
                                               {$LANG.billingcyclesemi} {$currency.prefix}{$pricing.rawpricing.semiannually}{$currency.suffix} {if $pricing.rawpricing.ssetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.ssetupfee}{ $currency.suffix} {$LANG.ordersetupfee}{/if} {if $ssaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$ssaving}{$currency.suffix}){/if} - {$currency.prefix}{$smonthprice}{$currency.suffix} {$LANG.permonth} {if (($productinfo.freedomain) and ($productinfo.freedomainpaymentterms|strstr:$billingcycle))}({$LANG.orderfreedomainonly}){/if}
                                           </option>
                                       {/if}
                                       {if $pricing.annually}
                                           <option value="annually"{if $billingcycle eq "annually"} selected{/if}>
                                               {$LANG.billingcycleannual} {$currency.prefix}{$pricing.rawpricing.annually}{$currency.suffix} {if $pricing.rawpricing.asetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.asetupfee}{ $currency.suffix} {$LANG.ordersetupfee}{/if} {if $asaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$asaving}{$currency.suffix}){/if} - {$currency.prefix}{$amonthprice}{$currency.suffix} {$LANG.permonth} {if (($productinfo.freedomain) and (($productinfo.freedomainpaymentterms|strpos:$billingcycle===0) or ($productinfo.freedomainpaymentterms eq $billingcycle) or ($productinfo.freedomainpaymentterms|strstr:',annually')))}({$LANG.orderfreedomainonly}){/if}
                                           </option>
                                       {/if}
                                       {if $pricing.biennially}
                                           <option value="biennially"{if $billingcycle eq "biennially"} selected{/if}>
                                               {$LANG.billingcyclebienn} {$currency.prefix}{$pricing.rawpricing.biennially} {$currency.suffix} {if $pricing.rawpricing.bsetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.bsetupfee}{ $currency.suffix} {$LANG.ordersetupfee}{/if} {if $bsaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$bsaving}{$currency.suffix}){/if} - {$currency.prefix}{$bmonthprice}{$currency.suffix} {$LANG.permonth} {if (($productinfo.freedomain) and (($productinfo.freedomainpaymentterms|strpos:$billingcycle===0) or ($productinfo.freedomainpaymentterms eq $billingcycle) or ($productinfo.freedomainpaymentterms|strstr:',biennially')))}({$LANG.orderfreedomainonly}){/if}
                                           </option>
                                       {/if}
                                       {if $pricing.triennially}
                                           <option value="triennially"{if $billingcycle eq "triennially"} selected{/if}>
                                               {$LANG.billingcycletrienn} {$currency.prefix}{$pricing.rawpricing.triennially}{$currency.suffix} {if $pricing.rawpricing.tsetupfee neq 0} + {$currency.prefix}{$pricing.rawpricing.tsetupfee}{ $currency.suffix} {$LANG.ordersetupfee}{/if} {if $tsaving gt 0}({$LANG.cyclesaving} {$currency.prefix}{$tsaving}{$currency.suffix}){/if} - {$currency.prefix}{$tmonthprice}{$currency.suffix} {$LANG.permonth} {if (($productinfo.freedomain) and (($productinfo.freedomainpaymentterms|strpos:$billingcycle===0) or ($productinfo.freedomainpaymentterms eq $billingcycle) or ($productinfo.freedomainpaymentterms|strstr:',triennially')))}({$LANG.orderfreedomainonly}){/if}
                                           </option>
                                       {/if}
                                   </select>
                               </div>
                           </div>
                       {/if}

Link to comment
Share on other sites

Its same result with no saving amount.

I think the problem is you have "Monthly Pricing Breakdown" enabled in your settings. :)

 

setup -> general settings -> ordering -> Monthly Pricing Breakdown

 

the quick fix would be to untick the above checkbox - then the savings should appear. :idea:

 

alternatively, you can tweak the Smarty maths code and change...

 

{* Calculate the cycle savings *}                
{if $pricing.minprice.cycle eq "monthly"}
{assign var="qsaving" value=0}
{math assign="qsaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.monthly b=3 c=$pricing.rawpricing.msetupfee d=$pricing.rawpricing.quarterly e=$pricing.rawpricing.qsetupfee format="%.2f"}
{assign var="ssaving" value=0}
{math assign="ssaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.monthly b=6 c=$pricing.rawpricing.msetupfee d=$pricing.rawpricing.semiannually e=$pricing.rawpricing.ssetupfee format="%.2f"}
{assign var="asaving" value=0}
{math assign="asaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.monthly b=12 c=$pricing.rawpricing.msetupfee d=$pricing.rawpricing.annually e=$pricing.rawpricing.asetupfee format="%.2f"}
{assign var="bsaving" value=0}
{math assign="bsaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.monthly b=24 c=$pricing.rawpricing.msetupfee d=$pricing.rawpricing.biennially e=$pricing.rawpricing.bsetupfee format="%.2f"}
{assign var="tsaving" value=0}
{math assign="tsaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.monthly b=36 c=$pricing.rawpricing.msetupfee d=$pricing.rawpricing.triennially e=$pricing.rawpricing.tsetupfee format="%.2f"}
{elseif $pricing.minprice.cycle eq "quarterly"}
{assign var="ssaving" value=0}
{math assign="ssaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.quarterly b=2 c=$pricing.rawpricing.qsetupfee d=$pricing.rawpricing.semiannually e=$pricing.rawpricing.ssetupfee format="%.2f"}
{assign var="asaving" value=0}
{math assign="asaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.quarterly b=4 c=$pricing.rawpricing.qsetupfee d=$pricing.rawpricing.annually e=$pricing.rawpricing.asetupfee format="%.2f"}
{assign var="bsaving" value=0}
{math assign="bsaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.quarterly b=8 c=$pricing.rawpricing.qsetupfee d=$pricing.rawpricing.biennially e=$pricing.rawpricing.bsetupfee format="%.2f"}
{assign var="tsaving" value=0}
{math assign="tsaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.quarterly b=12 c=$pricing.rawpricing.qsetupfee d=$pricing.rawpricing.triennially e=$pricing.rawpricing.tsetupfee format="%.2f"}
{elseif $pricing.minprice.cycle eq "semiannually"}
{assign var="asaving" value=0}
{math assign="asaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.semiannually b=2 c=$pricing.rawpricing.ssetupfee d=$pricing.rawpricing.annually e=$pricing.rawpricing.asetupfee format="%.2f"}
{assign var="bsaving" value=0}
{math assign="bsaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.semiannually b=4 c=$pricing.rawpricing.ssetupfee d=$pricing.rawpricing.biennially e=$pricing.rawpricing.bsetupfee format="%.2f"}
{assign var="tsaving" value=0}
{math assign="tsaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.semiannually b=8 c=$pricing.rawpricing.ssetupfee d=$pricing.rawpricing.triennially e=$pricing.rawpricing.tsetupfee format="%.2f"}
{elseif $pricing.minprice.cycle eq "annually"}
{assign var="bsaving" value=0}
{math assign="bsaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.annually b=2 c=$pricing.rawpricing.asetupfee d=$pricing.rawpricing.biennially e=$pricing.rawpricing.bsetupfee format="%.2f"}
{assign var="tsaving" value=0}
{math assign="tsaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.annually b=3 c=$pricing.rawpricing.asetupfee d=$pricing.rawpricing.triennially e=$pricing.rawpricing.tsetupfee format="%.2f"}
{elseif $pricing.minprice.cycle eq "biennially"}
{assign var="tsaving" value=0}
{math assign="tsaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.biennially b=1.5 c=$pricing.rawpricing.bsetupfee d=$pricing.rawpricing.triennially e=$pricing.rawpricing.tsetupfee format="%.2f"}
{/if}  

to...

 

{* Calculate the cycle savings *}                
{if (($pricing.minprice.cycle eq "monthly") or ($pricing.minprice.cycle eq "1month"))}
{assign var="qsaving" value=0}
{math assign="qsaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.monthly b=3 c=$pricing.rawpricing.msetupfee d=$pricing.rawpricing.quarterly e=$pricing.rawpricing.qsetupfee format="%.2f"}
{assign var="ssaving" value=0}
{math assign="ssaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.monthly b=6 c=$pricing.rawpricing.msetupfee d=$pricing.rawpricing.semiannually e=$pricing.rawpricing.ssetupfee format="%.2f"}
{assign var="asaving" value=0}
{math assign="asaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.monthly b=12 c=$pricing.rawpricing.msetupfee d=$pricing.rawpricing.annually e=$pricing.rawpricing.asetupfee format="%.2f"}
{assign var="bsaving" value=0}
{math assign="bsaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.monthly b=24 c=$pricing.rawpricing.msetupfee d=$pricing.rawpricing.biennially e=$pricing.rawpricing.bsetupfee format="%.2f"}
{assign var="tsaving" value=0}
{math assign="tsaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.monthly b=36 c=$pricing.rawpricing.msetupfee d=$pricing.rawpricing.triennially e=$pricing.rawpricing.tsetupfee format="%.2f"}
{elseif (($pricing.minprice.cycle eq "quarterly") or ($pricing.minprice.cycle eq "3month"))}
{assign var="ssaving" value=0}
{math assign="ssaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.quarterly b=2 c=$pricing.rawpricing.qsetupfee d=$pricing.rawpricing.semiannually e=$pricing.rawpricing.ssetupfee format="%.2f"}
{assign var="asaving" value=0}
{math assign="asaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.quarterly b=4 c=$pricing.rawpricing.qsetupfee d=$pricing.rawpricing.annually e=$pricing.rawpricing.asetupfee format="%.2f"}
{assign var="bsaving" value=0}
{math assign="bsaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.quarterly b=8 c=$pricing.rawpricing.qsetupfee d=$pricing.rawpricing.biennially e=$pricing.rawpricing.bsetupfee format="%.2f"}
{assign var="tsaving" value=0}
{math assign="tsaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.quarterly b=12 c=$pricing.rawpricing.qsetupfee d=$pricing.rawpricing.triennially e=$pricing.rawpricing.tsetupfee format="%.2f"}
{elseif (($pricing.minprice.cycle eq "semiannually") or ($pricing.minprice.cycle eq "6month"))}
{assign var="asaving" value=0}
{math assign="asaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.semiannually b=2 c=$pricing.rawpricing.ssetupfee d=$pricing.rawpricing.annually e=$pricing.rawpricing.asetupfee format="%.2f"}
{assign var="bsaving" value=0}
{math assign="bsaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.semiannually b=4 c=$pricing.rawpricing.ssetupfee d=$pricing.rawpricing.biennially e=$pricing.rawpricing.bsetupfee format="%.2f"}
{assign var="tsaving" value=0}
{math assign="tsaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.semiannually b=8 c=$pricing.rawpricing.ssetupfee d=$pricing.rawpricing.triennially e=$pricing.rawpricing.tsetupfee format="%.2f"}
{elseif (($pricing.minprice.cycle eq "annually") or ($pricing.minprice.cycle eq "12month"))}
{assign var="bsaving" value=0}
{math assign="bsaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.annually b=2 c=$pricing.rawpricing.asetupfee d=$pricing.rawpricing.biennially e=$pricing.rawpricing.bsetupfee format="%.2f"}
{assign var="tsaving" value=0}
{math assign="tsaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.annually b=3 c=$pricing.rawpricing.asetupfee d=$pricing.rawpricing.triennially e=$pricing.rawpricing.tsetupfee format="%.2f"}
{elseif (($pricing.minprice.cycle eq "biennially") or ($pricing.minprice.cycle eq "24month"))}
{assign var="tsaving" value=0}
{math assign="tsaving" equation="((a * b) + c) - (d + e)" a=$pricing.rawpricing.biennially b=1.5 c=$pricing.rawpricing.bsetupfee d=$pricing.rawpricing.triennially e=$pricing.rawpricing.tsetupfee format="%.2f"}
{/if}

btw - you have your PM settings so that you can't receive PMs... therefore, I was unable to reply to your private message. :roll:

Link to comment
Share on other sites

hello,

 

i have implemented it and SAVING is not showing. Monthly Pricing Breakdown is disabled. Its showing like this:

Quarterly Cost $16.95 USD - $5.65 USD per/m

Kindly guide where to put the alternative code you given above "your alternatively, you can tweak the Smarty maths code and change..."

Link to comment
Share on other sites

Hi,

 

i have implemented it and SAVING is not showing. Monthly Pricing Breakdown is disabled. Its showing like this:

Quarterly Cost $16.95 USD - $5.65 USD per/m

Kindly guide where to put the alternative code you given above "your alternatively, you can tweak the Smarty maths code and change..."

it assumed you've added the maths code from the first page of this thread - that code comes in two parts, and you change the second part with the above code... the instructions above tells you what code to replace and what to replace it with.

 

you should then have output that should look similar to...

 

GNX6nHZ.png

 

 

to save time for others, i've modified the "Modern" and "Standard_cart" configureproduct.tpl templates from WHMCS v6.20 and will make them available as an attachment below - these should work without a problem... you'll just need to add the language overrides code shown on the first page.

 

i'm not necessarily going to upload an updated release zip after every minor WHMCS update - it should be simple to update manually if required - but if the code starts to fail, i'll post the necessary template changes. :idea:

Modifiy Recurring Cycle Billing v6.20.zip

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.

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