Has anyone worked out a way to generate discount codes on the fly? Generating giftcards is very simple, but I have yet to find a way to generate discount codes.
You have to first create a Marketing campaign through Tea Commerce, as far as I can see, you're not able to do this programatically using the Tea Commerce API.
When having created the Marketnig campaign, you have to add a Discount Code rule and an award, then you have to get the ID of the discount code rule. There's probably a way better way to get the ID, but the way I've done it so far is this:
// TODO: REMOVE THIS IN PRODUCTION
public ActionResult DiscountCodeGenerate(long storeId)
{
var allCampaigns = TeaCommerce.Api.Marketing.Services.CampaignService.Instance.GetAllActive(storeId);
var campaign = allCampaigns.FirstOrDefault(i => i.Name == "NewsletterSignupDiscount");
return Content(campaign.RulesGroups.FirstOrDefault().Rules.FirstOrDefault().Id.ToString());
}
Next, you need to generate the actual code. So let's assume the rule ID is 1, you can execute the following code:
Generating a discount code
Hello fellow Umbracians (and Tea Commercians?)
Has anyone worked out a way to generate discount codes on the fly? Generating giftcards is very simple, but I have yet to find a way to generate discount codes.
Thanks :)
I figured it out.
You have to first create a Marketing campaign through Tea Commerce, as far as I can see, you're not able to do this programatically using the Tea Commerce API.
When having created the Marketnig campaign, you have to add a Discount Code rule and an award, then you have to get the ID of the discount code rule. There's probably a way better way to get the ID, but the way I've done it so far is this:
Next, you need to generate the actual code. So let's assume the rule ID is 1, you can execute the following code:
is working on a reply...