Developer forum

Forum » Development » Basket - Server side step ?

Basket - Server side step ?

Anders Jensen
Reply

Hi

If I want to create a custom server side step in the basket, and store the new data to the basket/order.

How would I go about doing that ?


Replies

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

Hi Anders,

You cannot create a new step that is executed only on the server, but that wouldn't make sense anyway, because steps are for breaking the checkout flow up into manageable pieces for the user.

If you want to execute some logic at a certain point during the checkout, you can use notifications. There are loads of them in the cart (https://doc.dynamicweb.com/api/html/ca4f1873-5a74-322b-57ba-124f5a707dbd.htm), so you should be able to find one that works for your use-case.

If this is not what you're looking for, please explain in more detail, what you're trying to do so I can better assist you.

- Jeppe

 
Anders Jensen
Reply

Hi Jeppe

sorry for the bad explanation, I still want a view file to show the server side filled out model, so the user can type/select data from that model.

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

Not sure I completely understand what you're trying to do, but if the challenge is to render one or more fields to the user for them to give additional input, then it sounds like you can solve that using custom Order Fields (https://doc.dynamicweb.com/documentation-9/ecommerce/carts-orders/custom-fields). These allow you to extend the shape of an order so you can collect additional information from the user.

- Jeppe

 
Anders Jensen
Reply

Hi Jeppe

I need to get external data "RESTAPI" and give that info to the user in the checkout.

Where the user selects an option of that data, and store that on the basket/order.

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Anders,

If I understand your need correctly, you should probably add a new step in the checkout flow, add a new template to it, and do whatever you need.

Just make sure you use a form to post data back to the cart before redirecting to the next step.

I hope this helps,

Adrian

 

 

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

Hi Anders,

You can solve this issue in a couple of ways.

As Adrian suggests, one solutions is to create a template that communicates with the REST endpoints to fetch the data, and render it to the user. This can either be done as a server-side rendered template (Razor) or as a client-side JS app.

You can also use an order template extender (https://doc.dynamicweb.com/api/html/0c76677c-15df-c244-c177-46a549ad3708.htm) to contact the endpoints and render new tags in the template.

In both cases, you can save the user selection in a custom Order Field.

- Jeppe

 
Anders Jensen
Reply

Thanks Jeppe  & Adrian, I'll look into your options.

 

You must be logged in to post in the forum