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

# Shopify Functions

> Create discount, payment, and shipping customizations

## What are Functions?

Shopify Functions are serverless functions that customize discounts, payments, shipping, and validation logic.

## Function Types

<CardGroup cols={2}>
  <Card title="Discounts" icon="percent">
    Volume discounts, BOGO, tiered pricing
  </Card>

  <Card title="Payment Customization" icon="credit-card">
    Hide/rename payment methods
  </Card>

  <Card title="Shipping Customization" icon="truck">
    Custom shipping rates and rules
  </Card>

  <Card title="Validation" icon="shield-check">
    Cart and checkout validation
  </Card>
</CardGroup>

## Example: Volume Discount

```javascript theme={null}
export function run(input) {
  const quantity = input.cart.lines.reduce((total, line) => total + line.quantity, 0);
  
  if (quantity >= 10) {
    return {
      discounts: [{
        value: { percentage: { value: 20 } },
        targets: [{ productVariant: { id: "gid://..." } }]
      }]
    };
  }
  
  return { discounts: [] };
}
```

## Key Features

* **JavaScript/Rust**: Write in familiar languages
* **Fast Execution**: Sub-100ms execution time
* **GraphQL Input**: Query cart and customer data
* **Metafield Config**: Configure via Shopify admin
