New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extra field hook added on customer address form #9132

Merged
merged 1 commit into from Nov 6, 2018

Conversation

Projects
None yet
7 participants
@PeeyushAgrawalWebkul
Contributor

PeeyushAgrawalWebkul commented May 28, 2018

Questions Answers
Branch? develop
Description? Please add a hook on customer address form to add a custom field through a module like as customer registration form and also manage the validation code for the corresponding fields because the existing hook ('actionValidateCustomerAddressForm') cannot be used as the form function is private.
Type? new feature
Category? CO
BC breaks? no
Deprecations? no
How to test? Try to add a custom field in address form through a module.

Important guidelines


This change is Reviewable

@prestonBot

This comment has been minimized.

Collaborator

prestonBot commented May 28, 2018

Hello @PeeyushAgrawalWebkul!

This is your first pull request on the PrestaShop project. Thank you, and welcome to this Open Source community!

@@ -146,6 +146,21 @@ public function getFormat()
$format[$formField->getName()] = $formField;
}
//To add the extra fields in address form
$additionalAddressFormFields = Hook::exec('additionalCustomerAddressFields', array(), null, true);

This comment has been minimized.

@mickaelandrieu

mickaelandrieu May 29, 2018

Contributor

what if 2 modules calls the same hook?

This comment has been minimized.

@PeeyushAgrawalWebkul

PeeyushAgrawalWebkul May 30, 2018

Contributor

@mickaelandrieu
If 2 modules call the same hook and try to add an extra field then the field from both module will be added.
Both modules will work without any confliction.
It will work as like as a hook on customer registration form(additionalCustomerFormFields).

@mickaelandrieu mickaelandrieu requested a review from Quetzacoalt91 May 30, 2018

@PierreRambaud

This comment has been minimized.

Contributor

PierreRambaud commented Jun 6, 2018

@mickaelandrieu waiting for QA feedback?

@kpodemski

This comment has been minimized.

Contributor

kpodemski commented Jun 6, 2018

ok, but what about validation? this is exampel of another Formatter and its solution:
https://github.com/PeeyushAgrawalWebkul/PrestaShop/blob/f870ec79d010f6f14aae1285b5541c944aa68f55/classes/form/CustomerForm.php#L234

@marionf

This comment has been minimized.

Contributor

marionf commented Jun 21, 2018

Hello @PeeyushAgrawalWebkul
Do you have a module adding a custom field in address ? It will allow us to do the regression tests
Thanks :)

@PeeyushAgrawalWebkul

This comment has been minimized.

Contributor

PeeyushAgrawalWebkul commented Jun 29, 2018

Hello @marionf
I requested because PrestaShop doesn't have any hook to add the extra field in customer address form and also we cannot override in the module that's why we can't create a module with this purpose. Right now we don't have any module which performs this operation. We can simply check by adding a hook in the file like as on customer registration form.

@marionf

This comment has been minimized.

Contributor

marionf commented Jun 29, 2018

@mickaelandrieu If you can provide a module it will be awesome to test :)

@rblaurin

This comment has been minimized.

rblaurin commented Jul 3, 2018

I am also needing it. I need to have some custom fields in address form, but I need to be able to determine its position at the form. I need to have 2 custom fields right after address1, before address2. It would be great if we could reach this using additionalCustomerAddressFields only. If I am understanding the solution proposed here, custom fields would always be shown after all the default fields, right? It would be nice if we could manage the position of custom fields at backoffice in the Country settings.

@mickaelandrieu mickaelandrieu added Feature and removed feature labels Jul 3, 2018

@PeeyushAgrawalWebkul

This comment has been minimized.

Contributor

PeeyushAgrawalWebkul commented Oct 26, 2018

Hello @marionf ,

The code failed on Codacy Quality review, But I don't think I need to fix this.

PrestaShop also has this code, I just added this here as the same feature, Check PrestaShop code:

$additionalCustomerFormFields = Hook::exec('additionalCustomerFormFields', array(), null, true);

Could you please let me know the status of this PR?

Thanks,

@marionf

This comment has been minimized.

Contributor

marionf commented Oct 26, 2018

Hello @PeeyushAgrawalWebkul

I am waiting for a module allowing me to test your PR, without this I can't test your PR and validate it

@PeeyushAgrawalWebkul

This comment has been minimized.

Contributor

PeeyushAgrawalWebkul commented Oct 26, 2018

Hello @marionf
Please find the test module link for this PR.
https://github.com/PeeyushAgrawalWebkul/Testing-module-PR-9132/tree/master

In this module, I have added the hook and in readme file also mentioned the code need to add in core files(as in PR).

Thanks

@marionf marionf self-assigned this Oct 26, 2018

@marionf marionf added QA ✔️ and removed waiting for QA labels Oct 29, 2018

@marionf marionf removed their assignment Oct 29, 2018

@PierreRambaud PierreRambaud merged commit 3b0ae04 into PrestaShop:develop Nov 6, 2018

1 of 2 checks passed

Codacy/PR Quality Review Not up to standards. This pull request quality could be better.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@PierreRambaud

This comment has been minimized.

Contributor

PierreRambaud commented Nov 6, 2018

@PierreRambaud PierreRambaud added this to the 1.7.6.0 milestone Nov 6, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment