Default shipping option

Rob Stephen asked on June 24, 2022 18:15


Kentico 12.

Do you know if it is possible to have a default shipping option before the customer has entered their details, shipping address, name etc. Kentico will not show the shipping option unless these are set. I am just wondering if I should continue to invest time looking for a solution if its not recommended/possible.

As a quick test to look at possibilities, on my basket page (code in basket controller) I added in a default shipping option to the shopping service, in addition to this I added a dummy/default customer so that I also have a shipping address. My default shipping option then appears. However (And as expected) when I move through checkout it is using my dummy customer, which I would then need to replace with the actual customer data.

I hope that makes sense of what I am trying to achieve, any thoughts, ideas or recommendations?

Many thanks for your time, Rob

Recent Answers

Rob Stephen answered on June 28, 2022 10:09 (last edited on June 28, 2022 10:18)

Hi Pauline,

I contacted Kentico directly and they suggested a web part or event handler, I used the event handler approach as my solution is on MVC. And this suggestion from them worked well, it did not require a user or address, i had to tweak it as we need an address to get shipping costs from a 3rd party, but the general way used is below.

I created a custom shipping event Events

And then on CartItem Add fired a new event

ShoppingCartItemInfo.TYPEINFO.Events.Insert.After += ShoppingCartItem_InsertAfter;

Within that:

    if (ShoppingCart.IsShippingNeeded && (ShoppingCart.ShippingOption == null))
        int myShippingOptionID = //get your shipping option id
        ShoppingCart.ShoppingCartShippingOptionID = myShippingOptionID;

Regards, Rob

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.