# onCouponApplied

### Purpose

Triggered when a coupon is successfully applied to the cart. Use this hook to play celebration sounds and show savings information.

### When It Triggers

* Player enters a valid coupon code
* Coupon validation passes on the server

### Parameters

| Parameter              | Type   | Description              |
| ---------------------- | ------ | ------------------------ |
| `data.shopId`          | string | Unique shop identifier   |
| `data.shopName`        | string | Display name of the shop |
| `data.couponCode`      | string | The coupon code applied  |
| `data.discountPercent` | number | Discount percentage      |
| `data.discountAmount`  | number | Dollar amount saved      |
| `data.previousTotal`   | number | Cart total before coupon |
| `data.newTotal`        | number | Cart total after coupon  |

### Example

```lua
exports['sd-shops']:registerClientHook('onCouponApplied', function(data)
    -- Play success sound
    PlaySoundFrontend(-1, 'CHALLENGE_UNLOCKED', 'HUD_AWARDS', true)

    -- Show savings notification
    lib.notify({
        title = 'Coupon Applied!',
        description = ('%s - Save $%d (%d%% off)'):format(
            data.couponCode, data.discountAmount, data.discountPercent
        ),
        type = 'success'
    })

    -- Log savings
    print(('[COUPON] Applied %s: $%d -> $%d (saved $%d)'):format(
        data.couponCode, data.previousTotal, data.newTotal, data.discountAmount
    ))
end)
```
