onPurchaseCompleted
Last updated
Last updated
exports['sd-shops']:registerClientHook('onPurchaseCompleted', function(data)
-- Hide loading indicator
lib.hideTextUI()
-- Play purchase success sound
PlaySoundFrontend(-1, 'PURCHASE', 'HUD_LIQUOR_STORE_SOUNDSET', true)
-- Show receipt notification
lib.notify({
title = 'Purchase Complete',
description = ('Paid $%d at %s'):format(data.totalAmount, data.shopName),
type = 'success'
})
-- Show loyalty points if earned
if data.loyaltyPointsEarned and data.loyaltyPointsEarned > 0 then
lib.notify({
title = 'Loyalty Points',
description = ('+%d points (Total: %d)'):format(
data.loyaltyPointsEarned, data.newLoyaltyBalance
),
type = 'inform'
})
end
-- Show discount if applied
if data.discountApplied and data.discountApplied > 0 then
print(('[PURCHASE] Saved $%d with discounts'):format(data.discountApplied))
end
end)