OpenMage / magento-lts

Official OpenMage LTS codebase | Migrate easily from Magento Community Edition in minutes! Download the source code for free or contribute to OpenMage LTS | Security vulnerability patches, bug fixes, performance improvements and more.
https://www.openmage.org
Open Software License 3.0
870 stars 436 forks source link

Turning Required Fields as Optional not working #1573

Closed LuizSantos1 closed 2 years ago

LuizSantos1 commented 3 years ago

Summary (*)

I have talked about this issue before so I thought it was a problem related only with the Moip One Step Checkout extension, which can be found here: https://github.com/elisei/moip-transparente-magento but I am also facing the same issue with IWD One Step Checkout (IWD Checkout Suite) which can be downloaded here: https://www.iwdagency.com/products/checkout-suite-m1

Examples (*)

The issue with Moip One Step Checkout It turns the field CPF (Tax VAT), Telephone and Date Of Birth as REQUIRED

The issue with IWD Checkout Suite It turns the field Telephone as required

Why turning off those fieds from "Required" to "Optional" is so important?

Here in Brazil, the new data protection law (LGPD) states that those fields while a customer is creating an account, MUST BE OPTIONAL and cannot be as REQUIRED anymore. I even got a strike from Google Merchant for that reason.

I have followed many tutorials on internet, Stack Over Flow and so on... Nothing works, I have even installed an extension called "Clarion Customer Attributes" https://github.com/r-martins/Clarion_Customeratributes That allow us to manage customer attributes from admin panel and turn off the "Required" option from "yes" to "no" but it did not work neither.

I have also used a SQL query to set Telephone field "is_Required" to "0" and still, it keeps asking for it. Which is quite annoying indeed.

Proposed solution

My suggestion would be creating an extension able to bypass the field validation even if it is empity. Let's say a code like if empty, then fill up that will with zeros or whatever other mock up info. Or simply ignore the validation altogether.

kiatng commented 3 years ago

Possible duplicate of issue #1547.

I am not suse if

it keeps asking for it

the it is javascript, but ref Moip One Step Checkout source code https://github.com/elisei/moip-transparente-magento/blob/141dfd0db95c2b106509d9461b6b26aec5b20fb0/app/design/frontend/base/default/template/MOIP/onestepcheckout/address/checkout/form.phtml#L34-L34:

<input type="tel" name="telephone" id="telephone" value="<?php echo $this->htmlEscape($this->getAddress()->getTelephone()) ?>" title="Telefone" class="form-control required-entry validate-tel-brazil" placeholder="Telefone">

You need to remove required-entry from the class for js to stop from validating requried-entry:

<input type="tel" name="telephone" id="telephone" value="<?php echo $this->htmlEscape($this->getAddress()->getTelephone()) ?>" title="Telefone" class="form-control validate-tel-brazil" placeholder="Telefone">

Disclaimer: I didn't check all the code.

LuizSantos1 commented 3 years ago

Possible duplicate of issue #1547.

I am not suse if

it keeps asking for it

the it is javascript, but ref Moip One Step Checkout source code https://github.com/elisei/moip-transparente-magento/blob/141dfd0db95c2b106509d9461b6b26aec5b20fb0/app/design/frontend/base/default/template/MOIP/onestepcheckout/address/checkout/form.phtml#L34-L34:

<input type="tel" name="telephone" id="telephone" value="<?php echo $this->htmlEscape($this->getAddress()->getTelephone()) ?>" title="Telefone" class="form-control required-entry validate-tel-brazil" placeholder="Telefone">

You need to remove required-entry from the class for js to stop from validating requried-entry:

<input type="tel" name="telephone" id="telephone" value="<?php echo $this->htmlEscape($this->getAddress()->getTelephone()) ?>" title="Telefone" class="form-control validate-tel-brazil" placeholder="Telefone">

Disclaimer: I didn't check all the code.

@kiatng That is not so simple. It will edit it, remove the asterix but it won't go any further on the next step of customer account creation Only way to really inspect it, is by installing and testing...

There are probaly php, phtml and even db codes involved. But thanks anyway...

kiatng commented 3 years ago

It will edit it, remove the asterix but it won't go any further on the next step of customer account creation

It seems that the error is thrown from the server (as opposed to from the js in the browser). The check on required attributes are done in various files depending on the attribute, for dob Date of Birth, it is happening in https://github.com/OpenMage/magento-lts/blob/8b0c0b9c9ec629826a19d1c07547e2a62b8a4fd7/app/code/core/Mage/Eav/Model/Attribute/Data/Date.php#L67-L69

The property is_required is primaryly retrieved from the database, in table eav_attribute, and customer_eav_attribute_website. You can check to make sure that is_required for dob is set to 0 in both tables. If it is 0, then it is very likely that the value is changed in custom code. If this is the case, you can try and look for it by searching for ->setIsRequired or ->setData('is_required' in your code base.

In any event, it doesn't seem to be an issue in OM core. Please close this issue if you agree.

LuizSantos1 commented 3 years ago

@kiatng Thanks, but I did not say it is a OM code issue, the only field which is required with OM is taxvat. The issues mentioned are coming from the OPC extensions...

fballiano commented 2 years ago

Closing since it's not a OM bug and it went silence since almost a year