I've added a class library to my solution that is referenced by my site:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using UCommerce; using UCommerce.Api; using UCommerce.EntitiesV2; using UCommerce.Transactions.Shipping;
namespace MyNamespace { public class VolumeShippingMethodService : IShippingMethodService { public Money CalculateShippingPrice(Shipment shipment) { int totalQuantity = 0; foreach (OrderLine orderline in shipment.OrderLines) { totalQuantity += orderline.Quantity; }
return new Money(shippingPrice, shipment.PurchaseOrder.BillingCurrency); }
public bool ValidateForShipping(Shipment shipment) { if (shipment.ShipmentAddress != null) throw new InvalidOperationException("Cannot validate shipment for country. Remember to set the shipping address for shipment.");
var shippingMethod = shipment.ShippingMethod; if (shippingMethod == null) throw new InvalidOperationException( "Cannot validate destination country for shipment. It does not contain a shipping method. Remember to add a shipping method to your shipment before validating.");
/// /// Validates the order lines according to their desired destination and configured contries for shipping method /// /// protected virtual bool ValidateShippingDestination(OrderAddress shippingAddress, ShippingMethod shippingMethod) { var eligibleCountries = shippingMethod.EligibleCountries;
// No eligible countries exist - so the shipment isn't valid if (eligibleCountries == null) return false;
I've also added the following to the Custom.config file:
The namespace I'm using is the same as the assembly name.
I've touched the web.config file, attempted to override SinglePriceService, and have tried adding the component line to shipping.config instead. For the life of me, I can't get this to show up or have any effect.
I'd be extremely grateful for any help anyone can offer.
So the name of the assembly is MyNamesapce? Just want to make sure :)
Also you need to make sure that you have only one components.config in your entire site. Sometimes VS and other tools publish files to various locations under the root.
If you search for components.config, how many hits do you get? This error is fixed in a later version of uCommerce, so if you're running an old version you should upgrade!
Unable to Add Custom Shipping Service - Umbraco 7 uCommerce 6
Hi all,
I'm using Umbraco 7 and ucommerce 6. I'm attempting to add a custom volume-based shipping service as described in http://docs.ucommerce.net/ucommerce/v6/extending-ucommerce/shipping-method-service.html.
I've added a class library to my solution that is referenced by my site:
I've also added the following to the Custom.config file:
The namespace I'm using is the same as the assembly name.
I've touched the web.config file, attempted to override SinglePriceService, and have tried adding the component line to shipping.config instead. For the life of me, I can't get this to show up or have any effect.
I'd be extremely grateful for any help anyone can offer.
Thank you in advance!
Ben
So the name of the assembly is MyNamesapce? Just want to make sure :)
Also you need to make sure that you have only one components.config in your entire site. Sometimes VS and other tools publish files to various locations under the root.
If you search for components.config, how many hits do you get? This error is fixed in a later version of uCommerce, so if you're running an old version you should upgrade!
Best regards
Morten
is working on a reply...