To configure voucher settings in your store, you need:
- Salesforce administrator or StoreConnect administrator access
- Active StoreConnect store configuration
- Voucher fields pre-configured for your store record layout
Set up the voucher email template
You can have different email templates for different voucher products. Just set the relevant template on each different voucher product.
- Navigate to Setup > Email Templates in Salesforce.
- Locate your voucher email template or create a new one.
- Edit the template to include merge fields:
- {!Voucher__c.Code__c} for the voucher code
- {!Voucher__c.Opening_Balance__c} for the value
- {!Voucher__c.Expires_At__c} for expiry date
- We recommend also including instructions for voucher use, and a link to a page for checking the voucher balance, e.g. https://your-store-domain.com/check-voucher.
- Save and test the template.
Configure store-level voucher settings
- Navigate to your Store record.
- Locate the voucher configuration section.
- Set Voucher Expiry Unit to either Month or Week.
- Enter a numeric value in Voucher Expiry Length (e.g. 12 for 12 months) Note: If both fields are set, automatically created vouchers will expire based on the configured timeframe from the creation date. Leave these fields blank if you don't want vouchers to expire.
- In the Deliver Vouchers At Order Status field, enter the API name of the Order Status that should trigger voucher creation (e.g. Activated).
- Click Save.
Caution: Ensure voucher orders are fully paid before changing them to the status that triggers voucher delivery.
Advanced configuration for vouchers
The following are optional advanced tasks for customizing how vouchers work in your business.
Customize voucher codes
By default, StoreConnect generates 16-character alphanumeric codes (case-insensitive) providing 7.96 × 10²⁴ possible combinations. This provides strong protection against brute-force attempts to guess voucher codes.
Voucher code security: If you want to customize voucher codes, ensure you maintain a large code space to prevent voucher codes from being guessed. We recommend you only customize to achieve stronger code generation.
- Create an Apex class that implements the global interface IVoucherCodeGenerator.
- Implement the required method: String generate(Voucher__c voucher).
- Ensure your code generates unique strings of 80 characters or less.
- Navigate to Setup > Custom Metadata Types.
- Open StoreConnect Settings.
- Enter your class name in the Voucher Code Generator Class field.
- Save and test voucher creation.
Example code structure
global class CustomVoucherCodeGenerator implements IVoucherCodeGenerator {
global String generate(Voucher__c voucher) {
// Your custom code generation logic
// Must return a unique string <= 80 characters
}
}