Adding the Values in Two Separate Fields

2 posts by 2 authors in: Forums > CMS Builder
Last Post: March 10, 2016   (RSS)

By Damon - March 10, 2016

Hi,

You can use PHP to add the two numbers to and then display the total. The code would look like this:

Price 1: <?php echo $record['price_1']; ?><br/>
Price 2: <?php echo $record['price_2']; ?><br/>
Total:   <?php echo ($record['price_1'] + $record['price_2']); ?><br />


Make sure that you set both the price fields in CMS Builder to only allow numbers and decimal in the Allowed Content, otherwise if someone enters a dollar sign, comma or any other character, there will be an error.

An alternative to get the total in a field within CMS Builder would be to get a custom plugin written to add the two fields and save to the third field on save.

Let me know if the code works for you or if you are interested in the plugin option.

Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/