1

I am new to Magento 2.
I have a website, in magento2 which offers some products to be add in cart.

On checkout page, I want to append country ISD code to mobile number textbox next to Country dropdown. For example, if user select Singapore as Country then +63 should be added to mobile number text box, so that user can add his/her mobile number.
So mobile number textbox can have text as +639988776655.

I can achieve this with jQuery, so kindly share where I can write this jquery stuff in magento2 for checkout page.

Any help would be great for me.
0

Magento 2 checkout is totally based on knockout js. Yes there are many ways in jQuery to fulfill your requirements but in magento 2 checkout page you can't do by using simply jQuery code. You have to use knockout js or else there are extensions available in market. You can use that and fulfill your requirements.

0

you can try this out
:-

Assuming you are using jQuery:

<select name="country" id="country">
        <option value="">Country...</option>
        <option value="966">Saudi Arabia</option>
    </select>
    
    
        $('#country').change(function () {
            var countryCode = $(this).val();
        
            if (countryCode) {
                $('#phone').val(countryCode);
            }
        });

based on your requirement you can customize it accordingly

1
  • Hi Chikku, my question was where to write this code magento file? – Amruta Ranade Jul 7 '20 at 9:36

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.