SwissUpLabs Logo

Housenumber & remove text “Line 1”

This feature supported since v.1.12.0

  1. Create custom.js file in your active theme with following content:

    define([
        'Swissup_Firecheckout/js/utils/form-field/manager',
        'Swissup_Firecheckout/js/utils/form-field/classname',
        'mage/translate'
    ], function (manager, classname, $t) {
        'use strict';
    
        classname('.street', 'fc-col-12');
        classname('[name="street[0]"]', 'fc-col-8 fc-size-s:fc-col-6 fc-size-xs:fc-col-12');
        manager('[name="street[1]"]', {
            label: 'Housenumber',
            placeholder: 'Housenumber',
            classname: 'fc-col-4 fc-size-s:fc-col-6 fc-size-xs:fc-col-12',
            validator: {
                'lazy': true,
                'required': true,
                'fc-custom-rule-housenumber': {
                    handler: function (value) {
                        return new RegExp(/^\d+[a-zA-Z]?$/).test(value);
                    },
                    message: $t('Invalid housenumber. Valid examples: 42, 3A, 18C')
                }
            }
        });
    });
    
    define([
        'Swissup_Firecheckout/js/utils/form-field/manager',
        'mage/translate'
    ], function (manager, $t) {
        'use strict';
    
        // `Street Address: Line 1` - rename to `Street Address`
        manager('[name="street[0]"]', {
            label: $t('Street Address'),
            placeholder: $t('Street Address'),
        });
            
        // rename multiple Street Address fields
        var streetFields = {
           '[name="street[0]"]': 'Street Address 1', 
           '[name="street[1]"]': 'Street Address 2',
           '[name="street[2]"]': 'Street Address 3'
        };
      
        for (var key in streetFields) {         
            manager(key, {
                label: $t(streetFields[key]),
                placeholder: $t(streetFields[key]),
            });
        }  
    });
    
  2. Run “Deploy static content” command:

    cd <magento_root>
    
    # remove previously deployed firecheckout files
    find pub/static -type d -regex ".*Firecheckout.*js" -exec rm -rf {} \;
    
    # run deployment command
    bin/magento setup:static-content:deploy
    

Result

Housenumber

Next up
Edit this Page