ICarrierProvider CanDeliver

Delford Chaffin asked on February 9, 2016 21:14

Following this example from the docs:

https://docs.kentico.com/display/K9/Example+-+Creating+a+shipping+carrier+provider+with+costs+based+on+the+country

I'm creating a custom Shipping Carrier Provider. I have the following in the CanDeliver() method:

public bool CanDeliver(Delivery delivery)
{
    EventLogProvider.LogInformation("USPSCarrierProvider", "CanDeliver", "Shipping Option: " + delivery.ShippingOption.ShippingOptionName);
    return false;
}

The log information never gets written and the shipping options (there are two services defined in the GetServices() method) still show up in the shipping selector in my checkout process.

The rest of the provider seems to work fine, i.e. it calculates shipping costs fine.

Help. Thanks!

Correct Answer

Delford Chaffin answered on February 9, 2016 23:30

SOLVED - Will share here for reference.

This ended up being a conflict with a CustomShippingOptionInfoProvider, a la ...

https://docs.kentico.com/display/K9/Example+-+Custom+shipping+option+selection

This was overriding the shipping option availability from the ICarrierProvider.CanDeliver() method.

0 votesVote for this answer Unmark Correct answer

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