Jump to content

Remove fields in the checkout page


user900

Recommended Posts

 

Hi guys,

Im trying to remove some fields form the checkout page (specifically: postcode, city, address 2)

First was a problem to remove the city field,  I went to: International / Locations them I selected country and when I tried to remove the field "city" I couldn't, PrestaShop said the following message:

"The city field (in tab Address) is required"

 

So after some google, I found out I need to modify:  classes/Address.php

I commented the whole line 134 that said:

'city' => ['type' => self::TYPE_STRING, 'validate' => 'isCityName', 'required' => true, 'size' => 64],

 

The problem persisted, and I still got the same message, so I edit the file classes/AddressFormat.php

I commented the line 63 that said "city":

    /** @var array Default required form fields list */
    public static $requireFormFieldsList = [
        'firstname',
        'lastname',
        'address1',
        // 'city',
        'Country:name',
    ];


Now, I finally was available to remove the field. But the issue still persit. Let me explain my self:

If you go to the checkout page, you can see the postal code and city field.

1296605711_Screenshot2021-03-31at10_14_26p.m..thumb.jpg.499c436f32673d061e4ecaa536d3e1bc.jpg

 

 

But, when I select the country, everything looks like is supposed to look.

862842549_Screenshot2021-03-31at10_14_36p.m..thumb.jpg.9a74ce48a65d3b2afee7f59abcd8b790.jpg

 

 


Any idea? How can I do, so i can remove the postcode and the city field?

Btw, my cache is off, but, I had cleaned my cache (in the performance page) and also I cleaned the cache on my browser. Also, I deleted this folder: /var/cache/prod/

Thanks guys

I use Prestashop: 1.7.7.2

Screenshot 2021-03-31 at 10.06.59 p.m..jpg

Screenshot 2021-03-31 at 10.00.57 p.m..jpg

Edited by user900 (see edit history)
Link to comment
Share on other sites

  • 5 months later...
On 3/31/2021 at 4:18 PM, user900 said:

 

Hi guys,

Im trying to remove some fields form the checkout page (specifically: postcode, city, address 2)

First was a problem to remove the city field,  I went to: International / Locations them I selected country and when I tried to remove the field "city" I couldn't, PrestaShop said the following message:

"The city field (in tab Address) is required"

 

So after some google, I found out I need to modify:  classes/Address.php

I commented the whole line 134 that said:

'city' => ['type' => self::TYPE_STRING, 'validate' => 'isCityName', 'required' => true, 'size' => 64],

 

 

 

Instead of to comment the line, you can set the required value to false, the same with the state field and the country field. The only one field that is REQUIRED by force is  postcode. It will be required, no matter what you do.

So, you only may add some CSS rules to hide these fields.

Edited by NestorAcevedo (see edit history)
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...