Skip to content
Digital Inspiration DocsDigital Inspiration Docs

Google Forms can collect an order, but it can’t add up the price. Form Notifications can do the arithmetic when it writes the email, so the customer gets a receipt with line totals, delivery and the amount to pay.

The calculation uses scriptlets, which are short tags that you type in the email body. You don’t need a spreadsheet formula or a script.

Maya sells pottery from Willow Lane Studio. Her order form asks for a quantity of each item, how to deliver and an optional discount code.

Question Type Daniel’s answer
Your name Short answer Daniel Okafor
Mugs Dropdown, 0 to 10 4
Bowls Dropdown, 0 to 10 2
Vases Dropdown, 0 to 10 (empty)
Delivery Multiple choice: Pickup, Courier Courier
Discount code Short answer STUDIO10

A mug costs $18, a bowl $24.50 and a vase $40. The courier costs $6, and the code STUDIO10 takes 10% off the items.

  1. Open the add-on in the order form. Click Create and choose Email Notification, or click the name of a notification that you already have.

  2. Type the Email Subject, such as Your order #{{Response Number}} from Willow Lane Studio.

  3. In Email Body, type the calculation first. Each line stores one number under a name:

    {%- assign mugs = {{Mugs}} | times: 18 -%}
    {%- assign bowls = {{Bowls}} | times: 24.5 -%}
    {%- assign vases = {{Vases}} | times: 40 -%}
    {%- assign subtotal = mugs | plus: bowls | plus: vases -%}
  4. Add the discount and the delivery charge. Each if checks one answer:

    {%- if {{Discount code}} == "STUDIO10" -%}
    {%- assign discount = subtotal | times: 0.1 | round: 2 -%}
    {%- else -%}
    {%- assign discount = 0 -%}
    {%- endif -%}
    {%- if {{Delivery}} == "Courier" -%}
    {%- assign shipping = 6 -%}
    {%- else -%}
    {%- assign shipping = 0 -%}
    {%- endif -%}
    {%- assign total = subtotal | minus: discount | plus: shipping | round: 2 -%}
  5. Write the message below the calculation. Print a stored number with {? and ?}:

    Hi {{Your name}},
    Thanks for your order. Here is what we will make for you:
    {% if mugs > 0 %}Mugs: {{Mugs}} x $18 = ${? mugs ?}
    {% endif %}{% if bowls > 0 %}Bowls: {{Bowls}} x $24.50 = ${? bowls ?}
    {% endif %}{% if vases > 0 %}Vases: {{Vases}} x $40 = ${? vases ?}
    {% endif %}
    Subtotal: ${? subtotal ?}
    {% if discount > 0 %}Discount ({{Discount code}}): -${? discount ?}
    {% endif %}Delivery ({{Delivery}}): ${? shipping ?}
    Total to pay: ${? total ?}
  6. Click Next: Recipients and send the email to the respondent. Add your own address in CC Recipients or BCC Recipients to get a copy of each order.

  7. Go to the PDF step and click Save. Submit a test order and read the email.

Daniel’s email reads:

Hi Daniel Okafor,
Thanks for your order. Here is what we will make for you:
Mugs: 4 x $18 = $72
Bowls: 2 x $24.50 = $49
Subtotal: $121
Discount (STUDIO10): -$12.1
Delivery (Courier): $6
Total to pay: $114.9

Daniel ordered no vases, so the email has no line for vases. A customer without a code sees no discount line.

You write What it does
{% assign mugs = {{Mugs}} | times: 18 %} Multiplies the answer by the price and stores the result as mugs
mugs | plus: bowls Adds two stored numbers
subtotal | times: 0.1 Takes 10% of the subtotal
round: 2 Rounds to 2 decimal places, so 12.100000001 becomes 12.1
{% if mugs > 0 %} … {% endif %} Shows the line only when the customer ordered that item
{? total ?} Prints the stored number
The hyphens in {%- and -%} Remove the empty line that the tag would leave in the email

The Scriptlets Reference lists every number filter, including divided_by, ceil, floor, at_least and at_most.

Add sales tax of 8% to the subtotal:

{%- assign tax = subtotal | times: 0.08 | round: 2 -%}
Sales tax (8%): ${? tax ?}

Charge for each guest and thank large groups:

{%- assign total = {{Number of guests}} | times: 45 -%}
Your {{Number of guests}} places cost ${? total ?}.
{% if total >= 100 %}Bookings over $100 get a free tote bag.{% endif %}

Put the total in the subject line:

Order #{{Response Number}}: ${? {{Mugs}} | times: 18 ?} for {{Mugs}} mugs
  • The form doesn’t take payment. The email shows what to pay. Add your payment link or bank details to the message. To collect card payments from a form, see Document Studio.
  • Prices live in the template. When a price changes, change the number in the email body. Earlier emails keep the old price.
  • The total is not saved in the form or the response sheet. To keep it, add a formula column in the sheet, or send the email to yourself as well.
  • Use a Dropdown for quantities. A Short answer lets people type two or 2 pcs, and text can’t be multiplied. If you use a Short answer, turn on response validation in Google Forms and require a number.
  • An empty quantity counts as 0, so a skipped item adds nothing to the total.
  • Amounts print without trailing zeros. $114.90 shows as 114.9. There is no filter that always prints two decimals.
  • Type the tags as plain text. In the visual editor, a tag that is partly bold or coloured stops working.
  • The same calculation works in the PDF template, so the receipt can also go out as a PDF.

The scriptlet has a mistake, so the add-on sent the message with the tags left in. Check that every {% if %} has an {% endif %}, that each tag opens with {% and closes with %}, and that markers have two braces on each side.

  • The marker doesn’t match the question title. Pick the marker from the list at the corner of the box.
  • The answers are text, such as 2 pcs. Change the question to a Dropdown with numbers only.

The total is far too large or has many decimals

Section titled “The total is far too large or has many decimals”
  • A long tail such as 12.100000000000001 comes from decimal arithmetic. End the line with | round: 2.
  • A total that is too large often means a price was typed with a comma. Write 1200, not 1,200, and 24.5, not 24,5.

Capital letters and spaces count in a comparison. studio10 and STUDIO10 don’t match STUDIO10. To ignore capitals, store the answer in lower case first:

{%- assign code = {{Discount code}} | downcase | strip -%}
{%- if code == "studio10" -%}