2

Want to add company name in shipping information in magento 2.3 version. On checkout page company name are not shown in shipping information section. enter image description here

2 Answers 2

3

For add field in shipping adress section, override vendor/magento/module-checkout/view/frontend/web/template/shipping-address/address-renderer/default.html

For override create requirejs-config.js at

app/code/Vendor/Module/view/frontend/requirejs-config.js

var config = {
    map: {
        '*': {
            'Magento_Checkout/template/shipping-address/address-renderer/default.html':
                'Vendor_Module/template/shipping-address/address-renderer/default.html',

            'Magento_Checkout/template/shipping-information/address-renderer/default.html':
                'Vendor_Module/template/shipping-information/address-renderer/default.html'
        }
    }
};

Now add <!-- ko text: address().company --><!-- /ko --> in overrided file where you want to display company field.

app/code/Vendor/Module/view/frontend/web/template/shipping-information/address-renderer/default.html


<div class="shipping-address-item" data-bind="css: isSelected() ? 'selected-item' : 'not-selected-item'">
    <!-- ko text: address().prefix --><!-- /ko --> <!-- ko text: address().firstname --><!-- /ko -->
    <!-- ko text: address().lastname --><!-- /ko --> <!-- ko text: address().suffix --><!-- /ko --><br/>
    <!-- ko text: address().street --><!-- /ko --><br/>
    <!-- ko text: address().company -->
    <!-- ko text: address().city --><!-- /ko -->, <!-- ko text: address().region --><!-- /ko --> <!-- ko text: address().postcode --><!-- /ko --><br/>
    <!-- ko text: getCountryName(address().countryId) --><!-- /ko --><br/>
    <!-- ko text: address().telephone --><!-- /ko --><br/>
    <!-- ko foreach: { data: address().customAttributes, as: 'element' } -->
        <!-- ko foreach: { data: Object.keys(element), as: 'attribute' } -->
            <!-- ko text: element[attribute].value --><!-- /ko -->
         <!-- /ko -->
    <!-- /ko -->
    <!-- ko if: (address().isEditable()) -->
    <button type="button"
            class="action edit-address-link"
            data-bind="click: editAddress, visible: address().isEditable()">
        <span data-bind="i18n: 'Edit'"></span>
    </button>
    <!-- /ko -->
    <button type="button" data-bind="click: selectAddress" class="action action-select-shipping-item">
        <span data-bind="i18n: 'Ship Here'"></span>
    </button>
</div>

Note: On Magento 2.3+ the template is slightly less complex you would just add this under the name line for both templates.

<text args="address().company"/><br/>
3
  • But in 2.3 version vendor/magento/module-checkout/view/frontend/web/template/shipping-address/address-renderer/default.html on this path i have not knockout code. code are change Jul 3, 2019 at 10:13
  • 1
    <text args="address().company"/> or <text args="address().companyname"/> Jul 3, 2019 at 10:17
  • its not working Jul 3, 2019 at 10:41
0

To add the company name on the shipping address and the side summary and the invoice address displayed on the payment page do the following:

You have to create a custom module in app/code/My/Module

see https://devdocs.magento.com/videos/fundamentals/create-a-new-module/

Then create in this module the file /app/code/My/Module/view/frontend/requirejs-config.js

var config = {
map: {
    '*': {
        'Magento_Checkout/template/billing-address/details.html':
            'My_Module/template/billing-address/details.html',

        'Magento_Checkout/template/shipping-address/address-renderer/default.html':
            'My_Module/template/shipping-address/address-renderer/default.html',

        'Magento_Checkout/template/shipping-information/address-renderer/default.html':
            'My_Module/template/shipping-information/address-renderer/default.html'
    }
}
};

Then in your custom theme folder copy the file from: /vendor/magento/module-checkout/view/frontend/web/template/billing-address/details.html

To: /app/design/frontend/Your/Theme/My_Module/web/template/billing-address/details.html

Change the file in the theme folder to add the company name.

add:

<if args="currentBillingAddress().company">
    <text args="currentBillingAddress().company"/><br/>
</if>

From: /vendor/magento/module-checkout/view/frontend/web/template/shipping-address/address-renderer/default.html

To: /app/design/frontend/Your/Theme/My_Module/web/template/shipping-address/address-renderer/default.html

add:

<if args="address().company">
    <text args="address().company"/><br/>
</if>

From: /vendor/magento/module-checkout/view/frontend/web/template/shipping-information/address-renderer/default.html

To: /app/design/frontend/Your/Theme/My_Module/web/template/shipping-information/address-renderer/default.html

add:

<if args="address().company">
    <text args="address().company"/><br/>
</if>

Then run setup:upgrade flush cache etc.

see also: How to display company name on checkout page in Magento 2.1?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.