Shipping Methods DataSource

kuntesh thakker asked on March 31, 2015 13:10

Anyone knows where Shipping selector loads datasource . From below from where ds is filled:-

/// /// /// protected override DataSet OnAfterRetrieveData(DataSet ds) { if ((ds == null) || (ShoppingCart == null)) { return ds; }

    var shippingOptions = ds.Tables[0].Select();

    foreach (DataRow optionRow in shippingOptions)
    {
        int optionID = ValidationHelper.GetInteger(optionRow["ShippingOptionID"], 0);

        ShippingOptionInfo option = ShippingOptionInfoProvider.GetShippingOptionInfo(optionID);

        if ((option != null) && !ShippingOptionInfoProvider.IsShippingOptionApplicable(ShoppingCart, option))
        {
            ds.Tables[0].Rows.Remove(optionRow);
        }
    }

    return ds;
}

Recent Answers


Suneel Jhangiani answered on March 31, 2015 13:55

That routine overrides OnAfterRetrieveData of the UniSelector which is defined in the ASCX code for the ShippingSelector as:

<cms:UniSelector ID="uniSelector" runat="server" ReturnColumnName="ShippingOptionID" ObjectType="ecommerce.shippingoption" ResourcePrefix="shippingselector" SelectionMode="SingleDropDownList" AllowEmpty="false" UseUniSelectorAutocomplete="false" />

You can see that the UniSelector is set to load objects of type 'ecommerce.shippingoption' and hence it would just pull a list of all the shipping options. That is why after the UniSelector pulls the data each entry is checked by the routine you posted to see if it is applicable to the current shopping cart or not.

As I mentioned in a previous post, I wouldn't mess around with the controls. I would either go the route of implementing a Carrier and having the administrator add each service (or do it dynamically on a periodic basis), or just implement a Custom Shipping Option Provider.

0 votesVote for this answer Mark as a Correct answer

kuntesh thakker answered on March 31, 2015 13:58

Ok.Thanks . I will go with Custom Shipping Option Provider.

0 votesVote for this answer Mark as a Correct answer

kuntesh thakker answered on March 31, 2015 13:59 (last edited on March 31, 2015 14:25)

You have any example how we can modify shipping option to get UPS Shipping instead of Kentico . It only tells about price calculation after checkout - https://docs.kentico.com/display/K8/Custom+Info+provider+example

0 votesVote for this answer Mark as a Correct answer

Suneel Jhangiani answered on March 31, 2015 15:50

I don't have an example as I haven't implemented a custom ShippingOptionInfoProvider before. However, if you are using Visual Studio, then Intellisense should help you know which routines to override. They should all end with Internal as part of their function names.

I still think you are opting to go about this the wrong way, and should really use a Custom Carrier as per the pseudo code in the other thread. If your site wants to allow all UPS services, then I would just add code in there to periodically check which services are offered by UPS and update the ShippingOptions available on the site (easy to do using a scheduled task). This has the added benefit that a site admin could limit the shipping options available by just marking those that they don't want as 'not enabled'. It is also a lot easier than trying to write a custom ShippingOptionInfoProvider class especially as you may have to handle some cases where parts are not implemented (ie. in your custom ShippingOptionInfoProvider you would probably want to override SetShippingOptionInfoInternal and set it to throw an exception since you won't be saving ShippingOptions).

0 votesVote for this answer Mark as a Correct answer

kuntesh thakker answered on March 31, 2015 15:58

Actually UPS gives the available shipping methods based on the ship address and product. I have to show that methods . so it will create issues for me if i would choose Custom Carrier as how would i get Shopping cart Object on Custom Carrier Module

0 votesVote for this answer Mark as a Correct answer

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