2017 © Pedro Peláez
 

magento2-module magento2-example-address-field-comment

Example module showing how to add custom fields to the checkout

image

yireo-training/magento2-example-address-field-comment

Example module showing how to add custom fields to the checkout

  • Thursday, July 5, 2018
  • by yireo-training
  • Repository
  • 1 Watchers
  • 3 Stars
  • 62 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 32 % Grown

The README.md

Yireo ExampleAddressFieldComment

This module integrates a new fields (comment) in various ways in the existing fieldsets of a shipment address. The comment field follows the pattern of a Custom Attribute (EAV value)., (*1)

  • Setup procedure
  • Shipment Address step in the checkout
  • Address form under the Customer Account

Installation

composer require yireo-training/magento2-example-address-field-comment:dev-master

Setup procedure

Through a file Setup/InstallData.php the field comment is added to the database, plus it is added to some forms in the backend. Right after this step, you can already enter and save values for this Custom Attribute comment in the backend., (*2)

Address form under the Customer Account

This is actually bad code: While the customer-entity can be cleanly extended using a form API, the address form is not easy to extend: Its fields are hard-coded in PHTML. Therefore, a plugin was created (etc/di.xml) to hack the new field comment (Block/Address/Edit/Field/Comment.php) into the right place., (*3)

The block-class calls for the comment value through the Custom Attribute code., (*4)

Shipment Address step in the checkout

The comment value is added automatically to the checkout, because it is a Custom Attribute. This method is the recommended approach for simple values., (*5)

The Versions

05/07 2018

dev-master

9999999-dev https://github.com/yireo-training

Example module showing how to add custom fields to the checkout

  Sources   Download

OSL-3.0

The Requires

  • php >=7.0.0
  • magento/framework ^100.1.0|^101.0.0

 

The Development Requires

by Jisse Reitsma (Yireo)

composer-installer magento