We are ovveriding the CalculateFromCarrier to count on some custom things. But we encountered a problem. If the product has a campaign price on itself, I cannot see this here.
How do I find the campaign price?
When testing im using “set a campai:hot_face:gn price on product”. And it’s displayed on the product. But when I’m in my function I cant see the campaign price.
Why cant I? And how do I access this so I can count the right way? Cause now our totalprice for the orderrow can be a negative number. Cause the discount I do in the custom function gets more than the campaign price (not more than the original).
public new void CalculateOrderRowTotal(OrderRowCarrier orderRow)
{
var num = orderRow.CampaignID != Guid.Empty ? orderRow.UnitCampaignPrice : orderRow.UnitListPrice;
decimal originDiscount = num * orderRow.Quantity * orderRow.DiscountPercentage * new Decimal(1, 0, 0, false, (byte)2);
decimal discount = 0;
if (!string.IsNullOrEmpty(orderRow.Comments) && !orderRow.IsAutoGenerated)
{
var variants = new OrderCarrierCommentUtilities().GetArticleNumbers(orderRow.Comments);
if (variants != null && variants.Any())
{
var discountSubscriptionFee = 0;
var months = 0;
foreach (var id in variants)
{
var variant = IoC.Resolve<VariantService>().Get(id);
discount += variant.Fields.GetValue<int>("SubscriptionDiscount");
var fieldDiscountSubscriptionFeeValue = variant.Fields.GetValue<int>("DiscountSubscriptionFee");
if (fieldDiscountSubscriptionFeeValue > 0)
{
discountSubscriptionFee = fieldDiscountSubscriptionFeeValue;
}
var fieldMontsValue = variant.Fields.GetValue<int>("SubscriptionMonths");
if (fieldMontsValue > 0)
{
months = fieldMontsValue;
}
}
discount += months > 0 ? discountSubscriptionFee * months : discountSubscriptionFee;
if (string.IsNullOrEmpty(orderRow.DiscountDescription) && orderRow.DiscountDescription != ChangedConstant && discount > 0)
{
var vat20Percentage = Decimal.Parse(CurrentState.Current.WebSite.As<OrderB2CWebSiteStrings>().SubscriptionDisountFeeVat) / 100;
decimal newDiscount = originDiscount + (discount - discount * vat20Percentage);
if (newDiscount >= orderRow.TotalPrice)
{
newDiscount = orderRow.TotalPrice - 1;
}
orderRow.DiscountDescription = ChangedConstant;
orderRow.DiscountAmount = newDiscount;
}
}
else
{
orderRow.DiscountAmount = originDiscount;
}
}
orderRow.TotalPrice = num * orderRow.Quantity - orderRow.DiscountAmount;
}
Litium version: 6.2.3-patch-1811190921