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
    Dec 03, 2012 @ 08:17
    Rasmus Fjord
    0

    Adding a property through C#

    Im doing some extending (yay ! :) ) but i cannot see how to add/remove a property to an order.

    What ive done is fetched the order, and taken out the properties as a list of orderproperties. When i have manipulated this i wanna put it back in, but how is this done ? it says on o.properties that its read only.

     

     

           Order o = TeaCommerce.Razor.TeaCommerce.GetOrder();                                      List<OrderProperty> props = o.Properties.ToList<OrderProperty>();                        OrderProperty op = new OrderProperty("giftcard", AcceptedGiftCard.Id.ToString());
           props.Add(op);

     

     

     

     

     

  • Rune Grønkjær 1372 posts 3103 karma points
    Dec 03, 2012 @ 08:23
    Rune Grønkjær
    0

    Hi Rasmus,

    First of all. In Tea Commerce 1 you cannot remove properties. You can just edit their value to an empty string.

    To add a new order line programatically you need to use the AddProperty method on the order object. If the property already exists it will be updated.

    order.AddProperty( new OrderProperty"key", "value"falsetrue ) );
    

    You can also edit the value of an existing property by settings it's Value.

    Remember to save the order in the end

    /Rune

  • Rasmus Fjord 675 posts 1566 karma points c-trib
    Dec 03, 2012 @ 08:39
    Rasmus Fjord
    0

    Arh okay. Thx Rune for a "quicky" answer :)

  • Rune Grønkjær 1372 posts 3103 karma points
    Dec 03, 2012 @ 08:52
    Rune Grønkjær
    0

    No prop(erty) ;)

Please Sign in or register to post replies

Write your reply to:

Draft