Here are some steps to take if you need to do some basic calculations within your document or other settings in WebMerge.  For example, you have created an order form, but you need to tack on an additional processing fee that is not calculated by your form.

Here are some examples of some basic calculations.  These simply print the result:

  • {($Variable1*$Variable2)|number_format:2}
  • {$Variable1+$Variable2}

If you need to save the values for later, you can use the assign function:

  • {$Variable3 = $Variable1+$Variable2}
  • {$Total = $Subtotal + $Shipping + $Tax}
  • {$Discount = ($Subtotal * 0.25)|number_format:2}
  • {$Percent = (100 * $Wins / $TotalGames)|number_format:2}

For more information on the mathematical calculations you can do within your documents, check out

Have more questions? Submit a request


  • Avatar
    Lee Kolm

    hi Jeremy, After looping through my table to show all the line items, i want to get a total at the bottom. I'm trying this, but i suspect there is a syntax error as i am only getting the last item in the array rather than the total. Help?
    Total Order Amount: {foreach from=$IODetails item=_iodetail}{assign var=SumSales value=$_iodetail.Revenue__c + SumSales }{/foreach} ${$SumSales}

  • Avatar
    Jeremy Clarke

    Hi Lee,

    Try this instead:

    {foreach from=$IODetails item=_iodetail}{$SumSales = $_iodetail.Revenue__c + $SumSales}{/foreach} ${$SumSales}

  • Avatar
    Rajasekhar VK

    Hi Jeremy, I have used auto-numbering to get the value of a variable. I want to capture this value for use later in the document. How do I do it? The field value that I want to capture runs like this:
    A copy of the Certificate of Incorporation is annexed as Annexure A-{$annexure++}.
    I defined it like this: {$A1= Annexure A-{$annexure++}}. But I get a compilation error. Please help..

  • Avatar
    Rajasekhar VK

    This is the error I am getting:
    Error merging document: Syntax Error in template "string:" "{$A1 = " - Unexpected "

  • Avatar
    Jeremy Clarke

    Hi Rajasekhar,

    Simply do this: {$A1 = "Annexure A-"|cat:($annexure + 1)}

    If you need more specific help, please create a support ticket.


  • Avatar
    Rajasekhar VK

    Hi Jeremy

    Thank you for the prompt response. Let me test and get back to you.

    Thanks once again.

Please sign in to leave a comment.
Powered by Zendesk