Shipping methods

Artemy Sokolov asked on May 27, 2014 08:45

Hello, How can i hide some shipping methods for some countries?

Correct Answer

Josef Dvorak answered on May 28, 2014 10:23

Hello Artemy,

There is no built in way how to do disallow certain shipping options for given countries. You will need to modify the control or web part used to display available options.

In Kentico 7, the control is located here:

~\CMSModules\Ecommerce\FormControls\ShippingSelector.ascx.cs

And is used by this checkout step:

~\CMSModules\Ecommerce\Controls\ShoppingCart\ShoppingCartPaymentShipping.ascx.cs

There are several ways how to customize these controls to achieve what you need.

For example you can rewrite the built in InitSelector method, and make it only use the additionalList property to determine what options to show. You can then specify which options are allowed in the ShoppingCartPaymentShipping control.

If you want to keep the existing functionality, you can also extend the payment method object with a custom field which will contain list of allowed countries, add a new property to the ShippingSelector, and pass a country code through this property. This will allow you to use the country code in a where condition.

The new checkout process in Kentico 8 uses this web part and control:

~\CMSWebParts\Ecommerce\Checkout\Selectors\ShippingSelection.ascx.cs ~\CMSModules\Ecommerce\FormControls\ShippingSelector.ascx.cs

The solution here is similar. Except that now options are shown using UniGrid, which allows you to directly specify the where condition, and you can access the ShoppingCart object directly in the control.

1 votesVote for this answer Unmark Correct answer

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