TeaCommerce v3.1? ( not totally sure how to check).
I want to add a custom property to either every order line, or specific ones if that isn't more complicated.
I've tried looking through the docs on the TeaCommerce website and couldn't find any help. I've also Google'd it and haven't found a definitive answer.
There is a process that happens after the order has been made. Once that process has completed, I need to record the result on some, but not necessarily all, order lines.
I then need to be able to retrieve the "result" to show it in the admin / order details page. I also need to be able to check it at other times / places in the website.
I've seen mention of adding the field alias on the "Store -> Product Tab -> Product property aliases field". Does that add the field to all order lines? What about existing orders?
It's fine for the field to be there all of the time, on all order lines.
Do I then just reference it in the same way as a normal property?
orderLine.Properties["propertyAlias"]
Can I set the value using the Javascript API? (Do you have an example?)
"Product property aliases field" will copy a property value from your product to the order line. It will of cause not copy it if it doesn't exist on the product. So you can have multiple different types of products (Document Types) that just adds different properties to their respective order lines.
Note that order line properties added this way is set to read only, so the javascript cannot edit them. The server side will still be able to edit them if it needs to.
Another way of adding properties to the order line is with the AddOrUpdateOrderLine method. This you can do when adding the order line in the first place or by calling it with the javascript later on and adding an orderLineId to the call to update an existing order line.
My favorite way of doing things like that is to run through my order server side on NotificationCenter.Order.Updating/Updated. Then I have control and can make sure users don't cheat. Requires that yo have access to the custom information of cause.
I have tried to set the "current" customer order using SetCurrentOrder, but rather than set the requested order, it instead sets the latest "Cart" as the current order!?
I have debugged my code and the correct storeId and orderId are being passed in to SetCurrentOrder.
var storeId = long.Parse(CurrentPage.GetPropertyValue<string>("store", true));
var orderId = new Guid(Request.QueryString["o"]);
var ord = TC.SetCurrentOrder(storeId, orderId);
So, what am I doing wrong?
I need to update the order line(s) later (add some custom properties). I was hoping to do that with JavaScript.
GetCurrentOrder also gives you the cart - we just named it order and finalized order in Tea Commerce. So SetCurrentOrder will correctly set the session to the cart/order id parsed in. A finalized order can never be set in the SetCurrentOrder as that is only for carts.
At what time do you need to update the order lines. You just state - later - what is later? :) Is it after the order has been finalized and is a completed order?
Ah, OK - that will be why then, as it is a finalised order.
Some products can be personalised but that cannot be initiated until after the order has been made. Once the personalisation has been done, we want to store some information about it on the specific order line.
Is it possible to edit order lines once an order is finalised / completed?
A finalized order can never be set in the SetCurrentOrder as that is
only for carts
Doesn't that mean I can't update the order line(s) of a finalized order, because both AddOrUpdateOrderLine and UpdateOrderLine apply to the "current" order?
I can't find any options that allow me to pass / select a specific (finalised) order.
I tried getting the following, but that didn't work either:
var orderDetails = TC.GetOrder(model.StoreId, orderIdGuid);
var orderLine = orderDetails.OrderLines.FirstOrDefault(t => t.Id == lineId);
if (orderLine != null)
{
var customPropertiesToAdd = new Dictionary<string, string>
{
{"mdesStatus", model.ActionType},
{"mdesInfo", model.Payload}
};
var rtn = orderLine.Properties.AddOrUpdate(customPropertiesToAdd);
}
Should the above have worked? Is there another way I should be doing it?
You can't use TC to update the order as that is using session state to only work on a cart. So you need to make your own surfacecontroller - make a Javascript call to it and in the controller fetch the order from an id parameter and then change the order server side using order.someMethod and then order.Save().
You get the order from OrderService.Instance.Get(storeId, orderId);
When in the cart/webshop process do the customer personalize an order line? Why can't that info be added to the order line/s during the checkout or buy process instead of after the order is finalized?
It personalises the product to the actual user - which may not necessarily be the purchaser and in that case, the purchaser would not have the necessary information (e.g. bank details).
We also can't rely on the customer doing the personalisation at the order stage. If they don't then the product is unusable, therefore we would still need a way to allow the customer (actual user) to do it, and for us to record the result, after the order has been made.
Do I need to do an Ajax call (?) so that the order line update(s) can be done via server side code?
In that case you need to make your own SurfaceController to allow your own JS to call that and on the server change the info on the order. The order won't be recalculated after its finalized unless you change that setting in the admin UI of Tea Commerce for each order status.
Custom Order Line property
TeaCommerce v3.1? ( not totally sure how to check).
I want to add a custom property to either every order line, or specific ones if that isn't more complicated.
I've tried looking through the docs on the TeaCommerce website and couldn't find any help. I've also Google'd it and haven't found a definitive answer.
There is a process that happens after the order has been made. Once that process has completed, I need to record the result on some, but not necessarily all, order lines.
I then need to be able to retrieve the "result" to show it in the admin / order details page. I also need to be able to check it at other times / places in the website.
I've seen mention of adding the field alias on the "Store -> Product Tab -> Product property aliases field". Does that add the field to all order lines? What about existing orders?
It's fine for the field to be there all of the time, on all order lines.
Do I then just reference it in the same way as a normal property?
Can I set the value using the Javascript API? (Do you have an example?)
Hi Gordon
"Product property aliases field" will copy a property value from your product to the order line. It will of cause not copy it if it doesn't exist on the product. So you can have multiple different types of products (Document Types) that just adds different properties to their respective order lines.
Note that order line properties added this way is set to read only, so the javascript cannot edit them. The server side will still be able to edit them if it needs to.
Another way of adding properties to the order line is with the AddOrUpdateOrderLine method. This you can do when adding the order line in the first place or by calling it with the javascript later on and adding an orderLineId to the call to update an existing order line.
My favorite way of doing things like that is to run through my order server side on NotificationCenter.Order.Updating/Updated. Then I have control and can make sure users don't cheat. Requires that yo have access to the custom information of cause.
/Rune
I have tried to set the "current" customer order using SetCurrentOrder, but rather than set the requested order, it instead sets the latest "Cart" as the current order!?
I have debugged my code and the correct storeId and orderId are being passed in to SetCurrentOrder.
So, what am I doing wrong?
I need to update the order line(s) later (add some custom properties). I was hoping to do that with JavaScript.
Hi Gordon
GetCurrentOrder also gives you the cart - we just named it order and finalized order in Tea Commerce. So SetCurrentOrder will correctly set the session to the cart/order id parsed in. A finalized order can never be set in the SetCurrentOrder as that is only for carts.
At what time do you need to update the order lines. You just state - later - what is later? :) Is it after the order has been finalized and is a completed order?
Kind regards
Anders
Ah, OK - that will be why then, as it is a finalised order.
Some products can be personalised but that cannot be initiated until after the order has been made. Once the personalisation has been done, we want to store some information about it on the specific order line.
Is it possible to edit order lines once an order is finalised / completed?
Doesn't that mean I can't update the order line(s) of a finalized order, because both AddOrUpdateOrderLine and UpdateOrderLine apply to the "current" order?
I can't find any options that allow me to pass / select a specific (finalised) order.
I tried getting the following, but that didn't work either:
Should the above have worked? Is there another way I should be doing it?
You can't use TC to update the order as that is using session state to only work on a cart. So you need to make your own surfacecontroller - make a Javascript call to it and in the controller fetch the order from an id parameter and then change the order server side using order.someMethod and then order.Save().
You get the order from OrderService.Instance.Get(storeId, orderId);
Kind regards
Anders
When in the cart/webshop process do the customer personalize an order line? Why can't that info be added to the order line/s during the checkout or buy process instead of after the order is finalized?
Kind regards
Anders
It personalises the product to the actual user - which may not necessarily be the purchaser and in that case, the purchaser would not have the necessary information (e.g. bank details).
We also can't rely on the customer doing the personalisation at the order stage. If they don't then the product is unusable, therefore we would still need a way to allow the customer (actual user) to do it, and for us to record the result, after the order has been made.
Do I need to do an Ajax call (?) so that the order line update(s) can be done via server side code?
In that case you need to make your own SurfaceController to allow your own JS to call that and on the server change the info on the order. The order won't be recalculated after its finalized unless you change that setting in the admin UI of Tea Commerce for each order status.
Kind regards
Anders
OK, thanks. There's no recalculation necessary - it is purely just that we want to store extra info (custom properties) on the Order Line record.
is working on a reply...