Jump to content

How to change order/position of field in checkout form?


AlighaThor

Recommended Posts

Hi again community.

I managed to make my own custom field for the checkout form, specially to the section Delivery Address.

I did this:

1 - I added my custom field to the DB into the Address table.

2 - I modified the CustomerFormatterAddress file to display my custom field:

        $format['custom_final_customer'] = (new FormField)
            ->setName('custom_final_customer')
            ->setType('checkbox')
            ->setLabel(
                $this->translator->trans(
                    'I want my invoice as End Consumer', [], 'Shop.Forms.Labels'
                )
            );

3 - I modified the Address model file:

//Custom Fields
    public $custom_final_customer = 0;
'other' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage', 'size' => 300),
'phone' => array('type' => self::TYPE_STRING, 'validate' => 'isPhoneNumber', 'size' => 32),
'phone_mobile' => array('type' => self::TYPE_STRING, 'validate' => 'isPhoneNumber', 'size' => 32),
'dni' => array('type' => self::TYPE_STRING, 'validate' => 'isDniLite', 'size' => 16),
'deleted' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_post' => false),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),

//Custom fields
'custom_final_customer' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool')

My field is displaying correctly in the front office:

762443867_Seleccin_017.jpg.0a4ac45868db5297cf6cbbcd4fd53fed.jpg

But two things:

1 - I don't know when even start to make that field into de position/order I want in that form.

2 - I assumed that maybe in BO / Countries / My country / Address Format, I could order my custom field like does the default fields, but nope. While my custom field is properly listed in the Address section inside the Address Format fields to add, my front office looks even worst:

2082058196_Seleccin_018.thumb.jpg.085e409d3e5b9e114833f5c2ea75972c.jpg

The final result:

37826490_Seleccin_019.jpg.0029b2eb40b4c6fd22ca1d06508657b5.jpg

Thanks in advance.

Link to comment
Share on other sites

  • 3 years later...

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...