Add a new field in address form

5 novembre 2018 0 Par admin

Add custom shipping carrier and validations:

Add custom shipping carrier

Add custom shipping carrier validations

extends \Magento\Shipping\Model\Carrier\AbstractCarrier

Create validation rules. /web/js/model

implements

\Magento\Shipping\Model\Carrier\CarrierInterface

Create validator. web/js/model

Use public function collectRates ($result->append($method))

Register validator and rules in the validators pool. /web/js/view

Add the validators and rules to the checkout layout. /layout/checkout_index_index.xml

Add a new field in address form:

responsable for add new information into Magento_Checkout/ js / action / set-shipping- information, this component is responsible for data submission between shipping and billing checkout steps.

Mix in

Merge.. se mêler

required file:

Add a JS mixin to modify data submission

/js/action/set-shipping-information

Load your mixin

/view/frontend/requirejs-config.js

Add field to address model

/etc/extension_attributes.xml

Access the value of the custom field on server side

$value = $address->getExtensionAttributes()->getCustomField();

Add the field to layout

for the \Magento\Checkout\Block\Checkout\LayoutProcessor::process method.

Lors de l’ajout d’un champ au formulaire d’adresse de facturation, vous devez modifier le comportement de l’un des composants suivants: Magento_Checkout / js / action / place-order ou Magento_Checkout / js / action / set-payment-information, selon le moment où vous le souhaitez. besoin du champ personnalisé à transmettre au serveur. Par exemple, pour un mixin modifiant l’un de ces composants, voir le fichier place-order-mixin.js dans le module Magento_CheckoutAgreements.

Please follow and like us: