cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to get jsp new form fields to AddToCartController ?

0 Likes
863

Hi,

How could I get new form values from a JSP PAGE, and send them to AddToCartController.

I know that I have to create a class similar to AddToCartForm to have the new fields that I want to send to the controller. But I am not sure about the proccess.

Please your help.

Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

rohit31_raj92
Active Participant
0 Likes

Hi

You have to first add the new attribute to add to cart form. send the form using model attribute from controller to jsp

In jsp, you already will have form accessed using commandName or name form field. now you can have your new attribute from form in any input field.

for testing just add hard coded value to input field.so now when you submit the form you will have post method which is taking form as parameter and in this method you can get the values form the form liek it is done for qty and product code which is coming from storefront/jsp

Let me share some more details which will help you to understand and implement the task

0 Likes

Hi

Thank you for your help with this topic. Could you please tell me what is the JSP associated to the AddToCartController ?. What is the JSP that invoke the AddtoCartController so that I can create a form with the new fields there ?.

Thank you so much.

VinayKumarS
Active Contributor
0 Likes

search for productaddtocartcomponent.jsp in your storefront addon

rohit31_raj92
Active Participant
0 Likes

Hi You can see the add to cction jsp which is used for addToCction. but it will be good if you through the main landing layout jsp and see how the add to cction is called on the jsp/tag.

Just have a look on product layout jsp and try debugging the jsp/tag code for pdp which will help you to get more context about frontend and storefront

Please let me know if this helps you.

0 Likes

Hi ,

Thanks again for your help. Is there a problem if I add the new input for the new atrributes that i created for the cartentry in this form?.

Could you please send me an example in regards how to add new input is this form, and how do you get the values in the AddToCartController? is it necessary to edit an existing form class or could I have my custom form for my new attributes ?.

Thank you so much!.

Answers (0)