onCouponDeleted

Purpose

Triggered when a coupon is deleted from a shop. Use this hook to log coupon removals for auditing.

When It Triggers

  • Owner or authorized employee deletes a coupon

  • Coupon is removed from the database

Parameters

Parameter
Type
Description

data.source

number

Server ID of who deleted

data.shopId

string

Unique shop identifier

data.shopName

string

Display name of the shop

data.couponCode

string

The deleted coupon code

data.deletedBy

string

Name of person who deleted

data.deletedByIdentifier

string

Identifier of person who deleted

data.totalTimesUsed

number

How many times coupon was used before deletion

data.timestamp

number

Server timestamp

Example

exports['sd-shops']:registerServerHook('onCouponDeleted', function(data)
    -- Log deletion
    print(('[COUPON] %s deleted coupon "%s" at %s (Was used %d times)'):format(
        data.deletedBy, data.couponCode, data.shopName, data.totalTimesUsed
    ))

    -- Send Discord notification
    exports['your-logging']:Log('coupon-deleted', {
        shop = data.shopName,
        code = data.couponCode,
        deletedBy = data.deletedBy,
        timesUsed = data.totalTimesUsed
    })
end)

Last updated