Skip to main content

Magento 2. : From where (PHP) is the checkout billing address options drop down being populated?

added 1590 characters in body; edited title
Source Link
vitoriodachef
  • 3.6k
  • 1
  • 23
  • 68

Magento 2. From where (PHP) is the checkout billing address options drop down being populated?

From where is the checkout billing address options drop down being populated? How can I control the options?

EDIT: Found root/vendor/magento/module-checkout/view/frontend/web/js/view/billing-address.js

   var lastSelectedBillingAddress = null,
        newAddressOption = {
            /**
             * Get new address label
             * @returns {String}
             */
            getAddressInline: function () {
                return $t('New Address');
            },
            customerAddressId: null
        },
        countryData = customerData.get('directory-data'),
        addressOptions = addressList().filter(function (address) {
            return address.getType() == 'customer-address'; //eslint-disable-line eqeqeq
        });

addressList then is 'Magento_Customer/js/model/address-list'

Found the template as well root/vendor/magento/module-checkout/view/frontend/web/template/billing-address/list.html

<div class="field field-select-billing">
    <label class="label"><span data-bind="i18n: 'My billing and shipping address are the same'"></span></label>
    <div class="control" data-bind="if: (addressOptions.length > 1)">
        <select class="select" name="billing_address_id" data-bind="
        options: addressOptions,
        optionsText: addressOptionsText,
        value: selectedAddress,
        event: {change: onAddressChange(selectedAddress())};
    "></select>
    </div>
</div>

This is database information so php has to bring it. Where in php are these values passed to knockout?

enter image description here

Magento 2. From where is the checkout billing address options drop down being populated?

From where is the checkout billing address options drop down being populated? How can I control the options?

enter image description here

Magento 2. From where (PHP) is the checkout billing address options drop down being populated?

From where is the checkout billing address options drop down being populated? How can I control the options?

EDIT: Found root/vendor/magento/module-checkout/view/frontend/web/js/view/billing-address.js

   var lastSelectedBillingAddress = null,
        newAddressOption = {
            /**
             * Get new address label
             * @returns {String}
             */
            getAddressInline: function () {
                return $t('New Address');
            },
            customerAddressId: null
        },
        countryData = customerData.get('directory-data'),
        addressOptions = addressList().filter(function (address) {
            return address.getType() == 'customer-address'; //eslint-disable-line eqeqeq
        });

addressList then is 'Magento_Customer/js/model/address-list'

Found the template as well root/vendor/magento/module-checkout/view/frontend/web/template/billing-address/list.html

<div class="field field-select-billing">
    <label class="label"><span data-bind="i18n: 'My billing and shipping address are the same'"></span></label>
    <div class="control" data-bind="if: (addressOptions.length > 1)">
        <select class="select" name="billing_address_id" data-bind="
        options: addressOptions,
        optionsText: addressOptionsText,
        value: selectedAddress,
        event: {change: onAddressChange(selectedAddress())};
    "></select>
    </div>
</div>

This is database information so php has to bring it. Where in php are these values passed to knockout?

enter image description here

Source Link
vitoriodachef
  • 3.6k
  • 1
  • 23
  • 68

Magento 2. From where is the checkout billing address options drop down being populated?

From where is the checkout billing address options drop down being populated? How can I control the options?

enter image description here