onLoyaltyPointsEarned
Last updated
Last updated
exports['sd-shops']:registerServerHook('onLoyaltyPointsEarned', function(data)
-- Log points earned
print(('[LOYALTY] %s earned %d points at %s (Total: %d)'):format(
data.customerName, data.pointsEarned, data.shopName, data.newPoints
))
-- Notify customer
TriggerClientEvent('ox_lib:notify', data.source, {
title = 'Loyalty Points',
description = ('You earned %d points! Total: %d'):format(
data.pointsEarned, data.newPoints
),
type = 'success'
})
-- Track loyalty engagement
exports['your-analytics']:TrackLoyalty({
shop = data.shopId,
customer = data.customerIdentifier,
pointsEarned = data.pointsEarned,
purchaseAmount = data.purchaseAmount
})
end)