Developer forum

Forum » Templates » Add value in orderline field when ordering using AJAX

Add value in orderline field when ordering using AJAX

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

I am trying to add some values to an Orderline field in the same AJAX call with adding the  Product to cart.

Asuming The system name of the Orderlinefield is Mileage, what should be the name of the Parameter used for Post?

I tried so far "Mileage" and "OrderLineFieldValue_Mileage" but it does not seem to work.

Also, the orderline fields are attached to the Shop and they are displayed on the Group details as being inherited from the Shop.

I am using 9.4.6.

Thank you,

Adrian


Replies

 
Anders Ebdrup
Anders Ebdrup
Reply

Hi Adrian,

 

How does you post look like for adding items to the basket?

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply
And did you assign the order lines to the ecom group in the backend? Without that it won't work...
 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply
Never mind. I see now you've done that at the shop level
 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Anders,

I usually serialize a few parameters and send an AJAX post to the cart.

ProductID, Quantity, CartCMD,VariantID.

I tried adding the above parameters in the same call but for some reason, nothing is saved on the OrderlineFields.

I can see the orderline fields in the cart (using templatetags) and on the Order details in the backend, but they are empty.

This means they are attached correctly to the Orderline. i am not sure if they are correctly attached to the EcomGroup even though they are reported as "Inherited" in the UI.

Thanks,
Adrian

 

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply
This post has been marked as an answer

Ok. I got it.

The name should be EcomOrderlineFieldInput_Mileage.

That would do it.

Adrian

Votes for this answer: 1
 
Hans Ravnsfjall
Hans Ravnsfjall
Reply

Hi Adrian

Are you able to display the value selected on adding to cart, in the show cart template? If so, in what loop do you see this? Can you show me an example?

I am able to populate the fields,  and i can see them in my orders - in eCom in backend, but in my loop

@foreach (LoopItem u in @i.GetLoop("Product.OrderLineFields")){
           
          }

They appear to be empty. Guess its the wrong loop or something

/Hans

 
Kim Hansen
Reply

Hey Hans,

Im pretty sure its Order.OrderLineFields, and not Product.OrderLineFields

/Kim

 

You must be logged in to post in the forum