WC_Countries::get_allowed_countries PHP Метод

get_allowed_countries() публичный Метод

Get the allowed countries for the store.
public get_allowed_countries ( ) : array
Результат array
    public function get_allowed_countries()
    {
        if ('all' === get_option('woocommerce_allowed_countries')) {
            return $this->countries;
        }
        if ('all_except' === get_option('woocommerce_allowed_countries')) {
            $except_countries = get_option('woocommerce_all_except_countries', array());
            if (!$except_countries) {
                return $this->countries;
            } else {
                $all_except_countries = $this->countries;
                foreach ($except_countries as $country) {
                    unset($all_except_countries[$country]);
                }
                return apply_filters('woocommerce_countries_allowed_countries', $all_except_countries);
            }
        }
        $countries = array();
        $raw_countries = get_option('woocommerce_specific_allowed_countries', array());
        if ($raw_countries) {
            foreach ($raw_countries as $country) {
                $countries[$country] = $this->countries[$country];
            }
        }
        return apply_filters('woocommerce_countries_allowed_countries', $countries);
    }

Usage Example

Пример #1
0
<?php

/**
 * Shipping template
 *
 * @since  2.0
 */
$country_obj = new WC_Countries();
$countries = $country_obj->get_allowed_countries();
$states = $country_obj->states;
$user_id = get_current_user_id();
$processing_time = dokan_get_shipping_processing_times();
$dps_enable_shipping = true;
//TD - get_user_meta( $user_id, '_dps_shipping_enable', true );
$dps_shipping_type_price = get_user_meta($user_id, '_dps_shipping_type_price', true);
$dps_additional_product = get_user_meta($user_id, '_dps_additional_product', true);
$dps_additional_qty = get_user_meta($user_id, '_dps_additional_qty', true);
$dps_form_location = get_user_meta($user_id, '_dps_form_location', true);
$dps_country_rates = get_user_meta($user_id, '_dps_country_rates', true);
$dps_state_rates = get_user_meta($user_id, '_dps_state_rates', true);
$dps_pt = get_user_meta($user_id, '_dps_pt', true);
$dps_shipping_policy = get_user_meta($user_id, '_dps_ship_policy', true);
$dps_refund_policy = get_user_meta($user_id, '_dps_refund_policy', true);
?>

<form method="post" id="shipping-form"  action="" class="dokan-form-horizontal">

    <?php 
wp_nonce_field('dokan_shipping_form_field', 'dokan_shipping_form_field_nonce');
?>
All Usage Examples Of WC_Countries::get_allowed_countries