Copied to clipboard

Flag this post as spam?

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


  • Mark 122 posts 255 karma points
    May 07, 2014 @ 17:32
    Mark
    0

    Editing a finalized order

    I believe it is possible to edit orderlines on an existing finalized order using the javascript and .net api, but is it possible to add new orderlines to a finalized order?

    I am implementing a saved basket feature, for a basket to be saved I am having to finalize it and give it a special order status of 'Basket Saved'. However, I need customers to be able to go back and edit orders that have this 'Saved Basket' status as if they are their current orders.

    I thought perhaps copying an order might create the copy with a non-finalized state, but it appears this isn't the case, and in fact the copy is also finalized.

    Am I going about this the wrong way? Should I not be finalizing a Saved Basket order, and if not, how do I retain the order? Is it possible to remove the finalized status somehow so that I can edit the copied order and then replace the original with the copy when the customer wants to save it?

    Sorry for the wordy question, tried to keep it simple while retaining the required info.

    Thanks in advance!

    Mark

  • Anders Burla 2560 posts 8256 karma points
    May 08, 2014 @ 09:53
    Anders Burla
    0

    A basket should never be finalized - why do you have to do that? You will have to make your own method to fetch basket for a specific customer - but then you can use the TC.SetCurrentOrder method to set the order in the session. And then you can edit it as normal using TC methods and javascript

    Kind regards
    Anders

  • Mark 122 posts 255 karma points
    May 08, 2014 @ 10:10
    Mark
    0

    Hi Anders,

    The situation is..

    Customers have to log in to use this web shop. There are 2 types of users, customers and 'admin'. A customer can add items to their basket, and either place and order now, or save the order for another day. They will be able to save as many orders as they want. They will be able to view all past orders and 'saved baskets' from a my account page, and so the saved baskets must persist from one session to another.

    Admin users can do all of the above (plus placing orders as a customer), but on the 'my account' page, they will see all past orders and saved baskets from all users.

    Saved baskets and orders are all accessible by passing in an order id to the relevant page from the my account page.

    I thought that a basket did not persist past the current session unless finalized, hence that step when a basket is 'saved' for later?

    I am aware that I can use TC.SetCurrentOrder to set a given order in the session, but obviously if that is finalized, then I can't add products to it etc. using the normal html api.

    Any thoughts on a better way to approach this would be appreciated, it's my first time with Tea Commerce and I'm still pretty new to Umbraco, so am sure there's still lots of tricks to learn..

    Many thanks,

    Mark

  • Anders Burla 2560 posts 8256 karma points
    May 08, 2014 @ 10:40
    Anders Burla
    100

    Baskets are just an order that has not finished. SO it is persisted in the DB as orders. So everything is there - you just need to fetch the baskets and display them and then load the one into session that the customer needs to change.

    So dont finalize the order until the customer actually buy/pays for it. Then its a finalized order and then it should not be able to change it.

    Kind regards
    Anders

  • Mark 122 posts 255 karma points
    May 08, 2014 @ 10:59
    Mark
    0

    Ah, ok..

    That's very useful then, so what's the best way to find all baskets for a customer? There's a nice 'GetAllFinalizedOrdersForCustomer' method for orders, but I'm not aware of anything similar for non finalized orders. I'll basically want to return all orders that have any of three order statuses - 'Saved Basket' / Order Placed / Order Dispatched.

    Any pointer for that would be a huige help, you've been most helpful already :-)

    Many thanks,

    Mark

  • Anders Burla 2560 posts 8256 karma points
    May 08, 2014 @ 11:01
    Anders Burla
    0

    There is no similar - you have to go to the DB and fetch the order id's and then load the orders using TC.GetOrders

    Kind regards
    Anders

  • Mark 122 posts 255 karma points
    May 08, 2014 @ 11:05
    Mark
    0

    Fair enough, I thought that may be the case (disappointed face..), but still it should be easier than what I was trying to do.

    Can we add the ability to get all orders (finalized or not) as a feature request? I imagine it would be very helpful for other people too.

    Thanks for all the help, much appreciate,

    Mark

  • Mark 122 posts 255 karma points
    May 08, 2014 @ 17:28
    Mark
    0

    Just as a quick update and with a final (hopefully) question..

    I have gone through and tweaked how my site works so that it no longer finalizes saved baskets, it now just changes the order status to 'Saved Basket'. Then, to try and keep things nice and quick, I am adding the order Ids of saved baskets to a lucene index along with the Customer Id, that way I can veryquickly get a list of all saved basket Order Ids per customer and use that to get a list of orders via the Tea Commerce api. Works a treat and is nice and quick without having to write lots of code to query the database directly.

    One thing though, when going back to edit an order in my basket, even though I am using TC.SetCurrentOrder() to set the currently selected saved basket as the current order (I am doing this at the top of my 'edit basket' page, only if an Order Id is passed to it), when trying to update quantities using the html api (/base/TC/FormPost.aspx), the quantities are not updated. If however I navigate away from the basket and add something else to it and return to the basket again, it starts to work properly.

    Any thoughts as to what I might be missing?

  • Anders Burla 2560 posts 8256 karma points
    May 09, 2014 @ 08:44
    Anders Burla
    0

    Could you please check the order id when the order works again and see if it is the same. It might be that the order is copied and then the new order works.

    Kind regards
    Anders

  • Mark 122 posts 255 karma points
    May 09, 2014 @ 10:57
    Mark
    0

    Wow, it would appear that I in fact spent too long on this yesterday trying different ideas out, and I had in fact set the current order to be a copy of the one I was passing in (I had been investigating createing a copy to overwrite the original finalized one after it had been edited) and failed to remove that bit of code again. All seems to be working as expected now, as long as I set the passed in order to be the current one.

    I actually want to not set the passed in one to be current, so that it doesn't overwrite the users current basket, but that's a seperate issue. I'm creating a new surface controller to update orderline quantities, I'm just having a slight issue with passing the orderline details to my surface controller view now.

    Thanks for all the help, it saved a world of pain!

    Mark

  • Anders Burla 2560 posts 8256 karma points
    May 09, 2014 @ 13:36
    Anders Burla
    0

    Your welcome. Glad you got something that is almost working :)

  • Mark 122 posts 255 karma points
    May 09, 2014 @ 13:56
    Mark
    0

    Correction, now fully working, just in time for Friday afternoon Woohoo!

    Cheers.

Please Sign in or register to post replies

Write your reply to:

Draft