1

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

2 Answers 2

0

Issue solved

I forgot window

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

I also had another error:

getAttribute not found.

I had actually selected two inputs, so check that only one should be selected

1
  • This error occurs when you are in production mode with minify js enabled. I also have this error and am trying to fix it. Did you fix it?
    – GieDe
    Oct 2, 2023 at 23:32
0

If you have production mode and JavaScript minification enabled then your intlTelInput.js file is compressed and minified by Magento, such that the object keys are changed.

Go to the page source in your browser and open the intlTelInput.min.js file and compare it to the original intlTelInput.js file (without compression and minification).

I solved this problem by adding the .min prefix to the file name (intlTelInput.js -> intlTelInput.min.js) so that Magento thinks that this file is already compressed and minified and doesn't make changes.

Thumbs up if I have helped.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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