• Resolved aizensoft

    (@aizensoft)


    Hello, how can I delete all countries from Vendor registration and profile and leave Just one?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hello @aizensoft ,

    Dokan uses WooCommrce’s country list so you can remove a specific country using this code –

    function woo_allow_specific_country( $country )  {
       unset($country['BD']);
       return $country; 
    }
    add_filter( 'woocommerce_countries', 'woo_allow_specific_country', 10, 1 );

    Here we can use another trick to remove all countries and allow only selected one by modifying the country array –

    function woo_allow_specific_country( $country )  {
       unset($country);
       $country = array(
            'BD' => __( 'Bangladesh', 'woocommerce' ),
        );
       return $country; 
    }
    add_filter( 'woocommerce_countries', 'woo_allow_specific_country', 10, 1 );

    You can use conditions and use this for specific page/user roles also.

    I hope this helps.

    Thank you.

    Thread Starter aizensoft

    (@aizensoft)

    But if I delete all countries in WooCommerce. The customers from other counties cant buy products. I need to allow one Country for Vendors and all countries for customers.

    • This reply was modified 4 years, 4 months ago by aizensoft.

    Hello @aizensoft ,

    If your plan is to limit the country only for the vendor dashboard settings page then use this code –

    function woo_allow_specific_country( $country )  {
    
        if(is_page('dashboard')) {
            unset($country);
            $country = array(
                 'BD' => __( 'Bangladesh', 'woocommerce' ),
             );
        }
    
       
       return $country; 
    }
    add_filter( 'woocommerce_countries', 'woo_allow_specific_country', 10, 1 );

    Customers country selection will not be affected by this.

    Thank you ??

    Thread Starter aizensoft

    (@aizensoft)

    Thank you I did, but how can I also limit country on Vendor setup wizard?

    Hello @aizensoft ,

    I have made some customization to the same code so that the code works on the set up wizard as well –

    function woo_allow_specific_country( $country )  {
    
        if( is_page('dashboard') || class_exists('WeDevs\Dokan\Vendor\SetupWizard')) {
            unset($country);
            $country = array(
                 'BD' => __( 'Bangladesh', 'woocommerce' ),
             );
        }
    
       
       return $country; 
    }
    
    add_action('init', function() {
        add_filter( 'woocommerce_countries', 'woo_allow_specific_country', 10, 1 );
    });

    If you need further customizations I think consulting with a professional developer will be a great option.

    Thank you ??

    Thread Starter aizensoft

    (@aizensoft)

    Thank you very much. Its work.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Dokan Vendor Registration Country’ is closed to new replies.