Skip to content

Instantly share code, notes, and snippets.

@Preciousomonze
Last active October 25, 2023 11:15
Show Gist options
  • Select an option

  • Save Preciousomonze/03c54e7e0cc0e11ca709832bc757810b to your computer and use it in GitHub Desktop.

Select an option

Save Preciousomonze/03c54e7e0cc0e11ca709832bc757810b to your computer and use it in GitHub Desktop.

Revisions

  1. Preciousomonze revised this gist Sep 18, 2020. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions wc_pv_custom_filters.php
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    <?php
    /**
    * List of Phone Validator for WooCommerce custom Filters and how to use.
    *
  2. Preciousomonze revised this gist Sep 9, 2020. 1 changed file with 7 additions and 4 deletions.
    11 changes: 7 additions & 4 deletions wc_pv_custom_filters.php
    Original file line number Diff line number Diff line change
    @@ -46,10 +46,13 @@ function pekky_cx_default_country( $value ){
    * @since 1.2.0
    * @return array
    */
    function pekky_cx_allowed_countries( $countries ){
    $countries = array('Ng','gh');
    // Or add to allowed countries
    // $countries[] = 'ng'; πŸ’†πŸ½β€β™‚οΈπŸ¦œ
    function pekky_cx_allowed_countries( $countries ) {
    $countries = array( 'Ng', 'gh' );
    // Or add to allowed countries.
    // $countries[] = 'ng'; πŸ’†πŸ½β€β™‚οΈπŸ¦œ.

    // Or get all countries from woocommerce.
    // $countries = array_keys( WC()->countries->get_countries() );
    return $countries;
    }
    add_filter( 'wc_pv_allowed_countries', 'pekky_cx_allowed_countries' );
  3. Preciousomonze revised this gist Jul 31, 2020. 1 changed file with 16 additions and 3 deletions.
    19 changes: 16 additions & 3 deletions wc_pv_custom_filters.php
    Original file line number Diff line number Diff line change
    @@ -21,12 +21,12 @@
    *
    * Incase you do not want to use the WooCommerce store country as default
    *
    * @param string $value the country's abbr(case insensitive). e.g NG for Nigeria
    * @param string $value the country's abbr e.g NG for Nigeria
    * @since 1.2.0
    * @return bool
    */
    function pekky_cx_default_country( $value ){
    $value = 'ng'; // Nigeria πŸ‡³πŸ‡¬
    $value = 'es'; // Nigeria πŸ‡³πŸ‡¬
    return $value;
    }
    add_filter( 'wc_pv_set_default_country', 'pekky_cx_default_country' );
    @@ -42,7 +42,7 @@ function pekky_cx_default_country( $value ){
    /**
    * Allowed countries
    *
    * @param array $countries initials (case Insensitive)
    * @param array $countries initials
    * @since 1.2.0
    * @return array
    */
    @@ -53,3 +53,16 @@ function pekky_cx_allowed_countries( $countries ){
    return $countries;
    }
    add_filter( 'wc_pv_allowed_countries', 'pekky_cx_allowed_countries' );

    /**
    * Preferred countries
    *
    * @param array $countries initials
    * @since 1.3.0
    * @return array
    */
    function pekky_cx_preferred_countries( $countries ){
    $countries = array('ng','gh','es');
    return $countries;
    }
    add_filter( 'wc_pv_preferred_countries', 'pekky_cx_preferred_countries' );
  4. Preciousomonze created this gist Jul 29, 2020.
    55 changes: 55 additions & 0 deletions wc_pv_custom_filters.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,55 @@
    /**
    * List of Phone Validator for WooCommerce custom Filters and how to use.
    *
    * Please feel free to add more to this, and don't forget to add your name to contributors, if you want to.
    *
    * @author Precious Omonzejele (CodeXplorer πŸ€ΎπŸ½β€β™‚οΈπŸ₯žπŸ¦œπŸ€‘)
    * @contributors ...add name(s) here
    */


    /**
    * Separate dial code
    *
    * @since 1.2.0
    * @return bool
    */
    add_filter( 'wc_pv_separate_dial_code', '__return_true' );

    /**
    * Set Default Country
    *
    * Incase you do not want to use the WooCommerce store country as default
    *
    * @param string $value the country's abbr(case insensitive). e.g NG for Nigeria
    * @since 1.2.0
    * @return bool
    */
    function pekky_cx_default_country( $value ){
    $value = 'ng'; // Nigeria πŸ‡³πŸ‡¬
    return $value;
    }
    add_filter( 'wc_pv_set_default_country', 'pekky_cx_default_country' );

    /**
    * Use your WooCommerce store country as default
    *
    * @since 1.2.0
    * @return bool
    */
    add_filter( 'wc_pv_use_wc_default_store_country', '__return_true' );

    /**
    * Allowed countries
    *
    * @param array $countries initials (case Insensitive)
    * @since 1.2.0
    * @return array
    */
    function pekky_cx_allowed_countries( $countries ){
    $countries = array('Ng','gh');
    // Or add to allowed countries
    // $countries[] = 'ng'; πŸ’†πŸ½β€β™‚οΈπŸ¦œ
    return $countries;
    }
    add_filter( 'wc_pv_allowed_countries', 'pekky_cx_allowed_countries' );