Jump to content

How to add Custom Fields in Checkout


miftikhan76

Recommended Posts

I added my module with a hook hookActionCarrierProcess. The value is not getting saved to the database. Here are the steps I followed:

 

  1. Added column in table ps_orders
  2. Added input control to order-carrier.tpl
  3. Added hook hookActionCarrierProcess to my module
  4. Set $cart->UserCarrierAccount = Tools::getValue('UserCarrierAccount'); in the hook

Can anyone have some thoughts why UserCarrierAccount value is not being saved to ps_orders table?

Link to comment
Share on other sites

I figured out the solution, see as follows:

 

1. Add same fields to both ps_orders and ps_cart

2. There is no need to add fields to order-carrier.tpl. You may use DisplayCarrierList hook.

3. Add Hook  hookActionCarrierProcess and set $cart->UserCarrierAccount = Tools::getValue('UserCarrierAccount');

4. Set values to order object from cart object in validateOrder in PaymentModule class after line number 260.

 

Although the 4th action should be done using overriding the class PaymentModule as a best practice. But I changed the core just to save time in implementation.

 

Can anyone comment on this?

Link to comment
Share on other sites

  • 1 year later...

Hi miftikhan76,

 

I am not creating a module. I am adding fields to order-carrier.tpl. What file do I have to set $cart->UserCarrierAccount = Tools::getValue('UserCarrierAccount'); ? And how do I set values to order object from cart object? I know where the PaymentModule is, and have seen line number 260.

 

Thanks.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...