Developer forum

Forum » Ecommerce - Standard features » Is it possible to alter product fields on adding to cart?

Is it possible to alter product fields on adding to cart?

Hans Ravnsfjall
Hans Ravnsfjall
Reply

I have a list of prducts where I would like to alter product data dynamically by the user before adding them to cart

So the products are born with "empty" textfields, but before the costumer adds them to cart, they will add value to the products dynamically, from the front end product list.

I was hoping to eiter be able to do this with javascript, or by adding it to a query when adding to cart. Is this possible somehow?

 

See attachment for what I want to achieve

 

/Hans

2018-06-26_1417.png

Replies

 
Nicolai Pedersen
Reply
This post has been marked as an answer

You need to use custom orderline fields (and not product fields).

The information will change from orderline to orderline, so use custom orderline fields for that.

That also takes care of giving you 2 order lines if someone tries to buy the same product with different information (i.e. print on a t-shirt, dates to rent etc.)

See docs: https://doc.dynamicweb.com/documentation-9/ecommerce/orders/order-details#2890

And some threads on the topic:

https://doc.dynamicweb.com/forum/templates/templates/orderline-fields-how-to

https://doc.dynamicweb.com/forum/ecommerce-standard-features/ecommerce-standard-features/updating-orderline-fields-in-cart

Votes for this answer: 2
 
Hans Ravnsfjall
Hans Ravnsfjall
Reply

Thank you very mutch Nicolai for the rapid reply :)

appreciate it

Wil look into orderline fields

 

 
Hans Ravnsfjall
Hans Ravnsfjall
Reply

I have created the orderline fields, But why am I not getting any output here?

 

@foreach (LoopItem i in GetLoop("Products")){


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

 @u.TemplateTags()
  }

 

What am i missing?

(This is in a productlist view)

 

/Hans

 

 
Hans Ravnsfjall
Hans Ravnsfjall
Reply

I have also tried this in product details view


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

@i.TemplateTags()

}

 

But still no Result

 

What am i doing wrong? Is there some more configuration needed?

 

 

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply
This post has been marked as an answer

Did you assign the order line fields to the group(s) that contains the products you're testing this on? https://doc.dynamicweb.com/documentation-9/ecommerce/product-catalog/product-groups#sideNavTitle1-4-2

Votes for this answer: 2
 
Hans Ravnsfjall
Hans Ravnsfjall
Reply

Thank you Imar, that indeed seems to be the issue. I had inheritance turned on, but the fields were created afterwards, and therefore i had to assign them again at shop level.

 

/Hans

 
Hans Ravnsfjall
Hans Ravnsfjall
Reply

I got so far, that I can add the products to cart from a listview, and from the listview - i can add value to my custom OrderLineFields.

I alseo included them in my post call data (Ajax add to cart call)

But no mather how i try, I can not find the value in these fields when i go to the cart. They all appear to be empty.

 

Is it part of a certain loop, or do I have do something in particular to get it to show? The products are showing up fine in the cart.

/Hans

 
Nicolai Pedersen
Reply

Inside the orderlines loop you should have a Order.OrderLineFields loop.

BR Nicolai

 

You must be logged in to post in the forum