Skip to content

How to add intlTelInput in Magento Checkout

International phone plugin : link

I added in my requirejsconfig.js

var config = {
    map: {
        '*': {
            customDisplayCheckout: 'Amasty_CheckoutCore/js/custom',
        },
        paths: {
            "intlTelInput": 'Amasty_CheckoutCore/js/intlTelInput',
            "intlTelInputUtils": 'Amasty_CheckoutCore/js/utils'
        },

        shim: {
            'intlTelInput': {
                'deps':['jquery', 'knockout']
            }
        }
    }

};

I also added files in specific folders, files loads (I can see it in network in chrome)

In my onepage.phtml

    require(['jquery', 'intlTelInput'], function($, intlTelInput) {
        
        $( document ).ready(function() {
                                    let input = $("[name='shippingAddress.telephone'] input")

                                    intlTelInput(input, {
                                        // any initialisation options go here
                                    });

        });
    });

This is what I receive in console :

Uncaught TypeError: intlTelInput is not a function