Is there any example how to create a campaign with code?
How can I set ConditionInfos, ActionInfo and Data?
var carrier = new CampaignCarrier()
{
Description = cId,
StartDate = DateTime.Now,
EndDate = DateTime.Now.AddDays(365),
CombineWithAllCampaigns = true,
ConditionInfos = null,
ActionInfo = null,
Data = null,
};
Litium version: 7.4
Easiest is to create a campaign in BO and check the values in the database tables and fill in the code based on that.
I filled in as an example here:
var carrier = new CampaignCarrier()
{
Description = "MyDescription",
StartDate = DateTime.Now,
EndDate = DateTime.Now.AddDays(365),
CombineWithAllCampaigns = true,
ConditionInfos = new System.Collections.Generic.List<CampaignConditionInfoCarrier>()
{
new CampaignConditionInfoCarrier
{
CampaignID = campaignId,
CarrierState = new CarrierState
{
IsMarkedForCreating = true
},
ConditionInfoID = Guid.NewGuid(),
Data = "", // Json data
LastUpdatedDate = DateTime.Now,
LastUpdatedUserID = SecurityToken.CurrentSecurityToken.UserID,
TypeName = "Litium.Foundation.Modules.ECommerce.Plugins.Campaigns.Conditions.OrderTotalCondition"
}
},
ActionInfo = new CampaignActionInfoCarrier
{
ActionInfoID = Guid.NewGuid(),
CampaignID = campaignId,
CarrierState = new CarrierState
{
IsMarkedForCreating = true
},
Data = "", // Json data
LastUpdatedDate = DateTime.Now,
LastUpdatedUserID = SecurityToken.CurrentSecurityToken.UserID,
TypeName = "Litium.Foundation.Modules.ECommerce.Plugins.Campaigns.Actions.ReducePriceByPercentageAction"
},
Data = new Foundation.Modules.ECommerce.Campaigns.CampaignData
{
Channels = null, // supported channels
Currencies = null // supported currencies
},
};
1 Like
system
Closed
3
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.