Calc Builder Support

Calc Builder support
No se permite escribir sin estar logado. Por favor, login

Rounding up numbers in the Calculator 24.03.2012 14:26

Hi everyone,

First of all, I would like to thank you for the good product.
I am not an expert in php, so I have been trying to create a simple calculator using your "Business cards" template. I still can not find a way to round up numbers, even tried the solution described in a previous post here.

Here is my code:
//base price



if ($language=='NL') $base=16.00;
if ($type=='E') $base=$base*1.5;
if ($pages>30) $base=$base*0.97;
if ($pages>50) $base=$base*0.93;
if ($pages>100) $base=$base*0.90;


The exit lay-out:

Number of pages ##pages##
Price per unit ##base##
Total price ##var1##

As I said, I took as a base the Business cards template and modified to my needs.
The calculator will have to calculate the price for translation services from one language to another. So, the normal price is 13, if from NL: 16. As you can see on the code, there is also discount depending on the number of pages.
So, I would like to have the 'base' (price per unit) and the '$var1' displayed with 2 numbers after the comma.
I would even go even deeper and put an 'if', so the discount is displayed on a separate row below the number of pages and the price per unit only the cases when a discount applies and then the total. But I suppose it's too far for my php knowledge

Second issue that I experienced is the display of the calculator within an article. It does not include the main menu on the left. I am using the standard Beez5 template from Joomla and I tried everything, but I could not get the menu displayed on the article with the calculator. Strangely enough, I have the same issue with the Xmap.

I do realise that it might not be part of your support tasks to help anyone with the php codes etc., but I would really appreciate if you could help me with the above issues!

Many thanks in advance8

Re: Rounding up numbers in the Calculator 26.03.2012 09:50

yes, support doesn't include php coding, but rounding numbers is a common function, so maybe we can help you with this. You are right when using number_format function, but you have to apply the function to the variable you need to format, just below all math is finished.
So, if you already have your calculations, for your case placed at $var1, you should apply formatting at the end of your code to the same variable:


giving number of decimals and/or, separators. You can also download the example calculator 'rounding numbers' in order to check how it's done using several formatting parameters.

To include conditional results, you can use at your output layout variables instead of fixed text. At the code you can decide if you fill that variables and their content to show. For ex:

##$result1## ##$number1##
##$result2## ##$number2##

And use the code to fill $result2 with a title
$result2='Second result:';
or leave it empty:

About your hidden menu, it's very strange indeed, we have not been reported this issue with any template. If you want us to take a look, please place a helpdesk ticket with your site data, and we'll try to help.

Thank you, best regards
Moonsoft Team

Re: Rounding up numbers in the Calculator 26.03.2012 21:00


Many thanks for your support, it worked perfect!

Re the menu display...The site is still on localhost, I will try to figure it out myself first. Perhaps there is another extension that causes this issue.

Many thanks again!
Are you satisfied with our products/services/support?
Please help us to keep improving, add a review at  joomla extensions site and  magento connect

Lo que nuestros clientes opinan de nosotros