Copied to clipboard

Flag this post as spam?

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


  • Tomasz Kowalski 135 posts 445 karma points
    Sep 26, 2013 @ 15:14
    Tomasz Kowalski
    0

    CalculateOrderLineUnitPrice and order line property

    Hi,

    Can I add an order line property inside CalculateOrderLineUnitPrice method?

    I have tried something like this:

            protected override decimal CalculateOrderLineUnitPrice(OriginalUnitPrice originalUnitPrice, OrderLine orderLine, Currency currency, Order order)
        {
            order.Properties.AddOrUpdate("customproperty", "something");
            order.Save();
    
            return originalUnitPrice.Value;
        }
    

    but "Add to cart" button freezes at adding to cart.

    Best regards Thomas

  • Anders Burla 2560 posts 8256 karma points
    Sep 26, 2013 @ 21:59
    Anders Burla
    0

    If you do anything in the calculator - DONT save the order. That is saved at a later time. So now you create an infinite loop :)

    Kind regards
    Anders

  • Tomasz Kowalski 135 posts 445 karma points
    Sep 27, 2013 @ 08:20
    Tomasz Kowalski
    0

    I tought so :)

    My "problem" is, that I need to calculate orderline price based on other custom properties. I would like to secure situation, that this properties was not set correctly. Is there a way to f.x redirect site in this "event", or just to "let know" that price can not be calculated? I was thinking about setting some additional custom orderline property, but I don't know if this is good approach.

    Best regards Thomas

  • Anders Burla 2560 posts 8256 karma points
    Sep 27, 2013 @ 10:20
    Anders Burla
    100

    Hi Thomas

    If you need properties added to the order line which is data from the umbraco node - then just add the property alias to the comma seperated list in the store settings at the "Product" tab. It is called "Order line property aliases". Then those properties will be added and customer ca't change them.

    Calculators always need to return a decimal - so you cant make a calculator fail. Your UI would need to make sure that products are added with the right info.

    Kind regards
    Anders

Please Sign in or register to post replies

Write your reply to:

Draft