Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Johannes Lantz 156 posts 838 karma points c-trib
    Jul 05, 2021 @ 22:13
    Johannes Lantz
    0

    Calculate Amount Adjustment first

    Hi!

    I have ran into a bit of a pickle here. Let's say we have a product that cost 1000 SEK. The customer has 500 SEK in credits. And ontop of that we have a sale for returning that is 20% off the order total.

    So we would need the 20% to be calculated on 500 SEK and not 1000 SEK.

    But I am having a difficult time getting it to work. I have tried using Amout/Price Adjustments. Pipelines, Calculator & Events. Of what I understand the "native" discounts allways calculates first?

    What I have now is 2 adjustments. 1 amount adjustment wich handles the credits. And 1 that gets added from using the discount dashboard in the backoffice. (Wich have the rule. If order has property)

    //Johannes

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Jul 06, 2021 @ 08:08
    Matt Brailsford
    100

    Hi Johannes,

    You can control the order of price adjusters at the DI level, injecting your adjuster before the built in DiscountsPriceAdjuster like so

    composition.WithPriceAdjusters()
      .InsertBefore<DiscountsPriceAdjuster, MyPriceAdjuster>();
    

    This should then ensure that your price adjuster runs before the core adjuster that calculates the discount adjustments.

    Hope this helps

    Matt

  • Johannes Lantz 156 posts 838 karma points c-trib
    Jul 06, 2021 @ 09:13
    Johannes Lantz
    0

    Hi Matt!

    That did the trick! Thank you so much!

    I already have a few orders in the system. And if I just change the current adjusment, it throws a Unable to cast object from amount to price error. Do I just create a new adjuster & keep the old one. Or how should I go about doing this?

    //Johannes

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Jul 06, 2021 @ 09:39
    Matt Brailsford
    0

    I'd make sure you are using the right type of adjuster. There are Price Adjusters and Amount Adjusters. You want to be using a Price Adjuster.

    Amount Adjusters are adjusters that just apply to the order TransactionAmount

Please Sign in or register to post replies

Write your reply to:

Draft