New Custom Field during Checkout process

Jeff Torririt asked on January 22, 2019 04:07

Hi There,

I was able to add a new field in an Order detail but I'm unable to save data to it.

During the checkout process, "Review Order", a customer needs to enter a Purchase Order Reference (Custom field) to the order before paying it.

Actions done:
I added a new field called OrderPORef via Modules > E-commerce > under Classes > using Order (ecommerce.order) > then Fields

After that, I don't have any idea to include it in the code. I tried going to the OrderNote.ascx webpart just to do simple dummy fill in the SaveStepData event setting the ShoppingCart using ShoppingCart.SetValue("OrderPORef", "TESTVALUE")...

Any help?

Correct Answer

Peter Mogilnitski answered on January 22, 2019 05:40

Technically you can use existing ShoppingCartCustomData field that will automatically become OrderCustomData field when shopping cart is destroyed. (search devnet for exapmples). For your custom field you have to write this code yourself in order to do that.

0 votesVote for this answer Unmark Correct answer

Recent Answers

Eric Dugre answered on January 22, 2019 21:25 (last edited on January 22, 2019 21:26)

Orders are not created until after the final step of the checkout process, so you will not be able to set the value of a custom Order field. Peter's suggestion of using ShoppingCartCustomData/OrderCustomData would be the simplest approach, but you can still use your custom Order field.

As Peter mentioned, the OrderCustomData field is automatically populated with the ShoppingCartCustomData after checkout. This is also true for any other similarly-named fields. For example, if you create a field "OrderPORef" for the shopping cart and "OrderPORef" for the order and set the cart OrderPORef during checkout, that value will automatically transfer to the Order.

With either of these approaches, you can then set cart.ShoppingCartCustomData["OrderPORef"] or cart.OrderPORef during checkout and you should be fine. You can check other web parts like ~\CMSWebParts\Ecommerce\Checkout\Selectors\PaymentMethodSelection.ascx.cs for inspiration.

0 votesVote for this answer Mark as a Correct answer

Jeff Torririt answered on January 23, 2019 22:11

Thank you for the great information.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.