Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
LoyaltyService
const { loyalty } = useStackfront(); // Get referral code and stats const referral = await loyalty.getReferral(customerId); // { referralCode: string; totalReferrals: number; rewardsEarned: number; shareUrl: string } // Track a new referral await loyalty.trackReferral({ referralCode: 'REF123', referredCustomerId: 'gid://shopify/Customer/456', orderId: 'gid://shopify/Order/789', });
import { useLoyalty } from 'react-native-stackfront-sdk'; function ReferralRewards({ customerId }: { customerId: string }) { const { account } = useLoyalty(customerId); const [referral, setReferral] = useState<ReferralSdkResponse | null>(null); useEffect(() => { const { loyalty } = useStackfront(); // Access service directly for referral data loyalty.getReferral(customerId).then(setReferral); }, [customerId]); if (!referral) return null; return ( <View> <Text>Your referral code: {referral.referralCode}</Text> <Text>Total referrals: {referral.totalReferrals}</Text> <Text>Rewards earned: {referral.rewardsEarned}</Text> <ShareButton url={referral.shareUrl} /> </View> ); }
{ referralCode: string; totalReferrals: number; rewardsEarned: number; shareUrl: string; }