Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Ben Tice 31 posts 131 karma points
    Sep 03, 2014 @ 19:00
    Ben Tice
    0

    Get Price from Pricing Tab in Custom Shipping Service

    Hi All,

    How can I access the given price in the "Pricing" tab of a shipping method for use in my custom shipping service? In my case, I'd like to default to this price if a shipment has under a certain quantity, and make it free otherwise.

    public Money CalculateShippingPrice(Shipment shipment)
    {
        int totalQuantity = 0;
        foreach (OrderLine orderline in shipment.OrderLines)
        {
            totalQuantity += orderline.Quantity;
        }
    
        decimal shippingPrice;
        if (totalQuantity < 4)
        {
            shippingPrice = 5.95m;
        }
        else
        {
            // free shipping
            shippingPrice = 0;
        }
    
        return new Money(shippingPrice, shipment.PurchaseOrder.BillingCurrency);
    }

    Thanks in advance for any insight!

    Ben

  • Morten Skjoldager 440 posts 1499 karma points
    Sep 04, 2014 @ 09:38
    Morten Skjoldager
    100

    Hi ben, 

    I think you can use 

    shipment.ShippingMethod.ShippingMethodPrices

    It's a collection of prices and you can distinquish them on price group (as per the pricing tab). 

    Hope that helps.

    Regards

    Morten

  • Ben Tice 31 posts 131 karma points
    Sep 05, 2014 @ 13:25
    Ben Tice
    0

    Thanks Morten! I'll give it a try!

    Ben

Please Sign in or register to post replies

Write your reply to:

Draft