I thought I'd post what I finally ended up writing. It is very basic, but satisfies our business needs.
using System;
using System.Collections.Generic;
using System.Linq;
using Nop.Core;
using Nop.Core.Domain.Common;
using Nop.Core.Domain.Customers;
using Nop.Core.Domain.Orders;
using Nop.Core.Domain.Payments;
using Nop.Core.Domain.Shipping;
using Nop.Services.Catalog;
using Nop.Services.Common;
using Nop.Services.Directory;
using Nop.Services.Localization;
using Nop.Services.Orders;
using Nop.Services.Payments;
using Nop.Services.Plugins;
using Nop.Services.Shipping;
using Nop.Services.Shipping.Pickup;
using Nop.Services.Stores;
using Nop.Services.Tax;
using Nop.Web.Factories;
using Nop.Web.Models.Checkout;
namespace Nop.Plugin.Shipping.Sigma
{
public class SigmaCheckoutModelFactory : CheckoutModelFactory
{
public SigmaCheckoutModelFactory(AddressSettings addressSettings, CommonSettings commonSettings, IAddressModelFactory addressModelFactory, IAddressService addressService, ICountryService countryService, ICurrencyService currencyService, IGenericAttributeService genericAttributeService, ILocalizationService localizationService, IOrderProcessingService orderProcessingService, IOrderTotalCalculationService orderTotalCalculationService, IPaymentPluginManager paymentPluginManager, IPaymentService paymentService, IPickupPluginManager pickupPluginManager, IPriceFormatter priceFormatter, IRewardPointService rewardPointService, IShippingPluginManager shippingPluginManager, IShippingService shippingService, IShoppingCartService shoppingCartService, IStateProvinceService stateProvinceService, IStoreContext storeContext, IStoreMappingService storeMappingService, ITaxService taxService, IWorkContext workContext, OrderSettings orderSettings, PaymentSettings paymentSettings, RewardPointsSettings rewardPointsSettings, ShippingSettings shippingSettings) : base(addressSettings, commonSettings, addressModelFactory, addressService, countryService, currencyService, genericAttributeService, localizationService, orderProcessingService, orderTotalCalculationService, paymentPluginManager, paymentService, pickupPluginManager, priceFormatter, rewardPointService, shippingPluginManager, shippingService, shoppingCartService, stateProvinceService, storeContext, storeMappingService, taxService, workContext, orderSettings, paymentSettings, rewardPointsSettings, shippingSettings)
{
}
public override CheckoutShippingMethodModel PrepareShippingMethodModel(IList<ShoppingCartItem> cart, Address shippingAddress)
{
CheckoutShippingMethodModel currentShippingModel = base.PrepareShippingMethodModel(cart, shippingAddress);
bool isDomestic = shippingAddress.Country.ThreeLetterIsoCode == "USA";
IList<CheckoutShippingMethodModel.ShippingMethodModel> tempShippingMethods = currentShippingModel.ShippingMethods;
for (int i = 0; i < tempShippingMethods.Count; i++)
{
if (isDomestic)
{
// Remove USPS for all domestic (USA) shipments
if (tempShippingMethods[i].ShippingRateComputationMethodSystemName.Contains("USPS"))
{
tempShippingMethods.RemoveAt(i);
}
}
else
{
// Remove UPS for all international shipments
if (tempShippingMethods[i].ShippingRateComputationMethodSystemName.Contains("UPS"))
{
tempShippingMethods.RemoveAt(i);
}
}
}
currentShippingModel.ShippingMethods = tempShippingMethods.ToArray();
return currentShippingModel;
}
}
}