Cissi
December 10, 2018, 2:24pm
1
I want to add write a custom conditioon. Cause when we create this campaign for examle: “get product for free if you have something from this product list in the checkout” I also want to say that it’s only valid if the products in the list costs 1000 kr or more.
I was reading the docs for this to do this for the amount of the order. https://docs.litium.com/documentation/previous-versions/litium-6/litium-documentation/sales/campaigns/creating-a-custom-condition
How do extend so I can make the campaign valid depending on a price condition.
Litium version: 6.2.2
Note that, you do have the list of order rows in conditionArgs.FilteredOrderRows.
Following is a sample which fetches prices. However, in your case, I suppose the List price is already there in the filteredOrderRow.
public bool Process(ConditionArgs conditionArgs)
{
var priceListIds = IoC.Resolve<IPriceCalculator>()
.GetPriceLists(new PriceCalculatorArgs
{
UserSystemId = conditionArgs.UserID,
CurrencySystemId = conditionArgs.OrderCarrier.CurrencyID,
DateTimeUtc = HttpContext.Current?.Timestamp.ToUniversalTime() ?? DateTime.UtcNow,
WebSiteSystemId = conditionArgs.WebSiteID
})
.Select(x => x.SystemId)
.ToList();
var rows = conditionArgs.FilteredOrderRows
.Where(row =>
{
return _includeTierPrices || _variantService.
Get(row.ArticleID)
.Prices
.Where(price => priceListIds.Contains(price.PriceListSystemId))
.All(price => price.MinimumQuantity == 0);
}).ToList();
conditionArgs.FilteredOrderRows = rows;
return rows.Any();
}