Copied to clipboard

Flag this post as spam?

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


  • Hutch White 89 posts 112 karma points
    Sep 21, 2012 @ 23:27
    Hutch White
    0

    Custom Shipping Per Product

    Trying to clean up post on this so starting a new thread.  Previous thread here: http://our.umbraco.org/projects/website-utilities/tea-commerce/tea-commerce-support/34699-Shipping-Method-per-Product

    Using the OrderLineAdded event I have created my custom shipping calculations based on the product property.

    This is working for adding one orderline.  It populates the amount properly for a quantity of that same orderline (if I order 2 of the same exact product it calculates correctly).  But if I add an entire new product to the order, it clears out the shipping and only totals for the last item added. Thoughts?

    Here's the main lines of the method I have hooked into OrderLineAdded:

    If (order.ShippingMethodId != intShipDefault)
    {
    order.ShippingMethodId = inShipDefault;
    }
    foreach (var property in orderLine.Properties)
    {
    if (property.Value.ToString().ToUpper() == "HALF")
    {
    shipFeeHalf = orderLine.Quantity * intShipHalfCost;
    }
    if (property.Value.ToString().ToUpper() == "FULL")
    {
    shipFeeFull = orderLine.Quantity * intShipFullCost;
    }
    }
    order.ShippingFeeWithoutVAT += shipFeeFull + shipFeeHalf;

  • Rune Grønkjær 1372 posts 3103 karma points
    Sep 24, 2012 @ 08:39
    Rune Grønkjær
    0

    Hi Hutch,

    You will need to do the foreach part for every  orderline you have. So run a foreach on your order.OrderLines.

    One little thing though. You don't need to loop your orderLine properties. You can use Linq to object to get the ones you want:

    orderLine.Properties.FirstOrDefault( p => p.Alias.ToUpperInvariant() == "HALF" );
    

    Hope that helps

    /Rune

  • Hutch White 89 posts 112 karma points
    Sep 24, 2012 @ 16:52
    Hutch White
    0

    Oh, nice!  Will try that and post results shortly.

  • 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.

Please Sign in or register to post replies