I need to implement a shipping cost that can based on zone or country/zip-code.
i saw something in this post:
http://devnet.kentico.com/Forums/f47/fp14/t14865/ECommerce-Shipping-Charge.aspx
and i changed to:
public class POSLAJUShippingOptionInfoProvider : ShippingOptionInfoProvider
{
protected override double CalculateShippingInternal(ShoppingCartInfo cart)
{
if (UPS)
{
return base.CalculateShippingInternal(cart);
}
else
{
// custom shipping calculation here
...
}
}
}
on top of that, I created 3/4 tables:
1) zone table (Zone1, Zone2, ...)
2) zone-country relationship table (for external courier; Malaysia in Zone1, USA in Zone4, etc)
3) zone-zipcode relationship table (for internal courier; 00000~00010 in Zone1, 10000~11000 in Zone2)
4) new/extend the "COM_ShippingCost" table to store zone-ID, and country/zipcode flag (
eg :
shippingOptionID=4, ZoneID=1, MinWeight=500g, CostValue=$10;
shippingOptionID=4, ZoneID=1, MinWeight=1000g, CostValue=$15;
shippingOptionID=4, ZoneID=2, MinWeight=500g, CostValue=$20;
shippingOptionID=4, ZoneID=2, MinWeight=1000g, CostValue=$25;
)
with this query (if external courier, based on country):
string queryText = "Select cscz.ShippingCostID, cscz.ShippingCostMinWeight, cscz.ShippingCostValue " +
" from dbo.CMS_Zone cz with (nolock) " +
"inner join dbo.CMS_ZoneCountryShipping czcs with (nolock) on cz.ZoneID = czcs.ZoneID " +
"inner join Kentico_Ecomm.dbo.COM_ShippingOption cso with (nolock) on czcs.ShippingOptionID = cso.ShippingOptionID " +
"inner join Kentico_Ecomm.dbo.CMS_Country cc with (nolock) on cc.CountryID = czcs.CountryID " +
"INNER JOIN dbo.COM_ShippingCostZone cscz with (nolock) on czcs.ZoneID = cscz.ShippingCostZoneID " +
" AND czcs.ShippingOptionID = cscz.ShippingCostShippingOptionID " +
"where czcs.CountryID = " + address.AddressCountryID +
" AND ShippingCostMinWeight <= " + cart.TotalItemsWeight +
" AND ShippingCostShippingOptionID = " + cart.ShippingOptionInfoObj.ShippingOptionID +
" ORDER BY ShippingCostMinWeight DESC";
thus I need to customize/sub-class this CMS-Desk module to perform the configuration.
~\CMSModules\Ecommerce\Pages\Tools\Configuration\ShippingOptions\ShippingOption_Edit_ShippingCosts_Edit.aspx.cs
How to override this class elegantly:
namespace CMS.Ecommerce
{
// Summary:
// ShippingCostInfo data container class.
public class ShippingCostInfo : SynchronizedInfo<ShippingCostInfo>
...