SaaS CMS has officially launched! Learn more now.

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

Vote:
 

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(
                cart,
                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?

Thanks,

Scott

#188218
Feb 14, 2018 18:30
Vote:
 

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: https://world.episerver.com/forum/developer-forum/Episerver-Commerce/Thread-Container/2017/9/how-to-fetch-and-display-discounted-shipping-price-before-the-shipping-method-has-been-selected/. We're still on version 10 of commerce but hopefully this can be helpful for you anyway.

/Martin 

#188230
Feb 15, 2018 9:59
Vote:
 

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 :-)

#188232
Feb 15, 2018 10:07
Vote:
 

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

#188235
Feb 15, 2018 11:29
Vote:
 
<p>Happy that I was able to help :-)&nbsp;</p>
#188244
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.