how to add extra fields in opencart checkout

Spread the love

in a previous project, i was working on; client told me to add remark option at checkout page so client can collect remarks from customers for their products.See Below Picture

how to add extra fields in opencart checkout

P.S. : this photo was sent by the client for my understanding so i can get idea

Now let me tell you guys how i did that.First of all you should have knowledge of  MVC architecture.If you think you have enough knowledge of those then here is what you need to do: Create a controller class and name it lets say “remarks”

add the code you need to process the data, you can get some ideas by looking at “checkout/guest/shipping” controller class. What you need is quite similar to what that class does. if you need to interact with the database in order to process the data then you need to create a Model class in the same route under the Model folder and write your functions in it. again you can get the idea from other model classes. But I don’t think you need this, probably you want to add this information to your order, in order to do that you should modify the Order class, both Controller and the Model !

Finally you need to create a template file for it, once again open the template file for “checkout/guest/shipping” and see how they did it, then you create your own.

For the controller and model classes make sure you name them properly. There is one more thing you need to do, The controller class for the step 5 sets the redirect to the next step which by default is the Confirmation. Change this line and make it redirect to your section and do the same thing for the new section and redirect it to Confirm:

I can only guide you what to do, how to do it is your job 😀 If you are a programmer then I don’t think you’ll have any problem with it. if you’re not i guess you’ll need someone to do it for you 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *