Some storeowners might want to generate massive discount coupon to hand them out to his customers, or to customers of his affiliates or to promoters for distribution to other people. Here is a very simple way to enhance Nop for this:
Create a new property for discounts: "Coupon Type":
Regular: The coupon remains as now just using the CouponCode
Masive for Registered Customers: The coupon (Extended-Copupon-Code) will be formed by 2 segments (separated by a hypen "-": CouponCode-Validator.
The Validator (V) is the value resulting of applying a "Validating Function" ( VF(x) ), which generates a 5 digits quasi-random integer number from the CustomerId: V= VF(CustomerId). The Validation Function will be commented later.
The store owner creates a discount with coupon code for example "ABC123" and then with Excel function generates the validator for each of the correponding customersand includes it in the discount coupon. Example:
CustomerID Validator Extended-Coupon-Code
5 53137 ABC123-53137
10 6274 ABC123-06274
123 67182 ABC123-67182
234 66834 ABC123-66834
56789 04878 ABC123-04878
Then when in the store the customer types the coupon, Nop will just check that the Validator is equal to VF(CustomerId).
Something similar can be done to distribute codes to customers associated to affiliates. In this case the Validator is generated and tested with the AffiliatedId.
Masive for Non-Registered Customers, or for Promoters, Vendors, etc.: The coupon (Extended-Copupon-Code) will be formed by 3 segments (separated by a hypen "-": CouponCode-CouponNumber-Validator.
In this case the CouponNumer is any number (sequential, random or assigned as Id to someone) which identifies the beneficiary (i.e. non registered potential customer) or and intermediary (promoter, vendor, etc.) who distributes the coupon to one or several persons. The validator and validation is done applying V=VF(CouponNumber). Example for a discount generated with coupone code "XYZ":
CouponNumber Validator Coupon
10 06274 XYZ-10-06274
20 12549 XYZ-20-12549
30 18824 XYZ-30-18824
40 25099 XYZ-40-25099
50 31374 XYZ-50-31374
The Validation Function
There are many options for the validation Function VF(X). Here is a simple one: Take the first 5 decimals of the result of dividing X by number Pi (with just 5 decimals: 3.14159) added to a MaskingNumber which is an encryption key (alike the "Encryption private key" for Credit Cards. Example 1234567890) whose first 5 digits (i.e. 0.12345) will be used as the MaskingNumber. To prevent hacking this encryption key can be changed from time to time. Example for X=10; encryption key=1234567890 and thus MaskingNumber=0.12345:
V= FirstFiveDigits of: X/(Pi+MaskingNumber)= 10/(3.14159 + 0.12345) = 10/(3.26504)= 3.062749614
V=06274
For this type of code a new type of Discount limitation could be added: N times per CouponNumber if you one to limit the number of persons the promoter can give the same coupon.