Customer to purchase discount code(s) for a particular product
Looking into the possibility of a customer purchasing discount codes to be used against a product. For example, a company secretary purchasing discount codes for an e-learning course (product) to be used by company employees.
I'm thinking something along the lines of
Create a product to represent a discount code.
When a customer purchases a discount code, a discount code would have to be manually created in the back-end.
Send an email to the customer with the discount code(s).
That's an interesting challenge, but I think it should be possible.
Off the top of my head, I would probably look to do the following:
Create a discount product like you have suggested.
On order finalize, create a discount or update an existing discount adding a new generated discount code to it then store the discount code against the order line in the properties collection
Modify the Confirmation email to display the discount code value stored in the order line property
Your tricky part will be number 2 as the discounts API isn't well documented atm but you'll want to explore the campaign service accessible via CampaignService.Instance and the properties and methods on a Campaign entity to be able to define the discount.
I think it could be possible to setup a basic campaign in the back office with all the rules setup but then try and add extra discount codes onto it. For that, I think you may be able to use the DiscountCodeService.Instance to fetch discount codes or create new DiscountCode instances and assign it to the known predefined RuleId.
This may not all make sense at the moment, but if you look into to those elements, I think they'll start to make more sense when you understand the structure:
Campaigns contain rules
Discount code rule works with discount codes
Discount codes are stored via DiscountCodeService
DiscountCode entities contain discount codes and save logic
Thanks for the quick response. Given me food for thought.
I was just looking into the possibility of creating a template campaign, i.e. Product Discount, and wondering if it would be possible to automatically copy that template when a discount code is purchased, amending the relevant rules.
It doesn't look like campaigns are deep clone-able so if you go that route, it'll mean you'd have to clone all of it's properties yourself. That said, a campaign isn't that big of an entity so I don't think it would be a huge task.
Is there any benefit to creating multiple campaigns? vs just appending another discount code to an exiting campaign?
Is there any benefit to creating multiple campaigns? vs just appending another discount code to an exiting campaign?
Guessing a benefit would be readability for the Shop Administrator.
The intention is to have discount codes tied to a product so that the discount code can only be used against a single product.
Using the approach of appending a discount code to an existing campaign, would I need a separate campaign per product to ensure the AND/OR logic would work as expected?
Yea I think you would, but might be better creating campaigns per product and appending codes rather than creating campaigns for each order as could make your campaigns interface quite long and harder to manage.
Another option could be to look at implementing your own IRule, IOrderLineRule (and possibly IAward) and create your own campaign rule that works more dynamically. Could save you having to create a load of campaigns if it could all be calculated in a dynamic rule.
Again, unfortunately, we don't have any docs on creating custom rules atm.
Customer to purchase discount code(s) for a particular product
Looking into the possibility of a customer purchasing discount codes to be used against a product. For example, a company secretary purchasing discount codes for an e-learning course (product) to be used by company employees.
I'm thinking something along the lines of
Is this a feasible approach?
Any guidance would be greatly appreciated.
Hi Sean,
That's an interesting challenge, but I think it should be possible.
Off the top of my head, I would probably look to do the following:
Your tricky part will be number 2 as the discounts API isn't well documented atm but you'll want to explore the campaign service accessible via
CampaignService.Instance
and the properties and methods on aCampaign
entity to be able to define the discount.I think it could be possible to setup a basic campaign in the back office with all the rules setup but then try and add extra discount codes onto it. For that, I think you may be able to use the
DiscountCodeService.Instance
to fetch discount codes or create newDiscountCode
instances and assign it to the known predefinedRuleId
.This may not all make sense at the moment, but if you look into to those elements, I think they'll start to make more sense when you understand the structure:
Hope this gives you a good starting point.
Matt
Hi Matt
Thanks for the quick response. Given me food for thought.
I was just looking into the possibility of creating a template campaign, i.e. Product Discount, and wondering if it would be possible to automatically copy that template when a discount code is purchased, amending the relevant rules.
Hey Sean,
It doesn't look like campaigns are deep clone-able so if you go that route, it'll mean you'd have to clone all of it's properties yourself. That said, a campaign isn't that big of an entity so I don't think it would be a huge task.
Is there any benefit to creating multiple campaigns? vs just appending another discount code to an exiting campaign?
Matt
Guessing a benefit would be readability for the Shop Administrator.
The intention is to have discount codes tied to a product so that the discount code can only be used against a single product.
Using the approach of appending a discount code to an existing campaign, would I need a separate campaign per product to ensure the AND/OR logic would work as expected?
Hi Sean,
Yea I think you would, but might be better creating campaigns per product and appending codes rather than creating campaigns for each order as could make your campaigns interface quite long and harder to manage.
Another option could be to look at implementing your own
IRule, IOrderLineRule
(and possiblyIAward
) and create your own campaign rule that works more dynamically. Could save you having to create a load of campaigns if it could all be calculated in a dynamic rule.Again, unfortunately, we don't have any docs on creating custom rules atm.
Matt
is working on a reply...