Copied to clipboard

Flag this post as spam?

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


  • Rasmus Fjord 675 posts 1566 karma points c-trib
    Nov 05, 2015 @ 10:37
    Rasmus Fjord
    0

    Add orderline from C# in v3

    Ey :)

    So im hooked into the CalculatePrice event, and in here there is a special case where i want to add an extra orderline. The orderline can have a shifting name and price, so i cannot just create a node with a fixed price and add that.

    But cannot get anything to work. Im trying this :

     Dictionary<string, string> props = new Dictionary<string, string>();
                    props.Add("uniqueId",Guid.NewGuid().ToString());
                    var ol = order.OrderLines.AddOrUpdate(orderLine.ProductIdentifier, 1, props);
                    ol.UnitPrice = new PriceInformation() { Value = new Price(price, orderLine.VatRate, currency) };
                     ol.Name = "WeekendTillæg";
    
  • Anders Burla 2560 posts 8256 karma points
    Nov 06, 2015 @ 10:25
    Anders Burla
    0

    Should it maybe be an award instead of doing it in the calculator? But you need to create your own order line and not use the order.OrderLines.AddOrUpdate as it use Umbraco to add the order line. You will have to create an order line totally manual.

  • Rasmus Fjord 675 posts 1566 karma points c-trib
    Nov 06, 2015 @ 10:31
    Rasmus Fjord
    0

    well i dont think we can clarify it as an award and there are so many "properties" that needs to be fulfilled for this to happen though.

    Its because the product ordered has a date within a weekend and the customer needs to pay the weekend extra fee, and the fee is based on the amount of people.

    Could you give an example of what is minimum for creating an orderline from scratch ?

  • Anders Burla 2560 posts 8256 karma points
    Nov 06, 2015 @ 10:36
    Anders Burla
    0

    See the GetSnapshot of the Umbraco InformationExtractor at Github - that is what is used to get info from the product and then the quantity.

    https://github.com/TeaCommerce/Tea-Commerce-for-Umbraco/blob/master/Source/TeaCommerce.Umbraco.Configuration/InformationExtractors/XmlNodeProductInformationExtractor.cs

  • Rasmus Fjord 675 posts 1566 karma points c-trib
    Nov 08, 2015 @ 19:28
    Rasmus Fjord
    0

    awesome ill look into it.

  • Rasmus Fjord 675 posts 1566 karma points c-trib
    Nov 19, 2015 @ 15:37
    Rasmus Fjord
    0

    Hey Anders

    I really can't figure out how to create an orderline manually, could you make an a small example that would really help.

  • Anders Burla 2560 posts 8256 karma points
    Nov 20, 2015 @ 09:25
    Anders Burla
    100

    OrderLine orderLine = new OrderLine();

    orderLine.Sku = "1000";

    orderLine.ProductIdentifier = "1000";

    orderLine.Name = "Test product";

    orderLine.Quantity = 1;

    orderLine.OriginalUnitPrices.Add(new OriginalUnitPrice(995.95M, 1)); //1 is the currencyId

    orderLine.Properties.Add("test", "value");

    order.OrderLines.Add(orderLine);

    order.Save()

  • Rasmus Fjord 675 posts 1566 karma points c-trib
    Nov 20, 2015 @ 13:27
    Rasmus Fjord
    0

    Awesome man !

    Its working :)

Please Sign in or register to post replies

Write your reply to:

Draft