Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sean Dooley 288 posts 527 karma points
    Dec 03, 2019 @ 10:47
    Sean Dooley
    0

    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).

    Is this a feasible approach?

    Any guidance would be greatly appreciated.

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Dec 03, 2019 @ 11:03
    Matt Brailsford
    0

    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:

    1. Create a discount product like you have suggested.
    2. 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
    3. 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

    Hope this gives you a good starting point.

    Matt

  • Sean Dooley 288 posts 527 karma points
    Dec 03, 2019 @ 11:09
    Sean Dooley
    0

    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.

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Dec 03, 2019 @ 11:18
    Matt Brailsford
    0

    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

  • Sean Dooley 288 posts 527 karma points
    Dec 03, 2019 @ 11:28
    Sean Dooley
    0

    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?

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Dec 03, 2019 @ 11:55
    Matt Brailsford
    0

    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 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.

    Matt

Please Sign in or register to post replies

Write your reply to:

Draft