> ## Documentation Index
> Fetch the complete documentation index at: https://docs.peanutsapp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Building Price Calculators

> Create dynamic calculators that pull pricing from your Knowledge Base

<Info>
  **Time:** 20 minutes | **Level:** Advanced\
  **Prerequisites:** [Knowledge Base Fundamentals](/tutorials/advanced/knowledge-base-fundamentals)
</Info>

## What You'll Learn

* Creating calculator-style helpers
* Linking fields to knowledge data
* Building dynamic pricing logic
* Generating instant quotes
* Sharing calculators with clients

***

## Why Build Price Calculators?

Transform your uploaded price lists into interactive tools:

| Manual Process            | With Calculator               |
| ------------------------- | ----------------------------- |
| Client calls for quote    | Client uses self-service tool |
| You look up prices        | Prices auto-populate          |
| Calculate totals manually | Instant calculated totals     |
| Email quote back          | Quote generated instantly     |

***

## Step 1: Prepare Your Knowledge

Before building, ensure your Knowledge Base has the pricing data:

<Steps>
  <Step title="Upload Price List">
    If not already done, upload your pricing document (PDF, Excel, or image).
  </Step>

  <Step title="Verify Extraction">
    Check that key pricing elements were extracted:

    * Product/service names
    * Base prices
    * Quantity tiers (if applicable)
    * Options and add-ons
  </Step>

  <Step title="Note the Structure">
    Understand how your data is organized:

    * What are the main product categories?
    * What variables affect price (size, material, quantity)?
    * Are there any conditional rules?
  </Step>
</Steps>

***

## Step 2: Create the Calculator Helper

<Steps>
  <Step title="Create New Helper">
    Tap **+** → describe: "Price calculator for \[your product/service]"

    Example: "Price calculator for printing services with paper type, size, and quantity"
  </Step>

  <Step title="Review Generated Fields">
    Peanuts creates fields based on your description. Common calculator fields:

    | Field Type | Use Case                               |
    | ---------- | -------------------------------------- |
    | Select     | Product type, paper type, size options |
    | Number     | Quantity, dimensions                   |
    | Checkbox   | Add-ons, rush delivery                 |
    | Calculated | Subtotal, tax, total                   |
  </Step>

  <Step title="Customize Fields">
    Adjust fields to match your pricing structure:

    * Add options from your price list
    * Set appropriate min/max for quantities
    * Add any missing variables
  </Step>
</Steps>

***

## Step 3: Link to Knowledge Base

Connect your calculator to the uploaded pricing data:

<Steps>
  <Step title="Open Helper Settings">
    Go to your calculator helper → **Settings** → **Knowledge**.
  </Step>

  <Step title="Link Price List">
    Select the relevant knowledge document(s) containing your pricing.
  </Step>

  <Step title="Test the Connection">
    Ask Peanuts within the helper:

    ```
    "What's the price for [specific option]?"
    ```

    It should return the correct price from your knowledge.
  </Step>
</Steps>

***

## Step 4: Configure Pricing Logic

Set up how prices are calculated based on selections:

<Tabs>
  <Tab title="Simple Lookup">
    For straightforward pricing (select option → get price):

    ```
    Paper Type: Matte → $25/100 sheets
    Paper Type: Glossy → $30/100 sheets
    Paper Type: Premium → $45/100 sheets
    ```

    The calculator looks up the price based on the selected option.
  </Tab>

  <Tab title="Quantity Tiers">
    For volume-based pricing:

    ```
    1-99 units: $5.00 each
    100-499 units: $4.00 each
    500+ units: $3.00 each
    ```

    Price per unit changes based on quantity entered.
  </Tab>

  <Tab title="Combined Variables">
    For multi-factor pricing:

    ```
    Base price (from size) × Paper multiplier × Quantity

    A4 Matte × 100 = $15 × 1.0 × 100 = $1,500
    A3 Glossy × 100 = $25 × 1.2 × 100 = $3,000
    ```
  </Tab>

  <Tab title="Add-ons">
    For optional extras:

    ```
    Base: $100
    ☑ Rush delivery: +$25
    ☑ Gift wrapping: +$10
    ☐ Insurance: +$5

    Total: $135
    ```
  </Tab>
</Tabs>

***

## Step 5: Add Calculated Fields

Create fields that automatically compute totals:

