Custom Shipping Method: Show value in shipping methods
I've built a simple custom shipping method. When I list the methods, I'd like to show how much it is calcualted to next to it. Can anyone advise on how could be done?
ALSO: In the meantime, I'm trying to output the Description to explain the calculation. Using:
I did this by creating an XSLT Extension in my App_Code, with a method that I can call from XSLT:
[XsltExtension]
public class Business
{
public Business() { } //required for the xslt extention
public static decimal GetShippingCost(int shipmentMethodId)
{
Basket b = SiteContext.Current.OrderContext.GetBasket();
OrderAddress shippingAddress = b.PurchaseOrder.OrderAddresses.ToList().Last();
return GetShippingCost(shipmentMethodId, b.PurchaseOrder.OrderLines, shippingAddress);
} ...
public static decimal GetShippingCost(int shipmentMethodId, ICollection<OrderLine> orderLines, OrderAddress orderAddress) { //logic to calculate shipping cost. Call this method from your custom shipping method, e.g. //decimal shippingPrice = Business.GetShippingCost(shipment.ShippingMethodId, shipment.OrderLines, shipment.ShipmentAddress); //return new Money(shippingPrice, shipment.OrderLines.First().PurchaseOrder.BillingCurrency); }
Custom Shipping Method: Show value in shipping methods
I've built a simple custom shipping method. When I list the methods, I'd like to show how much it is calcualted to next to it. Can anyone advise on how could be done?
ALSO: In the meantime, I'm trying to output the Description to explain the calculation. Using:
@myShippingMethod.GetDescription("EN-US").DescriptionThis is returning nothing. Am I calling this wrong?
I'm trying to do exaclty the same - help would be appreciated
I did this by creating an XSLT Extension in my App_Code, with a method that I can call from XSLT:
[XsltExtension] public class Business { public Business() { } //required for the xslt extention public static decimal GetShippingCost(int shipmentMethodId) { Basket b = SiteContext.Current.OrderContext.GetBasket(); OrderAddress shippingAddress = b.PurchaseOrder.OrderAddresses.ToList().Last(); return GetShippingCost(shipmentMethodId, b.PurchaseOrder.OrderLines, shippingAddress); }
...
public static decimal GetShippingCost(int shipmentMethodId, ICollection<OrderLine> orderLines, OrderAddress orderAddress)
{
//logic to calculate shipping cost. Call this method from your custom shipping method, e.g.
//decimal shippingPrice = Business.GetShippingCost(shipment.ShippingMethodId, shipment.OrderLines, shipment.ShipmentAddress);
//return new Money(shippingPrice, shipment.OrderLines.First().PurchaseOrder.BillingCurrency);
}
Then in your XSLT:
Hope that makes sense.
Zac
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.