Copied to clipboard

Flag this post as spam?

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


  • Dennis Adolfi 1071 posts 6356 karma points MVP 2x c-trib
    May 24, 2016 @ 09:50
    Dennis Adolfi
    0

    Orderline sortorder.

    Hi.

    Im tring to figure out how i can set up the orderlines sortorder in TeaCommerce. By default it seems that the sortorder is the same order as the items are added to the cart but my client has asked if its possible to configure the cart to always show the most expensive products first.

    Sure i could do a .OrderBy() in every view, but i want this sortorder to be saved on the order object, and not just "displayed" as ordered, so that this order also gets applied in all my views, in my confimation email and in the backoffice. Also, ive created a custom OrderCalculator and i loop through my orderlines with CalculateOrderLineUnitPrice and do some custom price calculations and i want this loop to also be looped in the order by price and not the order they got added to the cart.

    Is there a Sort function i could use or a workaround?

    Thank you!

  • Anders Burla Johansen 2560 posts 8256 karma points
    May 25, 2016 @ 09:10
    Anders Burla Johansen
    100

    Hi Dennis

    That is a good question. as the DB doesnt have any sort order for order lines other than the order they were added this is not possible out of the box. I think the "easy" way to do it is to make an extension method that sorts the order lines the places you need it. This means you have to make a custom order calculator that runs the order lines in the right order. I can't think of a smarter way to do it as you would then have to extend the order line with a sort order property and then make your own order repository that pulls in the order from DB with discounts, order lines etc and uses the custom order line property.

    Kind regards

    Anders

  • Dennis Adolfi 1071 posts 6356 karma points MVP 2x c-trib
    May 27, 2016 @ 09:45
    Dennis Adolfi
    0

    Thank you Anders for the reply. I´ll look in this that.

    / Dennis

Please Sign in or register to post replies

Write your reply to:

Draft