Hi. I have the CampaignItem set up via uCommerce admin UI that looks like this:
I have not generated any promo-codes intentially, since for this type of CompaignItems, this is assumed to be only done via code.
So right now I am looking for a way to generate a promo-code from C# code and distribute it to the client on one-per-one basis or some other autmomated way, so that I am sure I don't run out of promo codes at some point, plus I can get a hold of the promo code programmatically.
var generatedCodes = ObjectFactory.Instance.Resolve<IVoucherCodeGenerator>().GenerateCodes(numberToGenerate,
codeLength, prefix,
suffix);
Then you need to find your campaign item in some way and then find the apply target that is your promocode. You can use this services to get all apply targets (one of them if not the only one should be a promo code target.
var aggregator = ObjectFactory.Instance.Resolve<ITargetAggregator>();
var targets = aggregator .GetApplyTargets(CampaignItem).ToList();
Then you can use this to insert the voucher codes to the database:
Generating a promocode for CampaignItem from code
Hi. I have the CampaignItem set up via uCommerce admin UI that looks like this:
I have not generated any promo-codes intentially, since for this type of CompaignItems, this is assumed to be only done via code.
So right now I am looking for a way to generate a promo-code from C# code and distribute it to the client on one-per-one basis or some other autmomated way, so that I am sure I don't run out of promo codes at some point, plus I can get a hold of the promo code programmatically.
Please assist.
Thanks.
You can use this to generate a voucher code:
Then you need to find your campaign item in some way and then find the apply target that is your promocode. You can use this services to get all apply targets (one of them if not the only one should be a promo code target.
Then you can use this to insert the voucher codes to the database:
is working on a reply...