SaaS CMS has officially launched! Learn more now.

How do you predict shipping discount generically prior to selecting the shipping method? (11.7.1)


As there any way to predicate the discount rate of a shipping rate prior to selecting it?

We have the following scenario

  1. User adds items to the basket
  2. User as a discount based upon code to the bakse that is a shipping discount (This could be a percentage out the box discount or one we've created that discounts to free if spending over a certains amount)
  3. The user is presented with the shipping methods availible with their name and price.

We are currently calling the below

        /// Inheritdoc
        public IEnumerable GetPromotionsForCart(ICart cart)
            IEnumerable rewards = _promotionEngine.Run(
                new PromotionEngineSettings()
                    ApplyReward = false,
                    RequestedStatuses = RequestFulfillmentStatus.All

            return rewards;

And then checking the SavedAmount for each of our ShippingMethods contained within these rewards to work out the discount cost or if it's free.

However this evaluation only applies if the shipping method has been selected before calling the code and as this is the point at which we are presented those options what we want to be able to for the collection of Rewards which has been returned as attached to the basket evaluate which this discout will be when it is selected.

Is there anyway of getting what the discount will be without the option being prior selected in the Cart?



Feb 14, 2018 18:30

Hello Scott, 

I asked a similar question some time ago and just added our solution for this problem in that thread, you can find the thread here: We're still on version 10 of commerce but hopefully this can be helpful for you anyway.


Feb 15, 2018 9:59

Thanks Martin I appricate the response I'll have a look through the solution hopefully it will solve the issue as IMO it's a pretty common requirement :-)

Feb 15, 2018 10:07

Thanks this code worked exaclty as I hoped, thanks for your help :-)

Feb 15, 2018 11:29
<p>Happy that I was able to help :-)&nbsp;</p>
Feb 15, 2018 12:49
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.