<AccordionGroup>
  <Accordion title="Subtotal Field" icon="equals">
    Calculates the base price before extras:

    **Formula concept:**

    ```
    Unit Price (from knowledge) × Quantity
    ```
  </Accordion>

  <Accordion title="Add-ons Total" icon="plus">
    Sums selected optional extras:

    **Formula concept:**

    ```
    Sum of all checked add-on values
    ```
  </Accordion>

  <Accordion title="Tax Calculation" icon="percent">
    Applies tax rate to subtotal:

    **Formula concept:**

    ```
    (Subtotal + Add-ons) × Tax Rate
    ```
  </Accordion>

  <Accordion title="Grand Total" icon="calculator">
    Final amount due:

    **Formula concept:**

    ```
    Subtotal + Add-ons + Tax
    ```
  </Accordion>
</AccordionGroup>

***

## Step 6: Test Your Calculator

Run through test scenarios to verify accuracy:

<Steps>
  <Step title="Test Base Cases">
    Try the simplest selections and verify prices match your source.
  </Step>

  <Step title="Test Edge Cases">
    * Minimum quantities
    * Maximum quantities
    * Tier boundaries (99 vs 100 units)
    * All add-ons selected
  </Step>

  <Step title="Compare to Manual">
    Calculate a few quotes manually and compare to calculator output.
  </Step>

  <Step title="Fix Discrepancies">
    If prices don't match:

    * Check knowledge extraction accuracy
    * Verify field-to-knowledge linking
    * Review calculation logic
  </Step>
</Steps>

***

## Sharing Your Calculator

<Tabs>
  <Tab title="Widget Embed">
    Create a public widget for your website:

    1. Go to helper **Settings** → **Sharing**
    2. Enable **Public Widget**
    3. Copy embed code
    4. Add to your website

    ```html theme={null}
    <iframe 
      src="https://peanuts.app/widget/[your-helper-id]"
      width="100%"
      height="500"
      frameborder="0"
    ></iframe>
    ```
  </Tab>

  <Tab title="Direct Link">
    Share a link clients can access:

    1. Go to helper **Settings** → **Sharing**
    2. Enable **Public Access**
    3. Copy the share link
    4. Send to clients via email or message
  </Tab>

  <Tab title="QR Code">
    For in-store or print materials:

    1. Go to helper **Settings** → **Sharing**
    2. Generate **QR Code**
    3. Download and add to:
       * Business cards
       * Flyers
       * Store displays
  </Tab>
</Tabs>

***

## Real-World Examples

<CardGroup cols={2}>
  <Card title="Print Shop Calculator" icon="print">
    **Fields:** Paper size, paper type, quantity, color/B\&W, binding

    **Knowledge:** Price list PDF with size × paper × quantity matrix

    **Output:** Instant quote with itemized breakdown
  </Card>

  <Card title="Catering Quote Tool" icon="utensils">
    **Fields:** Event type, guest count, menu selection, add-ons

    **Knowledge:** Menu with per-person pricing

    **Output:** Total cost with dietary accommodation notes
  </Card>

  <Card title="Shipping Calculator" icon="truck">
    **Fields:** Package weight, dimensions, destination, speed

    **Knowledge:** Carrier rate tables

    **Output:** Shipping options with delivery dates
  </Card>

  <Card title="Service Quote" icon="screwdriver-wrench">
    **Fields:** Service type, hours estimated, parts needed, urgency

    **Knowledge:** Hourly rates and parts catalog

    **Output:** Labor + parts + rush fee total
  </Card>
</CardGroup>

***

## Exercise

<Card title="Practice: Build a Complete Price Calculator" icon="dumbbell">
  Create a calculator for a real or fictional business:

  1. **Choose a product/service** (printing, food, shipping, services)
  2. **Create or upload a price list** with at least:
     * 3+ product options
     * 2+ quantity tiers OR size variants
     * 1+ optional add-on
  3. **Build the calculator helper** with appropriate fields
  4. **Link to your knowledge base**
  5. **Test with 5 different quote scenarios**
  6. **Generate a shareable widget**

  **Bonus:** Share the widget link and test it on a different device.
</Card>

***

## Key Takeaways

<Tip>
  **Remember:** Price calculators = Knowledge Base + structured fields + calculated totals. Once set up, they generate accurate quotes 24/7 without any manual lookup.
</Tip>

***

## Next Steps

<CardGroup cols={2}>
  <Card title="Multi-Source Lookups" href="/tutorials/advanced/multi-source-lookups" icon="layer-group">
    Query across multiple knowledge documents
  </Card>

  <Card title="Webhooks & Automation" href="/tutorials/expert/webhooks-and-automations" icon="webhook">
    Auto-send quotes via email
  </Card>
</CardGroup>
