Install this package via composer:
composer require loki-checkout/magento2-quote-address-extendedNext, enable this module:
bin/magento module:enable Loki_QuoteAddressExtendedThis module adds a table loki_quote_address_extended with one row per quote address (quote_address_id). When the order is placed, each row is linked to the matching order address (order_address_id).
To store a custom value:
- Add a column to
loki_quote_address_extendedvia your ownetc/db_schema.xml(plusdb_schema_whitelist.json). - Add a field block to the Loki Checkout whose name ends with the column name (e.g.
loki-checkout.customer.example_address_field), using the templateLoki_FieldComponents::form/field.phtml. Optionally add the block arguments:address_type:shipping,billingorauto(default; the shipping address, or the billing address for virtual quotes);field_name: the column name, when it differs from the last part of the block name.
- Register the block in your
etc/loki_components.xmlwith the groupquoteAddressExtendedFields.
To display the value:
- Frontend (current quote):
Loki\QuoteAddressExtended\ViewModel\CheckoutQuoteAddressExtendedView::getValue('example_address_field', 'auto') - Admin order and invoice pages:
Loki\QuoteAddressExtended\ViewModel\Adminhtml\OrderAddressExtendedView::getValue('example_address_field', 'auto') - Order and invoice emails:
{{var loki_shipping_address_extended.example_address_field}}and{{var loki_billing_address_extended.example_address_field}}
Rows that are linked to neither a quote address nor an order address are removed by the cron job loki_quote_address_extended_delete_orphaned_rows.
See Loki_QuoteAddressExtendedExample for a complete example.