Setup Multiple Shipping Methods for Multiple Countries
In some cases you do not want your delivery drones to fly across the atlantic ocean to deliver your hardware to the customer. Luckily Ucommerce offers great capabilities to prevent those scenarios. In this article we'll cover how exactly that works and how easiy it is to limit available shipping methods for your customers based on either their billing address, delivery address or something completely different.
If you're interested
Setting Up Your Shipping Methods
Shipping methods can be created directly in the backend. If you're in how shipping methods works I recommend that you take a look at How to configure a shipping method.
Custom prices for shipping methods
The Single price that allows to be configured in the pricing tabs on your shipping method is some times enough for calculting the shipping costs. However if the costs are more dynamically based on some other criteria, custom calculations may be required. In that case I recommend that you take a look at How to create a custom shipping method service.
Dividing shipping methods into different stores and countries
Under the access tab on each shipping method you have the ability to divide its access per store and country.
On the front-end it's really easy to figure out what shipping methods is available for the customer. The only thing you need to do is the following:
The country passed into GetShippingMethods can be any Country coming from where-ever. The available shipping methods is per design not tied to either Shipping or Billing country. If you prefer you can even use GEO-location as base for what country is needed.
Once you pass in the country, Ucommerce will automatially figure out the store your customer are visiting and use that as base for what shipping methods should be returned. Thus the shipping methods will be filtered on store first and secondly per country.
Once shipping methods has been returned you just need to create it using the following:
UCommerce.Api.TransactionLibrary.CreateShipment(shippingMethodId, overwriteExisting: true);
Of course you're free to let the customer choose, but if there for some reason is only a single option you can easily just skip the step.
Once the shipment is being created the calculation of the shipping costs will be calculated by the service attached to the shipping method.