Copied to clipboard

Flag this post as spam?

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


  • John C Scott 473 posts 1183 karma points
    Feb 24, 2014 @ 19:30
    John C Scott
    0

    setting order property

    I want to add a courier tracking code, which is added to the order in the backoffice after the goods have been shipped, and then the customer can view this and also we can send an email. 

    Almost of this is fine and working nicely.

    The problem I have is I can't see how to add a property to the order if I'm not currently in the basket process.

    EG: I have

    Order o = TC.GetOrder(1, new Guid(order));
    TrackingCode.Text = o.Properties["tracking"];

    and this works

    the best I have so far to set it is

    Order o = TC.SetCurrentOrder(1, new Guid(order));
    CustomProperty c = TC.AddOrUpdateOrderProperty(1, "tracking", Button1.Text);

    but this doesn't work, is there any way to go from an order object to set a property?

     

     

     

  • Anders Burla 2560 posts 8256 karma points
    Feb 25, 2014 @ 13:30
    Anders Burla
    100

    Hi John.

    When an order is finalized you should not use TC anymore. TC is session based and and have rules for which orders can be as the current order. And a finalized order can never be set for the current order. So use TC to get the order, or use the OrderService.Instance (in TeaCommerce.Api) if you dont want it to be session based. Then just order.Properties.AddOrUpdate( parameters) and then order.Save(); That should be it.

    Kind regards
    Anders

  • John C Scott 473 posts 1183 karma points
    Mar 03, 2014 @ 15:34
    John C Scott
    0

    this seemed to be working, but actually it isn't

    the test code i have is very simple:

            protected void SaveCode_Click(object sender, EventArgs e)
    {
    Order o = TC.SetCurrentOrder(1, new Guid(order));
    o.Properties.AddOrUpdate("tracking",TrackingCode.Text);
    o.Save();
    }

    After this when I step through the order has the custom property, but not when the order is reloaded. Any ideas what might be wrong here?

     

  • John C Scott 473 posts 1183 karma points
    Mar 03, 2014 @ 16:19
    John C Scott
    0

    ha ha sorry fixed - should have read more carefully what you wrote above

    now I have...

    Order o = TC.GetOrder(1, new Guid(order));
    o.Properties.AddOrUpdate("tracking",TextBox1.Text);
    o.Save();

    and this works a treat :)

Please Sign in or register to post replies

Write your reply to:

Draft