raymonde1323 Posted February 2, 2016 Share Posted February 2, 2016 Hello Everyone. I'm just getting started with whmcs and have gotten the basic setup working good. I am having trouble figuring out how to diplay the product prices the way I want them In my case I have 3 different shared plans with recurring monthly and anual billing options. I am using the "premium comparison" order theme. Problem: The cart shows monthly billing prices for all plans. for each of the 3 plans the anual billing option gives the customer a much cheaper monthly price, but the customer does not see this because the cart is showing the monthly price for the monthly billing option instead. In the cart I want customers too see the monthly price according to the annual billing cycle first before they select a plan and be shown monthly billing cycle price after. Custom coding or theme development would be far over my head. Can someone point out how to solve this in the gui? Have I missed some options or does whmcs not have this feature yet? Any pointers would be great. Thanks 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 3, 2016 Share Posted February 3, 2016 Custom coding or theme development would be far over my head. Can someone point out how to solve this in the gui? it can't be done in the gui - you could enable "Monthly Pricing Breakdown" in setup -> general settings -> ordering and that would show the equivalent monthly price... but the WHMCS templates are coded to show the minimum cycle with a price - that's not necessarily the cheapest price, but the smallest cycle in order (monthly, quarterly, semi etc).. Have I missed some options or does whmcs not have this feature yet? I don't think it's ever had the feature! technically, it wouldn't be difficult for WHMCS to add it so that the cheapest price is shown regardless of cycle - even thinking about it as an action hook or Smarty in the template, it would be quite easy to do... perhaps i'll come back and take a closer look one day. but for your issue, you could do it simply by modifying one line in the premium_comparison/products.tpl template and change ~line 85 {$product.pricing.minprice.cycleText} to... {if $product.pricing.rawpricing.annually neq -1}<span>{$currency.prefix}{($product.pricing.rawpricing.annually/12)|string_format:"%.2f"}{$currency.suffix}</span>/mo{else}{$product.pricing.minprice.cycleText}{/if} so this works by first checking if the annual price is enabled on the product (if it isn't, it will equal -1 and the minimum cycle price will be shown); if it is, then it calculates the equivalent monthly price (e.g annual price divided by 12 and formats it to 2 decimal places), surrounds it in the current currency and displays the result. unfortunately, WHMCS doesn't calculate the equivalent monthly prices for other cycles in a string format that is handy for your purpose - so we'd either have to modify the string it does create, or perform the calculation ourselves - it's probably simpler to do the calculation! btw - the above code doesn't check if the monthly price is less than the monthly price breakdown for annual... it could easily be made to do so, but you already know that your annual prices are cheaper, so it shouldn't be necessary for this. 0 Quote Link to comment Share on other sites More sharing options...
raymonde1323 Posted February 4, 2016 Author Share Posted February 4, 2016 but for your issue, you could do it simply by modifying one line in the premium_comparison/products.tpl template and change ~line 85 {$product.pricing.minprice.cycleText} to... {if $product.pricing.rawpricing.annually neq -1}<span>{$currency.prefix}{($product.pricing.rawpricing.annually/12)|string_format:"%.2f"}{$currency.suffix}</span>/mo{else}{$product.pricing.minprice.cycleText}{/if} Thank you so much for taking the time to answer this post. By the looks of it your code works perfectly and it only took me 5 minutes to do. Much appreciated. :D:D This was exactly what I wanted. 0 Quote Link to comment Share on other sites More sharing options...
theictshak Posted March 5, 2020 Share Posted March 5, 2020 Thank you also. really appreciated this as it pointed me in the right direction. I expanded this a little to suit my needs as below and thought I woudl share. If the product has an annual fee and a monthly fee (annual payment is more cost effective that monthly payment. both are displayed, but if only monthly or only annually then the rel event price is displayed. {if $product.pricing.rawpricing.annually neq -1} <span>{$currency.prefix}{($product.pricing.rawpricing.annually)|string_format:"%.2f"}</span> <br><strong>(Annually)</strong><br>Or <br><strong>{$currency.prefix}{($product.pricing.rawpricing.monthly)|string_format:"%.2f"}(Monthly)</strong> <br> {if product.pricing.minprice.setupFee} <small>{$product.pricing.minprice.setupFee->toPrefixed()} {$LANG.ordersetupfee}</small>{/if} {else} {$product.pricing.minprice.cycleText}{/if} 0 Quote Link to comment Share on other sites More sharing options...
info Posted June 5, 2020 Share Posted June 5, 2020 a Little add on to have it display annual cycle when you click order, and after you select domain... line 95 > 97 after> a=add insert> &billingcycle=annually from: <a href="{$smarty.server.PHP_SELF}?a=add&{if $product.bid}bid={$product.bid}{else}pid={$product.pid}{/if}" class="order-button" id="product{$product@iteration}-order-button"> {$LANG.ordernowbutton} </a> to: <a href="{$smarty.server.PHP_SELF}?a=add&billingcycle=annually&{if $product.bid}bid={$product.bid}{else}pid={$product.pid}{/if}" class="order-button" id="product{$product@iteration}-order-button"> {$LANG.ordernowbutton} </a> 0 Quote Link to comment Share on other sites More sharing options...
bs1 Posted May 17, 2021 Share Posted May 17, 2021 On 3/02/2016 at 9:43 PM, brian! said: it can't be done in the gui - you could enable "Monthly Pricing Breakdown" in setup -> general settings -> ordering and that would show the equivalent monthly price... but the WHMCS templates are coded to show the minimum cycle with a price - that's not necessarily the cheapest price, but the smallest cycle in order (monthly, quarterly, semi etc).. I don't think it's ever had the feature! technically, it wouldn't be difficult for WHMCS to add it so that the cheapest price is shown regardless of cycle - even thinking about it as an action hook or Smarty in the template, it would be quite easy to do... perhaps i'll come back and take a closer look one day. but for your issue, you could do it simply by modifying one line in the premium_comparison/products.tpl template and change ~line 85 {$product.pricing.minprice.cycleText} to... {if $product.pricing.rawpricing.annually neq -1}<span>{$currency.prefix}{($product.pricing.rawpricing.annually/12)|string_format:"%.2f"}{$currency.suffix}</span>/mo{else}{$product.pricing.minprice.cycleText}{/if} so this works by first checking if the annual price is enabled on the product (if it isn't, it will equal -1 and the minimum cycle price will be shown); if it is, then it calculates the equivalent monthly price (e.g annual price divided by 12 and formats it to 2 decimal places), surrounds it in the current currency and displays the result. unfortunately, WHMCS doesn't calculate the equivalent monthly prices for other cycles in a string format that is handy for your purpose - so we'd either have to modify the string it does create, or perform the calculation ourselves - it's probably simpler to do the calculation! btw - the above code doesn't check if the monthly price is less than the monthly price breakdown for annual... it could easily be made to do so, but you already know that your annual prices are cheaper, so it shouldn't be necessary for this. Thanks, this is working good, except its not showing the $currency.prefix and making hard to guess what is the currency, plz advise. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted May 18, 2021 Share Posted May 18, 2021 21 hours ago, bs1 said: Thanks, this is working good, except its not showing the $currency.prefix and making hard to guess what is the currency, plz advise. it is a 5-year old thread! 🙂 {if $product.pricing.rawpricing.annually neq -1}<span>{$activeCurrency.prefix}{($product.pricing.rawpricing.annually/12)|string_format:"%.2f"}{$activeCurrency.suffix}</span>/mo{else}{$product.pricing.minprice.cycleText}{/if} 0 Quote Link to comment Share on other sites More sharing options...
bs1 Posted May 18, 2021 Share Posted May 18, 2021 54 minutes ago, brian! said: it is a 5-year old thread! 🙂 {if $product.pricing.rawpricing.annually neq -1}<span>{$activeCurrency.prefix}{($product.pricing.rawpricing.annually/12)|string_format:"%.2f"}{$activeCurrency.suffix}</span>/mo{else}{$product.pricing.minprice.cycleText}{/if} Thanks much Brian, but this is still seems to be an issue, can you please advise. https://cprod.webhost365.net/index.php?rp=/store/general-hosting-us 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted May 19, 2021 Share Posted May 19, 2021 20 hours ago, bs1 said: Thanks much Brian, but this is still seems to be an issue, can you please advise. https://cprod.webhost365.net/index.php?rp=/store/general-hosting-us which version of WHMCS are you using ? I seem to recall there was an issue with the first v8.0 versions, so hopefully it's not one of them. 0 Quote Link to comment Share on other sites More sharing options...
bs1 Posted May 19, 2021 Share Posted May 19, 2021 2 hours ago, brian! said: which version of WHMCS are you using ? I seem to recall there was an issue with the first v8.0 versions, so hopefully it's not one of them. 8.0.4, is that the issue ? is there some work around ? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted May 31, 2021 Share Posted May 31, 2021 On 19/05/2021 at 17:42, bs1 said: 8.0.4, is that the issue ? is there some work around ? that should give you a $currency array, then you can use $currency.prefix and $currency.suffix as per the original code. 0 Quote Link to comment Share on other sites More sharing options...
MacZil Posted April 13, 2022 Share Posted April 13, 2022 Hi Brian! You're the star around here. Thanks for all your contributions. I was wondering if you had a similar solution but for the "PricingPlan" theme, as I can't locate the same line of code as the one from "Premium Comparison", i.e.: {$product.pricing.minprice.cycleText} Also, I have a monthly, annual, biennial and triennial. The longer the billing cycle the cheaper the monthly rate. I'd love to have the triennial monthly price display by default instead of the monthly rate. I am using WHMCS V8.4.1. Hope you're able to help! 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted May 29, 2022 Share Posted May 29, 2022 On 13/04/2022 at 16:48, MacZil said: You're the star around here. Thanks for all your contributions. a faded star - i've moved on to a happier life no longer thinking about WHMCS. 😎 On 13/04/2022 at 16:48, MacZil said: I was wondering if you had a similar solution but for the "PricingPlan" theme, as I can't locate the same line of code as the one from "Premium Comparison", i.e.: is "PricingPlan" a third-party theme? if so, then contacting it's developer might be useful.. or perhaps add {debug} to the code within the relevant template (I guess it would be products.tpl) and refresh the page - it should generate a popup window of (most) of the available variables... hopefully the variable you want will be in there... and then don't forget to remove {debug} from the template code when you're finished. On 13/04/2022 at 16:48, MacZil said: Also, I have a monthly, annual, biennial and triennial. The longer the billing cycle the cheaper the monthly rate. I'd love to have the triennial monthly price display by default instead of the monthly rate. depending on the theme, this might be a case of editing the template (if the cycle options are shown via multiple IF statements), or reversing the array if it's a loop - I will no doubt have posted solutions previous to both options... perhaps do a search on "triennial" or "triennially" and using my author name as a search option... don't go to far back, i'm pretty sure the reversing the array option would have been posted in 2018-2020... I can remember it was for an Indian poster. if I was familiar with the theme you were mentioning, then I could give a more useful reply. On 13/04/2022 at 16:48, MacZil said: I am using WHMCS V8.4.1. I never got around to installing v8.4 - got the files, just not the inclination, or need, to install it - perhaps when v8.5 goes GA, i'll take a look at that version... or perhaps not. 🙂 0 Quote Link to comment Share on other sites More sharing options...
MacZil Posted May 31, 2022 Share Posted May 31, 2022 Thanks @brian! you're a legend! That helped get me on the track and now it's working 100%. On 5/29/2022 at 1:55 PM, brian! said: a faded star - i've moved on to a happier life no longer thinking about WHMCS. 😎 Happy for you but sad to see you go; you've been a real community treasure here! Wishing you all the best on your new adventure and hope you continue to visit here occasionally. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.