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

# Basic usage

# Product Discounts - Basic Usage

Learn the essential parameters and structure for product discount events.

## Event Structure

```json theme={null}
{
  "discount": "product_discount",
  "params": {
    "discount_type": "percentage",
    "value": 15,
    "message": "15% Off Sale"
  }
}
```

## Required Parameters

### discount\_type

Specifies the type of discount to apply.

**Options:**

* `"percentage"`: Percentage discount
* `"fixed_amount"`: Fixed dollar amount off

**Example:**

```json theme={null}
{
  "discount_type": "percentage"
}
```

### value

The discount amount (numeric).

**For percentage:**

* Use whole numbers: `15` = 15%, `20` = 20%
* Not decimals: ~~`0.15`~~ ❌

**For fixed\_amount:**

* Dollar amount: `10` = \$10 off
* Per item by default (see `appliesToEachItem`)

**Examples:**

```json theme={null}
// 25% off
{
  "discount_type": "percentage",
  "value": 25
}

// $5 off per item
{
  "discount_type": "fixed_amount",
  "value": 5
}
```

## Optional Parameters

### message

Customer-facing text displayed with the discount.

```json theme={null}
{
  "message": "VIP Member Discount"
}
```

**Best Practices:**

* Keep it short and clear
* Explain why they got the discount
* Avoid technical jargon
* Examples: "10% Off Sale Items", "VIP Discount", "Bulk Order Savings"

### handles

Target specific products by their handle.

```json theme={null}
{
  "handles": ["cool-t-shirt", "awesome-jeans"]
}
```

**Notes:**

* Handles are URL-friendly product identifiers
* Find in Shopify admin or product URL
* Case-sensitive
* Multiple handles = OR logic (any matching product)

### variant\_ids

Target specific variants by ID.

```json theme={null}
{
  "variant_ids": [12345678, 87654321]
}
```

**Notes:**

* Numeric IDs or GIDs both accepted
* Most specific targeting method
* Find in Shopify admin under product variants

### vendors

Target all products from specific vendors.

```json theme={null}
{
  "vendors": ["Nike", "Adidas"]
}
```

**Notes:**

* Exact match (case-sensitive)
* Multiple vendors = OR logic
* Vendor name must match exactly as stored in Shopify

### variant\_titles

Target variants by their option values.

```json theme={null}
{
  "variant_titles": ["Large", "X-Large"]
}
```

**Notes:**

* Matches against variant option combinations
* Case-sensitive
* Useful for size/color-based discounts

## Discount Types in Detail

### Percentage Discount

Reduces price by a percentage.

```json theme={null}
{
  "discount_type": "percentage",
  "value": 20,
  "message": "20% Off"
}
```

**Calculation:**

* Original Price: \$100
* Discount: 20%
* Final Price: \$80

**Best for:**

* Sales (20% off everything)
* Customer segments (VIP gets 15% off)
* Promotional events

### Fixed Amount Discount

Reduces price by a fixed dollar amount.

```json theme={null}
{
  "discount_type": "fixed_amount",
  "value": 10,
  "message": "$10 Off"
}
```

**Default behavior (per item):**

* Original Price: \$50 per item
* Quantity: 2
* Discount: \$10 per item
* Total Discount: \$20
* Final Total: \$80

**Best for:**

* Bulk discounts (\$5 off each)
* Clearance pricing
* Fixed savings promotions

## Complete Examples

### Simple Percentage Discount

10% off all products:

```json theme={null}
{
  "rules": [
    {
      "conditions": {},
      "events": [
        {
          "discount": "product_discount",
          "params": {
            "discount_type": "percentage",
            "value": 10,
            "message": "10% Off Sitewide"
          }
        }
      ]
    }
  ]
}
```

### Targeted Product Discount

\$15 off specific product:

```json theme={null}
{
  "rules": [
    {
      "conditions": {},
      "events": [
        {
          "discount": "product_discount",
          "params": {
            "handles": ["premium-sneakers"],
            "discount_type": "fixed_amount",
            "value": 15,
            "message": "$15 Off Premium Sneakers"
          }
        }
      ]
    }
  ]
}
```

### Conditional Vendor Discount

20% off Nike products for VIP customers:

```json theme={null}
{
  "rules": [
    {
      "conditions": {
        "customer.tags": { "includes": "VIP" }
      },
      "events": [
        {
          "discount": "product_discount",
          "params": {
            "vendors": ["Nike"],
            "discount_type": "percentage",
            "value": 20,
            "message": "VIP Special - 20% Off Nike"
          }
        }
      ]
    }
  ]
}
```

### Multiple Product Discount

15% off specific products:

```json theme={null}
{
  "rules": [
    {
      "conditions": {},
      "events": [
        {
          "discount": "product_discount",
          "params": {
            "handles": ["t-shirt", "hoodie", "jacket"],
            "discount_type": "percentage",
            "value": 15,
            "message": "15% Off Apparel"
          }
        }
      ]
    }
  ]
}
```

## Common Patterns

### No Targeting = All Products

Omit targeting parameters to apply to entire cart:

```json theme={null}
{
  "discount": "product_discount",
  "params": {
    "discount_type": "percentage",
    "value": 10,
    "message": "10% Off Everything"
  }
}
```

### Multiple Targeting Methods

Combine targeting (OR logic):

```json theme={null}
{
  "params": {
    "handles": ["t-shirt"],
    "vendors": ["Nike"],
    "discount_type": "percentage",
    "value": 20
  }
}
```

Applies to: products with handle "t-shirt" OR from vendor "Nike".

## Next Steps

* [Targeting Strategies](targeting.md) - Advanced product selection with selectors
* [Advanced Features](advanced.md) - Dynamic pricing, quantity breaks, value\_case
* [Examples](examples.md) - More real-world configurations
