Copied to clipboard

Flag this post as spam?

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


  • Kasper Skov 66 posts 346 karma points
    Oct 29, 2013 @ 15:31
    Kasper Skov
    0

    GetAllFinalizedOrdersForCustomer data source?

    Where does the API function 'GetAllFinalizedOrdersForCustomer' get data from? I'm having trouble updating some custom properties on order lines in finalized orders. Changing data in the database or in the finalized XML will not result in the function returning the correct data. The only way I can get it to give the correct data, is if I delete the finalized XML and rebuild the entire site.

    So I guess its a third cached XML file somewhere.

    But if 'UpdateOrderLine' doesn't update the same data as 'GetAllFinalizedOrdersForCustomer' gets - whats the whole point of using those API functions? Well I guess the answer to that is that there's a difference between an order and a finalized order. But updating the data manually in the database doesn't do the trick either.

    Please help :)

  • Kasper Skov 66 posts 346 karma points
    Oct 29, 2013 @ 15:36
    Kasper Skov
    0

    Wait, now that I think about it. 'UpdateOrderLine' does not update my order lines.

                var orderLine = dc.TeaCommerce_OrderLines.First(x => x.Id == Convert.ToInt32(id));
                //var orderLineProp = dc.TeaCommerce_CustomOrderLineProperties.First(x => x.OrderLineId == orderLine.Id && x.Alias == "subscriptionInterval");
                //orderLineProp.Value = interval;
                //dc.SubmitChanges();
                var customPropertiesToAdd = new Dictionary<string, string>();
                customPropertiesToAdd.Add("subscriptionInterval", interval);
                TC.SetCurrentOrder(1, dc.TeaCommerce_Orders.First(x => x.Id == orderLine.OrderId).Id);
                TC.UpdateOrderLine(1, Convert.ToInt64(id), orderLine.Quantity, customPropertiesToAdd);
    

    The out-commented code does update the database ofcourse. The API UpdateOrderLines does not.

  • Kasper Skov 66 posts 346 karma points
    Oct 29, 2013 @ 17:05
    Kasper Skov
    0

    I guess I have to override something. But what?

  • Anders Burla 2560 posts 8256 karma points
    Oct 30, 2013 @ 08:45
    Anders Burla
    0

    Is the order that you try to set in the TC.SetCurrenOrder a finalized order? If so - you can't do that. The current order can only be an order that is in the cart stage.

    GetAllFinalizedOrdersForCustomer uses the order xml cache file to fetch data. So if the order data is not there it won't find it correctly using this method. Try and check of you have some properties on the order/order line that isnt allowed in xml which could break that the order xml cache updates.

    Kind regards
    Anders

  • Kasper Skov 66 posts 346 karma points
    Oct 30, 2013 @ 08:50
    Kasper Skov
    0

    Okay got it.

    THe XML file you are talking about is 'App_Data/teacommerce/finalized-order-xml-cache-1.xml' right? So nothing can be done via the API to update a finalized order?

  • Anders Burla 2560 posts 8256 karma points
    Oct 30, 2013 @ 09:01
    Anders Burla
    0

    Don't use the Razor TC class. Use the .NET API directly. The TC is just a facade for the .NET API

  • Kasper Skov 66 posts 346 karma points
    Oct 30, 2013 @ 09:27
    Kasper Skov
    0

    Got it.

    But the .NET API documentation is thin. A method list for different scenarios would be nice. But i'll manange.

    But you're saying that I can easily update properties on a finalized order using the .NET API?

    E.g. TeaCommerce.Api.Services.OrderService.Instance.Get(shopId, orderId).Properties.Get("alias").Value = "newValue"; would update both database and cached xml file so that TC.GetAllFinalizedOrdersForCustomer() will get the updated property? Or are you saying I should completely stop using GetAllFinalizedOrdersForCustomer and the Razor API?

  • Anders Burla 2560 posts 8256 karma points
    Oct 30, 2013 @ 09:40
    Anders Burla
    100

    You can just use the .NET API to update the finalized order. So get the order using the OrderService and then change things and save the order. The xml cache is then updated. Then use TC to get the order xml. TC is meant for the frontend where the .NET api is for the bit more advanced setups :)

  • Kasper Skov 66 posts 346 karma points
    Oct 30, 2013 @ 09:50
    Kasper Skov
    0

    Alright. Got it. Thanks alot.

Please Sign in or register to post replies

Write your reply to:

Draft