• Resolved Ammar Tello

    (@ammartello97)


    Hello,

    Your plugin was working well on my site, but for now, I don’t know what happened, until your country code didn’t show in telephone inputs anymore, as you can see in the screenshot below:

    https://prnt.sc/W480TQa9GNtl

    The page I need help with: [log in to see the link]

Viewing 10 replies - 1 through 10 (of 10 total)
  • Yes, facing same issue.
    https://prnt.sc/oPqSFmJtn-YE

    Thread Starter Ammar Tello

    (@ammartello97)

    @ghouri80 did you find any solution?

    @ammartello97
    Yes, the problem is solved. I was facing this issue on localhost. So when I tested it on the live site then no error showed in my case. Not figured out why getting the following warning on localhost.
    Warning: Undefined variable $initialCountry in?wp-content\plugins\international-telephone-input-with-flags-and-dial-codes\index.php?on line?139.
    Maybe due to some conflict.
    So disable all other plugins to find out which plugin causes conflict.
    So which form you are using?
    I am using the Ultimate member plugin form.

    Thread Starter Ammar Tello

    (@ammartello97)

    @ghouri80 Thank you for your reply.

    I tried to disable all other plugins, but the problem is still exist.

    I have used the Ultimate member plugin and WooCommerce (checkout form).

    @ammartello97
    I am also using the Ultimate member plugin.
    I found out why this issue was happening, which means why it shows this warning
    Warning: Undefined variable $initialCountry in wp-content\plugins\international-telephone-input-with-flags-and-dial-codes\index.php on line 139.
    and when I tested on another site then showed no error and worked fine.
    I found it is due to not disabling the debugging mode in the wp-config.php file.
    define(‘WP_DEBUG’, false);
    So when I disabled the debugging mode then no warning or notice showed and the issue was resolved.
    Hope this helps you.

    And I hope in the next update of this plugin, plugin developers will solve the following issue/warning.
    Warning: Undefined variable $initialCountry in?wp-content\plugins\international-telephone-input-with-flags-and-dial-codes\index.php?on line?139.

    Thread Starter Ammar Tello

    (@ammartello97)

    @ghouri80 Thank you for sharing the information.

    But I already have:

    define( ‘WP_DEBUG’, false );

    in my wp-config.php file

    although when I deactivated the ultimate member plugin, the problem still exists, I believe that the problem isn’t related to any other plugin.

    I am disappointed with the developers as, up to this point, they have yet to respond to this thread.

    • This reply was modified 9 months, 2 weeks ago by Ammar Tello.

    @ammartello97
    Ok, I saw the page in which you are facing this issue
    https://basbelarabi.com/checkout/?add-to-cart=50250&quantity=1
    and in the console, I found the same problem/warning there that I got on my end. So if all debugging mode is deactivated and still gets this issue then a temporary solution for this is until the developers fix this in the next update because this issue is on the plugin’s developer-end. So manually set that warning in an index.php in international-telephone-input-with-flags-and-dial-codes plugin file if you are familiar with the code. In the index.php find
    public function footer()” (find this on the 106 line) and replace that with this

    public function footer()
    {
        if ( isset( $this->options['enable'] ) && esc_attr( $this->options['enable'] ) == 'on' )
        {
            $excludeCountries = empty( $this->options['excludeCountries'] ) ? array() : $this->options['excludeCountries'];
    
            $preferredCountries = empty( $this->options['preferredCountries'] ) ? array() : $this->options['preferredCountries'];
    
            $onlyCountries = empty( $this->options['onlyCountries'] ) ? array() : $this->options['onlyCountries'];
    
       $initialCountry = ''; // Temporary fix
    
            if ( isset( $this->options['enable_geoip_loopup'] ) && $this->options['enable_geoip_loopup'] == 'on' )
            {
                require_once WPITFDC_ROOT_DIR . '/includes/vendor/autoload.php';
    
                // This creates the Reader object, 
                $reader = new Reader( WPITFDC_ROOT_DIR . '/assets/vendor/GeoLite2-Country/GeoLite2-Country.mmdb' );
    
                try
                {   
                    $VisitorGeo = $reader->country( $this->get_visitor_ip() );
    
                    $initialCountry = $VisitorGeo->country->isoCode;
                }
                catch ( Exception $e )
                {
                    $initialCountry = '';
                }
            }
    
            ?>
                <script type="text/javascript">
                    jQuery( document ).ready( function( $ )
                    {
                        let initialCountry = '<?= strtolower( $initialCountry ); ?>';
    
                        <?php
    
                            if ( isset( $this->options['enable_geoip_loopup_ajax'] ) && $this->options['enable_geoip_loopup_ajax'] == 'on' )
                            {
                                ?>
                                    $.get( "<?= admin_url( 'admin-ajax.php' ); ?>", { action: 'wpitfdc_get_visitor_country' }, function( data )
                                    {
                                        initialCountry = data;
    
                                        do_the_plugin_thing();
                                    } );
                                <?php
                            }
                            else
                            {
                                ?>
                                    do_the_plugin_thing();
                                <?php
                            }
                        ?>
    
                        function do_the_plugin_thing()
                        {
                            $( "input[type='tel']" ).each( function( index, el )
                            {
                                var name = ( typeof $( el ).attr( 'name' ) != 'undefined' && $( el ).attr( 'name' ) != '' ) ? $( el ).attr( 'name' ) : 'phoneNumber';
    
                                $( el ).removeAttr( 'name' );
    
                                var id = Date.now();
    
                                $( el ).after( '<input type="hidden" id="countryCode'+ id +'" name="'+ name +'" />' );
    
                                $( el ).intlTelInput(
                                {
                                    excludeCountries: <?= json_encode( $excludeCountries ); ?>,
                                    initialCountry: initialCountry,
                                    onlyCountries: <?= json_encode( $onlyCountries ); ?>,
                                    preferredCountries: <?= json_encode( $preferredCountries ); ?>,
                                    separateDialCode: true,
                                } );
    
                                setInterval( function()
                                {
                                    var newVal = $( "input#countryCode" + id ).prev( '.iti' ).find( '.iti__selected-dial-code' ).text() + $( el ).val();
    
                                    if ( newVal == $( "input#countryCode" + id ).val() )
                                    {
                                        return;
                                    }
    
                                    if ( $( el ).val() == '' )
                                    {
                                        newVal = '';
                                    }
    
                                    $( "input#countryCode" + id ).val( newVal );
    
                                }, 1000 );
                            } );
                        }
                    } );
                </script>
            <?php
        }
    }

    After that issue is resolved temporarily until developers fix that in their end in next update.

    Thread Starter Ammar Tello

    (@ammartello97)

    @ghouri80 Man, you are awesome!

    Thank you so much.

    It is working now ??

    @ammartello97
    You’re welcome! I’m glad to hear that it’s working now ??

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Country code didn’t show anymore’ is closed to new replies.