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.

  • Qaisar 31 posts 77 karma points
    Dec 02, 2014 @ 09:27
    Qaisar
    0

    custom shipping method service - problem with shipment.orderlines

    I am trying to create a custom shipping service based on weight. I have created the service by using the following link

    http://docs.ucommerce.net/ucommerce/v6/extending-ucommerce/shipping-method-service.html

     

    decimal totalWeight = 0;

        foreach (OrderLine orderline in shipment.OrderLines)
            totalWeight += orderline.Quantity * Convert.ToDecimal(orderline["Weight"]);

    the problem is when calculating the weight for the order.It seems there are no orderlines in the shipment and the total weight becomes zero.

    but if i use shipment.PurchaseOrder.OrderLines it retreives the weight.

    decimal totalWeight = 0;
                foreach (OrderLine orderline in shipment.PurchaseOrder.OrderLines)
                    totalWeight += orderline.Quantity * Convert.ToDecimal(orderline["Weight"]);

    The weight property is getting added to the orderline in AddToBasket service.

    Has anyone experienced the same or can someone point out what could be wrong?

  • Jesper Nielsen 141 posts 498 karma points
    Dec 04, 2014 @ 13:19
    Jesper Nielsen
    0

    Hello,

    Sounds like you do something like:

    1. TransactionLibrary.CreateShipment(...);
    2. TransactionLibrary.AddToBasket(...);

    In this case, the product added will be in the basket, but not assigned to the shipment.

    The normal flow is:

    1 TransactionLibrary.AddToBasket(...);
    2 TransactionLibrary.CreateShipment(...);

    Calling CreateShipment adds all the existing orderlines to the new shipment. You can specify that it should overwrite any existing shipment in a parameter.

    If you want more "finegrained" control of the Shipment flow, you can of course modify the PurchaseOrder object directly.

    Kind regards,

    Jesper

  • Qaisar 31 posts 77 karma points
    Dec 04, 2014 @ 15:07
    Qaisar
    0

    Thanks alot Jesper - It works now :-)

Please Sign in or register to post replies

Write your reply to:

Draft