# Campaign price in overriden CalculateFromCarrier

**URL:** <https://forum.litium.com/t/campaign-price-in-overriden-calculatefromcarrier/398>\
**Category:** Questions\
**Tags:** litium-6, accelerator\
**Created:** [November 29, 2018, 3:08pm UTC](https://forum.litium.com/t/campaign-price-in-overriden-calculatefromcarrier/398 "2018-11-29T15:08:49Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cissi](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/cissi/32/18_2.png) [@Cissi](https://forum.litium.com/u/Cissi)\
**Post date:** [November 29, 2018, 3:08pm UTC](https://forum.litium.com/t/campaign-price-in-overriden-calculatefromcarrier/398/1 "2018-11-29T15:08:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![patric.forsgard](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/patric.forsgard/32/10_2.png) [@patric.forsgard](https://forum.litium.com/u/patric.forsgard)\
**Post date:** [November 29, 2018, 8:09pm UTC](https://forum.litium.com/t/campaign-price-in-overriden-calculatefromcarrier/398/2 "2018-11-29T20:09:32Z")

</div>

> [@Cissi](#):
>
> public new void

Depend on how the call stack is the ‘new’ keyword can make the execution to take a base implementation instead of the expected one. Are you sure the correct method is used?

---

<div class="post-metadata">

**Author:** ![Cissi](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/cissi/32/18_2.png) [@Cissi](https://forum.litium.com/u/Cissi)\
**Post date:** [December 3, 2018, 8:06am UTC](https://forum.litium.com/t/campaign-price-in-overriden-calculatefromcarrier/398/3 "2018-12-03T08:06:57Z")

</div>

Yes, I know this is used. Were using it and have been using this for a while. But the big question is why can’t I see the campaign price at this point?

---

<div class="post-metadata">

**Author:** ![patric.forsgard](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/patric.forsgard/32/10_2.png) [@patric.forsgard](https://forum.litium.com/u/patric.forsgard)\
**Post date:** [December 3, 2018, 9:58am UTC](https://forum.litium.com/t/campaign-price-in-overriden-calculatefromcarrier/398/4 "2018-12-03T09:58:43Z")

</div>

Is it all product campaigns or only `BuyXPayY` campaign type?

---

<div class="post-metadata">

**Author:** ![patric.forsgard](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/patric.forsgard/32/10_2.png) [@patric.forsgard](https://forum.litium.com/u/patric.forsgard)\
**Post date:** [December 3, 2018, 10:07am UTC](https://forum.litium.com/t/campaign-price-in-overriden-calculatefromcarrier/398/5 "2018-12-03T10:07:55Z")

</div>

I think the reason is that you using the default `IOrderCalculator` that will call the `IOrderTotalCalculator` before `ICampaignCalculator`, that means that the campaign prices is added to each the order row after the total calculations have been made.

---

<div class="post-metadata">

**Author:** ![Cissi](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/cissi/32/18_2.png) [@Cissi](https://forum.litium.com/u/Cissi)\
**Post date:** [December 3, 2018, 11:57am UTC](https://forum.litium.com/t/campaign-price-in-overriden-calculatefromcarrier/398/6 "2018-12-03T11:57:11Z")

</div>

Ok. But how can I make sure when calculation that the price discount im setting is too much.  
Cause now the discount is calcluated on the original price and not the campaign price, so the discount price is too much so it gets to a negative sum

---

<div class="post-metadata">

**Author:** ![patric.forsgard](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/patric.forsgard/32/10_2.png) [@patric.forsgard](https://forum.litium.com/u/patric.forsgard)\
**Post date:** [December 3, 2018, 12:24pm UTC](https://forum.litium.com/t/campaign-price-in-overriden-calculatefromcarrier/398/7 "2018-12-03T12:24:10Z")

</div>

The campaigns are calculating the prices on the `UnitListPrice`, some campaings can calculate on `UnitCampaignPrice` if the order row have an assigned `CampaignID` and the campaign is marked to work on existing campaign prices.

The actual calculation as you doing here should probably be a campaign with a special campaign action that will fetch the discount amount from the variant instead of fixed from the campaign. Then you are able to combine this campaign with other campaigns or the merchant can select to not combine the campaign with a specific campaign if they want.

---

<div class="post-metadata">

**Author:** ![Cissi](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/cissi/32/18_2.png) [@Cissi](https://forum.litium.com/u/Cissi)\
**Post date:** [December 3, 2018, 12:33pm UTC](https://forum.litium.com/t/campaign-price-in-overriden-calculatefromcarrier/398/8 "2018-12-03T12:33:50Z")

</div>

We can’t use campaigns for this. That’s why we have the calculation here. But I need to see if there is a campaign on the products so the calculations gets right. So if I cant see it here how do I do? There must be some way to get right price.

---

<div class="post-metadata">

**Author:** ![anusha.ganegoda](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/anusha.ganegoda/32/58_2.png) [@anusha.ganegoda](https://forum.litium.com/u/anusha.ganegoda)\
**Post date:** [December 4, 2018, 3:09pm UTC](https://forum.litium.com/t/campaign-price-in-overriden-calculatefromcarrier/398/9 "2018-12-04T15:09:20Z")

</div>

As @Patric has mentioned, the issue is with new operator.  
instead of following:

```auto
public new void CalculateOrderRowTotal(OrderRowCarrier orderRow)

```

you need to do

```auto
public void CalculateOrderRowTotal(OrderRowCarrier orderRow)

```

and to do that, extend the interface

```auto
    [Plugin("Default")]
    public class CustomOrderTotalCalculator : IOrderTotalCalculator

```

---

<div class="post-metadata">

**Author:** ![Cissi](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/cissi/32/18_2.png) [@Cissi](https://forum.litium.com/u/Cissi)\
**Post date:** [December 5, 2018, 4:46pm UTC](https://forum.litium.com/t/campaign-price-in-overriden-calculatefromcarrier/398/10 "2018-12-05T16:46:15Z")

</div>

Still something else is happening after my code. So after I set the discount and total price it’s get a new price after this gets set…  
Nvm seems like I had to remove my vat from totalprice calculation
