The WooCommerce countries class stores country/state data.
Author: WooThemes
コード例 #1
0
ファイル: wc-edostavka.php プロジェクト: kalbac/wc-edostavka
 public function admin_load_script($hook)
 {
     if ($hook !== 'woocommerce_page_wc-settings') {
         return;
     }
     wp_enqueue_script('edostavka-admin', plugins_url('/assets/js/admin.js', __FILE__), array('jquery'), self::VERSION, true);
     wp_localize_script('edostavka-admin', 'wc_params', array('default_country' => WC_Countries::get_base_country(), 'api_url' => $this->get_api_url()));
 }
コード例 #2
0
 /**
  * Register/queue frontend scripts.
  *
  * @access public
  * @return void
  */
 public function frontend_scripts()
 {
     global $post;
     $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
     $lightbox_en = get_option('woocommerce_enable_lightbox') == 'yes' ? true : false;
     $chosen_en = get_option('woocommerce_enable_chosen') == 'yes' ? true : false;
     $ajax_cart_en = get_option('woocommerce_enable_ajax_add_to_cart') == 'yes' ? true : false;
     $frontend_script_path = $this->plugin_url() . '/assets/js/frontend/';
     // Register any scripts for later use, or used as dependencies
     wp_register_script('chosen', $this->plugin_url() . '/assets/js/chosen/chosen.jquery' . $suffix . '.js', array('jquery'), '0.9.11', true);
     wp_register_script('jquery-blockui', $this->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array('jquery'), '2.60', true);
     wp_register_script('jquery-placeholder', $this->plugin_url() . '/assets/js/jquery-placeholder/jquery.placeholder' . $suffix . '.js', array('jquery'), $this->version, true);
     wp_register_script('wc-add-to-cart-variation', $frontend_script_path . 'add-to-cart-variation' . $suffix . '.js', array('jquery'), $this->version, true);
     wp_register_script('wc-single-product', $frontend_script_path . 'single-product' . $suffix . '.js', array('jquery'), $this->version, true);
     wp_register_script('jquery-cookie', $this->plugin_url() . '/assets/js/jquery-cookie/jquery.cookie' . $suffix . '.js', array('jquery'), '1.3.1', true);
     // Queue frontend scripts conditionally
     if ($ajax_cart_en) {
         wp_enqueue_script('wc-add-to-cart', $frontend_script_path . 'add-to-cart' . $suffix . '.js', array('jquery'), $this->version, true);
     }
     if (is_cart()) {
         wp_enqueue_script('wc-cart', $frontend_script_path . 'cart' . $suffix . '.js', array('jquery'), $this->version, true);
     }
     if (is_checkout()) {
         if ($chosen_en) {
             wp_enqueue_script('wc-chosen', $frontend_script_path . 'chosen-frontend' . $suffix . '.js', array('chosen'), $this->version, true);
             wp_enqueue_style('woocommerce_chosen_styles', $this->plugin_url() . '/assets/css/chosen.css');
         }
         wp_enqueue_script('wc-checkout', $frontend_script_path . 'checkout' . $suffix . '.js', array('jquery', 'woocommerce'), $this->version, true);
     }
     if ($lightbox_en && (is_product() || !empty($post->post_content) && strstr($post->post_content, '[product_page'))) {
         wp_enqueue_script('prettyPhoto', $this->plugin_url() . '/assets/js/prettyPhoto/jquery.prettyPhoto' . $suffix . '.js', array('jquery'), '3.1.5', true);
         wp_enqueue_script('prettyPhoto-init', $this->plugin_url() . '/assets/js/prettyPhoto/jquery.prettyPhoto.init' . $suffix . '.js', array('jquery'), $this->version, true);
         wp_enqueue_style('woocommerce_prettyPhoto_css', $this->plugin_url() . '/assets/css/prettyPhoto.css');
     }
     if (is_product()) {
         wp_enqueue_script('wc-single-product');
     }
     // Global frontend scripts
     wp_enqueue_script('woocommerce', $frontend_script_path . 'woocommerce' . $suffix . '.js', array('jquery', 'jquery-blockui'), $this->version, true);
     wp_enqueue_script('wc-cart-fragments', $frontend_script_path . 'cart-fragments' . $suffix . '.js', array('jquery', 'jquery-cookie'), $this->version, true);
     wp_enqueue_script('jquery-placeholder');
     // Variables for JS scripts
     $woocommerce_params = array('countries' => json_encode($this->countries->get_allowed_country_states()), 'plugin_url' => $this->plugin_url(), 'ajax_url' => $this->ajax_url(), 'ajax_loader_url' => apply_filters('woocommerce_ajax_loader_url', $this->plugin_url() . '/assets/images/ajax-loader@2x.gif'), 'i18n_select_state_text' => esc_attr__('Select an option…', 'woocommerce'), 'i18n_required_rating_text' => esc_attr__('Please select a rating', 'woocommerce'), 'i18n_no_matching_variations_text' => esc_attr__('Sorry, no products matched your selection. Please choose a different combination.', 'woocommerce'), 'i18n_required_text' => esc_attr__('required', 'woocommerce'), 'i18n_view_cart' => esc_attr__('View Cart →', 'woocommerce'), 'review_rating_required' => get_option('woocommerce_review_rating_required'), 'update_order_review_nonce' => wp_create_nonce("update-order-review"), 'apply_coupon_nonce' => wp_create_nonce("apply-coupon"), 'option_guest_checkout' => get_option('woocommerce_enable_guest_checkout'), 'checkout_url' => add_query_arg('action', 'woocommerce-checkout', $this->ajax_url()), 'is_checkout' => is_page(woocommerce_get_page_id('checkout')) ? 1 : 0, 'update_shipping_method_nonce' => wp_create_nonce("update-shipping-method"), 'cart_url' => get_permalink(woocommerce_get_page_id('cart')), 'cart_redirect_after_add' => get_option('woocommerce_cart_redirect_after_add'));
     if (is_checkout() || is_cart()) {
         $woocommerce_params['locale'] = json_encode($this->countries->get_country_locale());
     }
     wp_localize_script('woocommerce', 'woocommerce_params', apply_filters('woocommerce_params', $woocommerce_params));
     // CSS Styles
     if (!defined('WOOCOMMERCE_USE_CSS')) {
         define('WOOCOMMERCE_USE_CSS', get_option('woocommerce_frontend_css') == 'yes' ? true : false);
     }
     if (WOOCOMMERCE_USE_CSS) {
         $css = file_exists(get_stylesheet_directory() . '/woocommerce/style.css') ? get_stylesheet_directory_uri() . '/woocommerce/style.css' : $this->plugin_url() . '/assets/css/woocommerce.css';
         wp_enqueue_style('woocommerce_frontend_styles', $css);
     }
 }
コード例 #3
0
 /**
  * Register/queue frontend scripts.
  *
  * @access public
  * @return void
  */
 function frontend_scripts()
 {
     global $post;
     $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
     $lightbox_en = get_option('woocommerce_enable_lightbox') == 'yes' ? true : false;
     $chosen_en = get_option('woocommerce_enable_chosen') == 'yes' ? true : false;
     $frontend_script_path = $this->plugin_url() . '/assets/js/frontend/';
     // Register any scipts for later use, or used as dependencies
     wp_register_script('chosen', $this->plugin_url() . '/assets/js/chosen/chosen.jquery' . $suffix . '.js', array('jquery'), $this->version, true);
     wp_register_script('jquery-ui', $this->plugin_url() . '/assets/js/jquery-ui' . $suffix . '.js', array('jquery'), $this->version, true);
     wp_register_script('jquery-plugins', $this->plugin_url() . '/assets/js/jquery-plugins' . $suffix . '.js', array('jquery'), $this->version, true);
     wp_register_script('wc-add-to-cart-variation', $frontend_script_path . 'add-to-cart-variation' . $suffix . '.js', array('jquery'), $this->version, true);
     wp_register_script('wc-single-product', $frontend_script_path . 'single-product' . $suffix . '.js', array('jquery'), $this->version, true);
     // Queue frontend scripts conditionally
     if (get_option('woocommerce_enable_ajax_add_to_cart') == 'yes') {
         wp_enqueue_script('wc-add-to-cart', $frontend_script_path . 'add-to-cart' . $suffix . '.js', array('jquery'), $this->version, true);
     }
     if (is_cart()) {
         wp_enqueue_script('wc-cart', $frontend_script_path . 'cart' . $suffix . '.js', array('jquery'), $this->version, true);
     }
     if (is_checkout()) {
         wp_enqueue_script('wc-checkout', $frontend_script_path . 'checkout' . $suffix . '.js', array('jquery'), $this->version, true);
     }
     if (is_product()) {
         wp_enqueue_script('wc-single-product');
     }
     if ($lightbox_en && (is_product() || !empty($post->post_content) && strstr($post->post_content, '[product_page'))) {
         wp_enqueue_script('fancybox', $this->plugin_url() . '/assets/js/fancybox/fancybox' . $suffix . '.js', array('jquery'), $this->version, true);
         wp_enqueue_style('woocommerce_fancybox_styles', $this->plugin_url() . '/assets/css/fancybox.css');
     }
     if ($chosen_en && is_checkout()) {
         wp_enqueue_script('wc-chosen', $frontend_script_path . 'chosen-frontend' . $suffix . '.js', array('chosen'), $this->version, true);
         wp_enqueue_style('woocommerce_chosen_styles', $this->plugin_url() . '/assets/css/chosen.css');
     }
     // Global frontend scripts
     wp_enqueue_script('woocommerce', $frontend_script_path . 'woocommerce' . $suffix . '.js', array('jquery', 'jquery-plugins'), $this->version, true);
     // Variables for JS scripts
     $woocommerce_params = array('countries' => json_encode($this->countries->get_allowed_country_states()), 'select_state_text' => __('Select an option…', 'woocommerce'), 'plugin_url' => $this->plugin_url(), 'ajax_url' => $this->ajax_url(), 'ajax_loader_url' => apply_filters('woocommerce_ajax_loader_url', $this->plugin_url() . '/assets/images/ajax-loader.gif'), 'required_rating_text' => esc_attr__('Please select a rating', 'woocommerce'), 'review_rating_required' => get_option('woocommerce_review_rating_required'), 'required_text' => esc_attr__('required', 'woocommerce'), 'update_order_review_nonce' => wp_create_nonce("update-order-review"), 'apply_coupon_nonce' => wp_create_nonce("apply-coupon"), 'option_guest_checkout' => get_option('woocommerce_enable_guest_checkout'), 'checkout_url' => add_query_arg('action', 'woocommerce-checkout', $this->ajax_url()), 'is_checkout' => is_page(woocommerce_get_page_id('checkout')) ? 1 : 0, 'update_shipping_method_nonce' => wp_create_nonce("update-shipping-method"), 'add_to_cart_nonce' => wp_create_nonce("add-to-cart"));
     if (is_checkout() || is_cart()) {
         $woocommerce_params['locale'] = json_encode($this->countries->get_country_locale());
     }
     wp_localize_script('woocommerce', 'woocommerce_params', apply_filters('woocommerce_params', $woocommerce_params));
 }
コード例 #4
0
 public function __construct()
 {
     _deprecated_function('woocommerce_countries', '1.4', 'WC_Countries()');
     parent::__construct();
 }
コード例 #5
0
							<div class="field_block">
								<label><?php 
echo $zip;
?>
</label>
								<input type="text" name="billing_postcode" id="billing_postcode" value="<?php 
if (isset($customer)) {
    echo $customer['billing_postcode'];
}
?>
" tabindex="1" />
							</div>
							<div class="field_block">
								<?php 
global $woocommerce;
$countries_obj = new WC_Countries();
$countries = $countries_obj->__get('countries');
$default_country = $countries_obj->get_base_country();
$default_county_states = $countries_obj->get_states($default_country);
if (isset($customer['billing_state'])) {
    $default_state = $customer['billing_state'];
} else {
    $default_state = '';
}
woocommerce_form_field('billing_state', array('type' => 'select', 'class' => array('chzn-drop'), 'label' => $state, 'placeholder' => __('Select a State'), 'options' => $default_county_states, 'default' => $default_state));
?>
							</div>
							<div style="clear:both;"></div>
						</div>

						<div class="woocommerce" style="text-align:center;">
コード例 #6
0
    /**
     * Generate form
     * @param $order_id
     * @return string
     */
    function generate_pagantis_eom_form($order_id)
    {
        //Logs
        $this->log->add('pagantis', 'Acceso al pago con Paga+Tarde');
        $order = new WC_Order($order_id);
        //Total Amount
        $transaction_amount = number_format((double) $order->get_total(), 2, '.', '');
        $transaction_amount = str_replace('.', '', $transaction_amount);
        $transaction_amount = floatval($transaction_amount);
        // Product Description
        $products = WC()->cart->cart_contents;
        $i = 1;
        $products_form = "";
        $description = "";
        foreach ($products as $product) {
            $products_form .= "\r\n              <input name='items[" . $i . "][description]' type='hidden' value='" . $product['data']->post->post_title . ' (' . $product['quantity'] . ')' . "'>\r\n              <input name='items[" . $i . "][quantity]' type='hidden' value='" . $product['quantity'] . "'>\r\n              <input name='items[" . $i . "][amount]' type='hidden' value='" . $product['data']->price * $product['quantity'] . "'>\r\n              ";
            $description[] = $product['data']->post->post_title . ' (' . $product['quantity'] . ')';
            $i++;
        }
        $shipping = $order->get_items('shipping');
        foreach ($shipping as $shipping_method) {
            if ($shipping_method['cost'] > 0) {
                $products_form .= "\r\n                <input name='items[" . $i . "][description]' type='hidden' value='" . __('Gastos de envio', 'pagantis') . "'>\r\n                <input name='items[" . $i . "][quantity]' type='hidden' value='1'>\r\n                <input name='items[" . $i . "][amount]' type='hidden' value='" . $shipping_method['cost'] . "'>\r\n                ";
                $description[] = 'Gastos de envio';
                $i++;
            }
        }
        $this->ok_url = $this->get_return_url($order);
        $this->ko_url = htmlspecialchars_decode($order->get_cancel_order_url());
        $account_id = "";
        $dataToEncode = "";
        //Test Environment Selected
        if ($this->environment == self::TEST_ENVIRONMENT) {
            $this->key = $this->test_key;
            $dataToEncode = $this->test_key . $this->test_account . $order_id . $transaction_amount . $this->currency . $this->ok_url . $this->ko_url . $this->callback_url;
            $account_id = $this->test_account;
        } else {
            $this->key = $this->real_key;
            $dataToEncode = $this->real_key . $this->real_account . $order_id . $transaction_amount . $this->currency . $this->ok_url . $this->ko_url . $this->callback_url;
            $account_id = $this->real_account;
        }
        $signature = sha1($dataToEncode);
        $form_url = $this->paga_mastarde_url;
        $adressInfo = explode("/", $order->billing_city);
        $customer = new WC_Customer();
        $countries = new WC_Countries();
        $address = $customer->get_address() . " " . $customer->get_address_2();
        $city = $customer->get_city();
        $postcode = $customer->get_postcode();
        $states = $countries->get_states();
        $state = $states[$order->shipping_country][$customer->get_state()];
        //todo can include shipping information
        //Create Form
        $buyer_name = $order->billing_first_name . " " . $order->billing_last_name;
        $pagantis_form_fields = "\r\n            <input name='order_id' type='hidden' value='" . $order_id . "' />\r\n            <input name='amount' type='hidden' value='" . $transaction_amount . "' />\r\n            <input name='currency' type='hidden' value='" . $this->currency . "' />\r\n\r\n            <input name='ok_url' type='hidden' value='" . $this->ok_url . "' />\r\n            <input name='nok_url' type='hidden' value='" . $this->ko_url . "' />\r\n\r\n            <input name='locale' type='hidden' value='" . $this->lang . "' />\r\n\r\n            <input name='full_name' type='hidden' value='" . $buyer_name . "'>\r\n            <input name='email' type='hidden' value='" . $order->billing_email . "'>\r\n\r\n            " . $products_form . "\r\n\r\n            <!-- firma de la operación -->\r\n            <input name='account_id' type='hidden' value='" . $account_id . "' />\r\n            <input name='signature' type='hidden' value='" . $signature . "' />\r\n\r\n            <!-- discount -->\r\n            <input name='iframe' type='hidden' value='" . $this->iframe . "' />\r\n\r\n            <!-- callback url -->\r\n            <input name='callback_url' type='hidden' value='" . $this->callback_url . "' />\r\n\r\n            <input name='description' type='hidden' value='" . implode(',', $description) . "' />\r\n\r\n            <!-- address -->\r\n            <input name='address[street]' type='hidden' value='" . $address . "'>\r\n            <input name='address[city]' type='hidden' value='" . $city . "'>\r\n            <input name='address[province]' type='hidden' value='" . $state . "'>\r\n            <input name='address[zipcode]' type='hidden' value='" . $postcode . "'>\r\n\r\n            <!-- eom -->\r\n            <input name='end_of_month' type='hidden' value='true'>\r\n            <!-- phone -->\r\n\r\n            <input name='phone' type='hidden' value='" . $order->billing_phone . "'>\r\n            ";
        $return_form = '<form action="' . $form_url . '" method="post" id="pagantis_payment_form">
            ' . $pagantis_form_fields . '
            <a class="button cancel floatLeft" href="' . $order->get_cancel_order_url() . '">' . __('Cancelar Pedido', 'pagantis') . '</a>
            <input type="submit" class="button-alt" id="submit_vme_payment_form" value="' . __('Realizar el pago', 'pagantis') . '" />

            </form>';
        if ($this->iframe == 'true') {
            $return_form .= "<script type='text/javascript'>\r\n\r\n            jQuery(document).ready(function() {\r\n              if (jQuery.isFunction(jQuery.fancybox) ){\r\n                 jQuery('#submit_vme_payment_form').on('click', function (e) {\r\n                  e.preventDefault(); // avoids calling success.php from the link\r\n                  //post data to get form url.\r\n                  jQuery.ajax({\r\n                    type: 'POST',\r\n                    url: '" . get_site_url() . "/wp-content/plugins/pagamastarde-payment-gateway-for-woocommerce/getPmtUrl.php',\r\n                    data: jQuery('#pagantis_payment_form').serialize(),\r\n                    success: function(data, textStatus, jqXHR)\r\n                    {\r\n                      jQuery.fancybox({\r\n                        // fancybox API options\r\n                        type: 'iframe',\r\n                        fitToView: false,\r\n                        openEffect: 'none',\r\n                        closeEffect: 'none',\r\n                        'width'  : 920,\r\n                        'minHeight' : 230,\r\n                        'href': data\r\n                      }); // fancybox\r\n                    }\r\n                  });\r\n                }); // on\r\n              }\r\n            }); //ready\r\n\r\n            </script>";
        }
        return $return_form;
    }
コード例 #7
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');
?>
コード例 #8
0
	public function get_shipping_address( $order ) {
		$countries = new WC_Countries();

		$name =  $order->shipping_first_name . ' ' . $order->shipping_last_name ;
		$domestic = in_array( $order->shipping_country, $this->domestic );
		$postcode = $domestic ? trim( str_replace( ' - ' , '' , $order->shipping_postcode ) ) : '';
		
		$request  = 
			"<ShipTo>
				<CompanyName>$name</CompanyName>
				<Address>
					 <AddressLine1>$order->shipping_address_1</AddressLine1>";
		if( !empty( $order->shipping_address_2 ) ) 
		$request .=	"<AddressLine2>$order->shipping_address_2</AddressLine2>";
		$request .=	"<City>$order->shipping_city</City>";	
						
		
		$state = ! $domestic && $order->shipping_country == 'CA' ? substr( $order->shipping_state, 5 ) : strlen( $order->shipping_state ) > 2 ? array_search( ucwords( strtolower( $order->shipping_state ) ), $countries->get_states( $order->shipping_country ) ) : $order->shipping_state;
				
		if( isset( $state ) ) 
			$request .= "<StateProvinceCode>$state</StateProvinceCode>";
		if( $domestic && isset( $postcode ) ) 
			$request .="<PostalCode>$postcode</PostalCode>";
			$request .="<CountryCode>$order->shipping_country</CountryCode>			
				</Address>
				<PhoneNumber>$order->billing_phone</PhoneNumber>
				<AttentionName>$name</AttentionName>
			</ShipTo>";
			
		return $request;
	}
コード例 #9
0
 /**
  * init_form_fields function.
  *
  * @access public
  * @return void
  */
 public function init_form_fields()
 {
     global $woocommerce;
     $this->form_fields = array('enabled' => array('title' => __('Enable/Disable', 'wc_ups'), 'type' => 'checkbox', 'label' => __('Enable this shipping method', 'wc_ups'), 'default' => 'no'), 'title' => array('title' => __('Method Title', 'wc_ups'), 'type' => 'text', 'description' => __('This controls the title which the user sees during checkout.', 'wc_ups'), 'default' => __('UPS', 'wc_ups')), 'availability' => array('title' => __('Method Availability', 'wc_ups'), 'type' => 'select', 'default' => 'all', 'class' => 'availability', 'options' => array('all' => __('All Countries', 'wc_ups'), 'specific' => __('Specific Countries', 'wc_ups'))), 'countries' => array('title' => __('Specific Countries', 'wc_ups'), 'type' => 'multiselect', 'class' => 'chosen_select', 'css' => 'width: 450px;', 'default' => '', 'options' => $woocommerce->countries->get_allowed_countries()), 'api' => array('title' => __('API Settings', 'wc_ups'), 'type' => 'title', 'description' => __('You need to obtain UPS account credentials by registering on via their website.', 'wc_ups')), 'user_id' => array('title' => __('UPS User ID', 'wc_ups'), 'type' => 'text', 'description' => __('Obtained from UPS after getting an account.', 'wc_ups'), 'default' => ''), 'password' => array('title' => __('UPS Password', 'wc_ups'), 'type' => 'text', 'description' => __('Obtained from UPS after getting an account.', 'wc_ups'), 'default' => ''), 'access_key' => array('title' => __('UPS Access Key', 'wc_ups'), 'type' => 'text', 'description' => __('Obtained from UPS after getting an account.', 'wc_ups'), 'default' => ''), 'shipper_number' => array('title' => __('UPS Shipper Number', 'wc_ups'), 'type' => 'text', 'description' => __('Obtained from UPS after getting an account.', 'wc_ups'), 'default' => ''), 'origin_postcode' => array('title' => __('Origin Postcode', 'wc_ups'), 'type' => 'text', 'description' => __('Enter the zip/postcode for the <strong>sender</strong>.', 'wc_ups'), 'default' => ''), 'origin_country' => array('title' => __('Origin Country', 'wc_ups'), 'type' => 'select', 'class' => 'chosen_select', 'css' => 'width: 250px;', 'description' => __('Enter the country for the <strong>sender</strong>.', 'wc_ups'), 'default' => WC_Countries::get_base_country(), 'options' => $woocommerce->countries->get_allowed_countries()), 'negotiated' => array('title' => __('Negotiated Rates', 'wc_ups'), 'label' => __('Enable negotiated rates', 'wc_ups'), 'type' => 'checkbox', 'default' => 'no', 'description' => __('Enable this if this shipping account has negotiated rates available.', 'wc_ups')), 'debug' => array('title' => __('Debug Mode', 'wc_ups'), 'label' => __('Enable debug mode', 'wc_ups'), 'type' => 'checkbox', 'default' => 'yes', 'description' => __('Enable debug mode to show debugging information on your cart/checkout.', 'wc_ups')), 'pickup_destination' => array('title' => __('Pickup and Destination', 'wc_ups'), 'type' => 'title', 'description' => ''), 'pickup' => array('title' => __('Pickup', 'wc_ups'), 'type' => 'select', 'css' => 'width: 250px;', 'class' => 'chosen_select', 'default' => '01', 'options' => $this->pickup_code), 'residential' => array('title' => __('Residential', 'wc_ups'), 'label' => __('Enable residential address flag', 'wc_ups'), 'type' => 'checkbox', 'default' => 'no', 'description' => __('Enable this to indicate to UPS that the receiver is a residential address.', 'wc_ups')), 'services_packaging' => array('title' => __('Services and Packaging', 'wc_ups'), 'type' => 'title', 'description' => ''), 'services' => array('type' => 'services'), 'offer_rates' => array('title' => __('Offer Rates', 'wc_ups'), 'type' => 'select', 'description' => '', 'default' => 'all', 'options' => array('all' => __('Offer the customer all returned rates', 'wc_ups'), 'cheapest' => __('Offer the customer the cheapest rate only', 'wc_ups'))), 'fallback' => array('title' => __('Fallback', 'wc_ups'), 'type' => 'text', 'description' => __('If UPS returns no matching rates, offer this amount for shipping so that the user can still checkout. Leave blank to disable.', 'wc_ups'), 'default' => ''), 'packing_method' => array('title' => __('Parcel Packing Method', 'wc_ups'), 'type' => 'select', 'default' => '', 'class' => 'packing_method', 'options' => array('per_item' => __('Default: Pack items individually', 'wc_ups'), 'box_packing' => __('Recommended: Pack into boxes with weights and dimensions', 'wc_ups'))), 'ups_packaging' => array('title' => __('UPS Packaging', 'wc_ups'), 'type' => 'multiselect', 'description' => __('Select UPS standard packaging options to enable', 'wc_ups'), 'default' => array(), 'css' => 'width: 150px; height: 115px', 'class' => 'ups_packaging', 'options' => $this->packaging_select), 'boxes' => array('type' => 'box_packing'));
 }
コード例 #10
0
ファイル: functions.php プロジェクト: CPHollister/shyftmodels
/**
 * Generate Address string | array for given seller id or current user
 *
 * @since 2.3
 *
 * @param int seller_id, defaults to current_user_id
 * @param boolean get_array, if true returns array instead of string
 *
 * @return String|array Address | array Address
 */
function dokan_get_seller_address($seller_id = '', $get_array = false)
{
    if ($seller_id == '') {
        $seller_id = get_current_user_id();
    }
    $profile_info = dokan_get_store_info($seller_id);
    if (isset($profile_info['address'])) {
        $address = $profile_info['address'];
        $country_obj = new WC_Countries();
        $countries = $country_obj->countries;
        $states = $country_obj->states;
        $street_1 = isset($address['street_1']) ? $address['street_1'] : '';
        $street_2 = isset($address['street_2']) ? $address['street_2'] : '';
        $city = isset($address['city']) ? $address['city'] : '';
        $zip = isset($address['zip']) ? $address['zip'] : '';
        $country_code = isset($address['country']) ? $address['country'] : '';
        $state_code = isset($address['state']) ? $address['state'] : '';
        $state_code = $address['state'] == 'N/A' ? '' : $address['state'];
        $country_name = isset($countries[$country_code]) ? $countries[$country_code] : '';
        $state_name = isset($states[$country_code][$state_code]) ? $states[$country_code][$state_code] : $state_code;
    } else {
        return 'N/A';
    }
    if ($get_array == TRUE) {
        $address = array('street_1' => $street_1, 'street_2' => $street_2, 'city' => $city, 'zip' => $zip, 'country' => $country_name, 'state' => isset($states[$country_code][$state_code]) ? $states[$country_code][$state_code] : $state_code);
        return $address;
    }
    $country = new WC_Countries();
    $formatted_address = $country->get_formatted_address(array('address_1' => $street_1, 'address_2' => $street_2, 'city' => $city, 'postcode' => $zip, 'state' => $state_code, 'country' => $country_code));
    return apply_filters('dokan_get_seller_address', $formatted_address, $profile_info);
}
コード例 #11
0
      <tr valign="top" class="campo_envio">
        <th scope="row" class="titledesc"> <label for="apg_sms_settings[campo_envio]">
            <?php 
_e('Shipping mobile field:', 'apg_sms');
?>
          </label>
          <span class="woocommerce-help-tip" data-tip="<?php 
_e('Select the shipping mobile field', 'apg_sms');
?>
"></span> </th>
        <td class="forminp forminp-number"><select id="apg_sms_settings[campo_envio]" name="apg_sms_settings[campo_envio]" class="wc-enhanced-select" tabindex="<?php 
echo $tab++;
?>
">
        <?php 
$pais = new WC_Countries();
$campos = $pais->get_address_fields($pais->get_base_country(), 'shipping_');
//Campos ordinarios
$campos_personalizados = apply_filters('woocommerce_checkout_fields', array());
if (isset($campos_personalizados['shipping'])) {
    $campos += $campos_personalizados['shipping'];
}
foreach ($campos as $valor => $campo) {
    $chequea = isset($configuracion['campo_envio']) && $configuracion['campo_envio'] == $valor ? ' selected="selected"' : '';
    if (isset($campo['label'])) {
        echo '<option value="' . $valor . '"' . $chequea . '>' . $campo['label'] . '</option>' . PHP_EOL;
    }
}
?>
        </select></td>
      </tr>
コード例 #12
0
 function init_address_fields($b_country = '', $s_country = '', $show_country = true)
 {
     $this->billing_fields = apply_filters('woocommerce_admin_billing_fields', array('first_name' => array('label' => __('First Name', 'woocommerce'), 'show' => false), 'last_name' => array('label' => __('Last Name', 'woocommerce'), 'show' => false), 'company' => array('label' => __('Company', 'woocommerce'), 'show' => false), 'address_1' => array('label' => __('Address 1', 'woocommerce'), 'show' => false), 'address_2' => array('label' => __('Address 2', 'woocommerce'), 'show' => false), 'city' => array('label' => __('City', 'woocommerce'), 'show' => false), 'postcode' => array('label' => __('Postcode', 'woocommerce'), 'show' => false), 'country' => array('label' => __('Country', 'woocommerce'), 'show' => false, 'class' => 'js_field-country select short', 'type' => 'select', 'options' => array('' => __('Select a country&hellip;', 'woocommerce')) + WC()->countries->get_allowed_countries()), 'state' => array('label' => __('State/County', 'woocommerce'), 'class' => 'js_field-state select short', 'show' => false), 'email' => array('label' => __('Email', 'woocommerce')), 'phone' => array('label' => __('Phone', 'woocommerce'))));
     $this->shipping_fields = apply_filters('woocommerce_admin_shipping_fields', array('first_name' => array('label' => __('First Name', 'woocommerce'), 'show' => false), 'last_name' => array('label' => __('Last Name', 'woocommerce'), 'show' => false), 'company' => array('label' => __('Company', 'woocommerce'), 'show' => false), 'address_1' => array('label' => __('Address 1', 'woocommerce'), 'show' => false), 'address_2' => array('label' => __('Address 2', 'woocommerce'), 'show' => false), 'city' => array('label' => __('City', 'woocommerce'), 'show' => false), 'postcode' => array('label' => __('Postcode', 'woocommerce'), 'show' => false), 'country' => array('label' => __('Country', 'woocommerce'), 'show' => false, 'type' => 'select', 'class' => 'js_field-country select short', 'options' => array('' => __('Select a country&hellip;', 'woocommerce')) + WC()->countries->get_shipping_countries()), 'state' => array('label' => __('State/County', 'woocommerce'), 'class' => 'js_field-state select short', 'show' => false)));
     if (!empty($b_country) || !empty($s_country)) {
         $countries = new WC_Countries();
         $locale = $countries->get_country_locale();
         $state_arr = WC()->countries->get_allowed_country_states();
     }
     if (!empty($b_country)) {
         if (isset($locale[$b_country])) {
             $this->billing_fields = wc_array_overlay($this->billing_fields, $locale[$b_country]);
             // If default country has postcode_before_city switch the fields round.
             // This is only done at this point, not if country changes on checkout.
             if (isset($locale[$b_country]['postcode_before_city'])) {
                 if (isset($this->billing_fields['postcode'])) {
                     $this->billing_fields['postcode']['class'] = array('form-row-wide', 'address-field');
                     $switch_fields = array();
                     foreach ($this->billing_fields as $key => $value) {
                         if ($key == 'city') {
                             // Place postcode before city
                             $switch_fields['postcode'] = '';
                         }
                         $switch_fields[$key] = $value;
                     }
                     $this->billing_fields = $switch_fields;
                 }
             }
             if (isset($state_arr[$b_country]) && !empty($state_arr[$b_country])) {
                 $this->billing_fields['state']['type'] = 'select';
                 $this->billing_fields['state']['class'] = array('form-row-left', 'address-field', 'chosen_select');
                 $this->billing_fields['state']['options'] = $state_arr[$b_country];
             }
         }
     }
     if (!empty($s_country)) {
         if (isset($locale[$s_country])) {
             $this->shipping_fields = wc_array_overlay($this->shipping_fields, $locale[$s_country]);
             // If default country has postcode_before_city switch the fields round.
             // This is only done at this point, not if country changes on checkout.
             if (isset($locale[$s_country]['postcode_before_city'])) {
                 if (isset($this->shipping_fields['postcode'])) {
                     $this->shipping_fields['postcode']['class'] = array('form-row-wide', 'address-field');
                     $switch_fields = array();
                     foreach ($this->shipping_fields as $key => $value) {
                         if ($key == 'city') {
                             // Place postcode before city
                             $switch_fields['postcode'] = '';
                         }
                         $switch_fields[$key] = $value;
                     }
                     $this->shipping_fields = $switch_fields;
                 }
             }
             if (isset($state_arr[$s_country]) && !empty($state_arr[$s_country])) {
                 $this->shipping_fields['state']['type'] = 'select';
                 $this->shipping_fields['state']['class'] = array('form-row-left', 'address-field', 'chosen_select');
                 $this->shipping_fields['state']['options'] = $state_arr[$b_country];
             }
         }
     }
 }
コード例 #13
0
            /**
             * Generate form
             * @param $order_id
             * @return string
             */
            function generate_pagantis_form($order_id)
            {
                //Logs
                $this->log->add('pagantis', 'Acceso al pago con Paga+Tarde');
                $order = new WC_Order($order_id);
                //Total Amount
                $transaction_amount = number_format((double) $order->get_total(), 2, '.', '');
                $transaction_amount = str_replace('.', '', $transaction_amount);
                $transaction_amount = floatval($transaction_amount);
                // Product Description
                $products = WC()->cart->cart_contents;
                $i = 1;
                $products_form = "";
                $description = "";
                foreach ($products as $product) {
                    $products_form .= "\r\n                  <input name='items[" . $i . "][description]' type='hidden' value='" . $product['data']->post->post_title . ' (' . $product['quantity'] . ')' . "'>\r\n                  <input name='items[" . $i . "][quantity]' type='hidden' value='" . $product['quantity'] . "'>\r\n                  <input name='items[" . $i . "][amount]' type='hidden' value='" . round(($product['data']->price + $product['line_tax']) * $product['quantity'], 2) . "'>\r\n                  ";
                    $description[] = $product['data']->post->post_title . ' (' . $product['quantity'] . ')';
                    $i++;
                }
                $shipping = $order->get_items('shipping');
                foreach ($shipping as $shipping_method) {
                    if ($shipping_method['cost'] > 0) {
                        $products_form .= "\r\n                    <input name='items[" . $i . "][description]' type='hidden' value='" . __('Gastos de envio', 'pagantis') . "'>\r\n                    <input name='items[" . $i . "][quantity]' type='hidden' value='1'>\r\n                    <input name='items[" . $i . "][amount]' type='hidden' value='" . $shipping_method['cost'] . "'>\r\n                    ";
                        $description[] = 'Gastos de envio';
                        $i++;
                    }
                }
                $account_id = "";
                $dataToEncode = "";
                $this->ok_url = $this->get_return_url($order);
                $this->ko_url = htmlspecialchars_decode(WC_Cart::get_checkout_url());
                $this->cancelled_url = htmlspecialchars_decode(WC_Cart::get_checkout_url());
                //Test Environment Selected
                if ($this->environment == self::TEST_ENVIRONMENT) {
                    $this->key = $this->test_key;
                    $dataToEncode = $this->test_key . $this->test_account . $order_id . $transaction_amount . $this->currency . $this->ok_url . $this->ko_url . $this->callback_url . $this->discount . $this->cancelled_url;
                    $account_id = $this->test_account;
                } else {
                    $this->key = $this->real_key;
                    $dataToEncode = $this->real_key . $this->real_account . $order_id . $transaction_amount . $this->currency . $this->ok_url . $this->ko_url . $this->callback_url . $this->discount . $this->cancelled_url;
                    $account_id = $this->real_account;
                }
                $signature = hash('sha512', $dataToEncode);
                $form_url = $this->paga_mastarde_url;
                $adressInfo = explode("/", $order->billing_city);
                $customer = new WC_Customer();
                $countries = new WC_Countries();
                $address = $customer->get_address() . " " . $customer->get_address_2();
                $city = $customer->get_city();
                $postcode = $customer->get_postcode();
                $states = $countries->get_states();
                $state = $states[$order->shipping_country][$customer->get_state()];
                $saddress = $customer->shipping_address_1 . " " . $customer->shipping_address_2;
                $scity = $customer->shipping_city;
                $spostcode = $customer->shipping_postcode;
                $sstate = $states[$order->shipping_country][$customer->shipping_state];
                //Create Form
                $buyer_name = $order->billing_first_name . " " . $order->billing_last_name;
                $pagantis_form_fields = "\r\n                <input name='order_id' type='hidden' value='" . $order_id . "' />\r\n                <input name='amount' type='hidden' value='" . $transaction_amount . "' />\r\n                <input name='currency' type='hidden' value='" . $this->currency . "' />\r\n\r\n                <input name='ok_url' type='hidden' value='" . $this->ok_url . "' />\r\n                <input name='nok_url' type='hidden' value='" . $this->ko_url . "' />\r\n                <input name='cancelled_url' type='hidden' value='" . $this->cancelled_url . "' />\r\n\r\n                <input name='locale' type='hidden' value='" . $this->lang . "' />\r\n\r\n                <input name='full_name' type='hidden' value='" . $buyer_name . "'>\r\n                <input name='email' type='hidden' value='" . $order->billing_email . "'>\r\n\r\n                " . $products_form . "\r\n\r\n                <!-- firma de la operación -->\r\n                <input name='account_id' type='hidden' value='" . $account_id . "' />\r\n                <input name='signature' type='hidden' value='" . $signature . "' />\r\n\r\n                <!-- discount -->\r\n                <input name='discount[full]' type='hidden' value='" . $this->discount . "' />\r\n                <input name='iframe' type='hidden' value='" . $this->iframe . "' />\r\n\r\n                <!-- callback url -->\r\n                <input name='callback_url' type='hidden' value='" . $this->callback_url . "' />\r\n\r\n                <input name='description' type='hidden' value='" . implode(',', $description) . "' />\r\n\r\n                <!-- address -->\r\n                <input name='address[street]' type='hidden' value='" . $address . "'>\r\n                <input name='address[city]' type='hidden' value='" . $city . "'>\r\n                <input name='address[province]' type='hidden' value='" . $state . "'>\r\n                <input name='address[zipcode]' type='hidden' value='" . $postcode . "'>\r\n\r\n                <input name='shipping[street]' type='hidden' value='" . $saddress . "'>\r\n                <input name='shipping[city]' type='hidden' value='" . $scity . "'>\r\n                <input name='shipping[province]' type='hidden' value='" . $sstate . "'>\r\n                <input name='shipping[zipcode]' type='hidden' value='" . $spostcode . "'>\r\n\r\n                <!-- phone -->\r\n\r\n                <input name='mobile_phone' type='hidden' value='" . $order->billing_phone . "'>\r\n                ";
                $return_form = '<form action="' . $form_url . '" method="post" id="pagantis_payment_form">
                ' . $pagantis_form_fields . '
                <input type="submit" class="button-alt" id="submit_vme_payment_form" value="' . __('Realizar el pago', 'pagantis') . '" />

                </form>';
                if ($this->iframe == 'true') {
                    wp_enqueue_style('style', esc_url(plugins_url('pages/assets/css/iframe.css', __FILE__)));
                    $return_form .= '<div id="myModal" class="paylater_modal">
                    <!-- Modal content -->
                    <div class="paylater_modal-content">
                      <span id="paylater_close">x</span>
                      <iframe id="iframe-pagantis" name="iframe-pagantis" style="width:100%;height:600px;display:block"></iframe>
                    </div>
                  </div>';
                    $return_form .= '<script type="text/javascript">
                  el = document.getElementById("submit_vme_payment_form");
                  el.addEventListener("click", function (e){
                    e.preventDefault();
                    document.getElementById("pagantis_payment_form").setAttribute("target", "iframe-pagantis");
                    document.getElementById("pagantis_payment_form").submit();
                    document.getElementById("iframe-pagantis").style.display = "block";
                    document.getElementById("myModal").style.display = "block";
                  });

                  var closeModal = function closeModal(evt) {
                   evt.preventDefault();
                   document.getElementById("myModal").style.display = "none";
                  };

                  var elements = document.querySelectorAll("#paylater_close, #myModal");
                   Array.prototype.forEach.call(elements, function(el){
                   el.addEventListener("click", closeModal);
                  });

                  document.addEventListener("DOMContentLoaded", function(event) {
                    document.getElementById("pagantis_payment_form").setAttribute("target", "iframe-pagantis");
                    document.getElementById("pagantis_payment_form").submit();
                    document.getElementById("iframe-pagantis").style.display = "block";
                    document.getElementById("myModal").style.display = "block";
                    });
                  </script>';
                } else {
                    $return_form .= "<script type='text/javascript'>\r\n                  jQuery(document).ready(function() {\r\n                    jQuery('#submit_vme_payment_form').click();\r\n                  });\r\n                  </script>";
                }
                return $return_form;
            }
コード例 #14
0
 public function get_settings()
 {
     $settings = get_option('slp_general_settings');
     $countries = new WC_Countries();
     return apply_filters('slp_general_settings', array(array('id' => 'slp_location_settings', 'title' => __('Location Settings', 'slp'), 'type' => 'title', 'desc' => __('Tell us about your business', 'slp'), 'autoload' => false), array('id' => 'company_name', 'title' => __('Company Name', 'slp'), 'type' => 'text', 'default' => '', 'value' => isset($settings['company_name']) ? $settings['company_name'] : '', 'autoload' => false), array('id' => 'address_1', 'title' => __('Address 1', 'slp'), 'type' => 'text', 'desc' => __('Street Address or PO Box', 'slp'), 'default' => '', 'value' => isset($settings['address_1']) ? $settings['address_1'] : '', 'autoload' => false), array('id' => 'address_2', 'title' => __('Address 2', 'slp'), 'type' => 'text', 'desc' => __('Suite, unit, etc', 'slp'), 'default' => '', 'value' => isset($settings['address_2']) ? $settings['address_2'] : '', 'autoload' => false), array('id' => 'address_3', 'title' => __('Address 3', 'slp'), 'type' => 'text', 'desc' => __('Floor, room, ect', 'slp'), 'default' => '', 'value' => isset($settings['address_3']) ? $settings['address_3'] : '', 'autoload' => false), array('id' => 'city', 'title' => __('City', 'slp'), 'type' => 'text', 'desc' => '', 'default' => '', 'value' => isset($settings['city']) ? $settings['city'] : '', 'autoload' => false), array('id' => 'country', 'title' => __('Country', 'slp'), 'type' => 'select', 'css' => 'width: 200px;', 'class' => 'chosen_select', 'default' => 'US', 'value' => isset($settings['country']) ? $settings['country'] : 'US', 'settings' => $countries->get_countries(), 'autoload' => false), array('id' => 'state', 'title' => __('State', 'slp'), 'type' => 'select', 'css' => 'width: 200px;', 'class' => 'chosen_select', 'default' => 'AL', 'value' => isset($settings['state']) ? $settings['state'] : '', 'settings' => $countries->get_states(isset($settings['country']) ? $settings['country'] : 'US'), 'autoload' => false), array('id' => 'zipcode', 'title' => __('Zip Code', 'slp'), 'type' => 'text', 'desc' => '5 digit zipcode', 'default' => '', 'tooltip' => false, 'value' => isset($settings['zipcode']) ? $settings['zipcode'] : '', 'autoload' => false), array('id' => 'phone', 'title' => __('Phone Number', 'slp'), 'type' => 'text', 'desc' => '', 'value' => isset($settings['phone']) ? $settings['phone'] : '', 'autoload' => false), array('type' => 'sectionend', 'id' => 'slp_location_settings')));
 }
コード例 #15
0
ファイル: resume.php プロジェクト: NoviumDesign/polefitness
     if ($current_user->user_email) {
         $update['shipping_address']['email'] = $current_user->user_email;
     }
     if ($woocommerce->customer->get_shipping_postcode()) {
         $update['shipping_address']['postal_code'] = $woocommerce->customer->get_shipping_postcode();
     }
 }
 if ($this->is_rest()) {
     $update['order_amount'] = (int) $klarna_order_total;
     $update['order_tax_amount'] = (int) $klarna_tax_total;
     // Only add shipping options if the option is unchecked for UK
     $checkout_settings = get_option('woocommerce_klarna_checkout_settings');
     if ('gb' == $this->klarna_country && 'yes' == $checkout_settings['uk_ship_only_to_base']) {
         $update['shipping_countries'] = array();
     } else {
         $wc_countries = new WC_Countries();
         $update['shipping_countries'] = array_keys($wc_countries->get_shipping_countries());
     }
     if ('billing_only' != get_option('woocommerce_ship_to_destination')) {
         $update['options']['allow_separate_shipping_address'] = true;
     }
     /* 
     // Add shipping options
     WC()->cart->calculate_shipping();
     $packages = WC()->shipping->get_packages();
     foreach ( $packages as $i => $package ) {
     	$chosen_method = isset( WC()->session->chosen_shipping_methods[ $i ] ) ? WC()->session->chosen_shipping_methods[ $i ] : '';
     	$available_methods = $package['rates'];
     	$show_package_details = sizeof( $packages ) > 1;
     
     	if ( ! empty( $available_methods ) ) {
コード例 #16
0
ファイル: formatting.php プロジェクト: GarryVeles/Artibaltika
 function woo_ce_expand_state_name($country_prefix = '', $state_prefix = '')
 {
     $output = $state_prefix;
     if ($output) {
         $countries = new WC_Countries();
         if ($states = $countries->get_states($country_prefix)) {
             if (isset($states[$state_prefix])) {
                 $state = $states[$state_prefix];
                 $output = $state;
             }
         }
     }
     return $output;
 }
コード例 #17
0
ファイル: plugin_options.php プロジェクト: mautd29388/naturel
    if (version_compare(WOOCOMMERCE_VERSION, '2.3', '<')) {
        ?>

                        <b style="color: red;"><?php 
        _e("GeoIP works from v.2.3 of the WooCommerce plugin and no with minor versions of WooCommerce!!", 'woocommerce-currency-switcher');
        ?>
</b><br />

                    <?php 
    }
    ?>

                    <ul>
                        <?php 
    if (!empty($currencies) and is_array($currencies)) {
        $c = new WC_Countries();
        foreach ($currencies as $key => $currency) {
            $rules = array();
            if (isset($geo_rules[$key])) {
                $rules = $geo_rules[$key];
            }
            ?>
                                <li>
                                    <table style="width: 100%;">
                                        <tr>
                                            <td>
                                                <div style="width: 70px;<?php 
            if ($currency['is_etalon']) {
                ?>
color: red;<?php 
            }
コード例 #18
0
 public function get_states()
 {
     $country = isset($_POST['country']) ? sanitize_text_field($_POST['country']) : '';
     $countries = new WC_Countries();
     $states = $countries->get_states($country);
     $this->send_json($states);
 }
コード例 #19
0
ファイル: wc_crm_ajax.php プロジェクト: sajidshah/le-dolci
 public function loading_states()
 {
     check_ajax_referer('wc_crm_loading_states', 'security');
     $country = $_REQUEST['country'];
     $state = $_REQUEST['state'];
     $id = $_REQUEST['id'];
     $countries = new WC_Countries();
     $filds = $countries->get_address_fields($country, '');
     unset($filds['first_name']);
     unset($filds['last_name']);
     unset($filds['company']);
     $filds['country']['options'] = $countries->get_allowed_countries();
     $filds['country']['type'] = 'select';
     if ($country != '') {
         $filds['country']['value'] = $country;
         $states = $countries->get_allowed_country_states();
         if (!empty($states[$country])) {
             $filds['state']['options'] = $states[$country];
             $filds['state']['type'] = 'select';
         }
     }
     $statelabel = $filds['state']['label'];
     $postcodelabel = $filds['postcode']['label'];
     $citylabel = $filds['city']['label'];
     $html = array();
     $state_html = '';
     if ($id == '_shipping_country') {
         $dd = '_shipping_state';
     } else {
         $dd = '_billing_state';
     }
     if (isset($filds['state']['options']) && !empty($filds['state']['options'])) {
         $state_html .= '<select id="' . $dd . '" class="form-row-wide address-field  ajax_chosen_select' . $dd . '" style="width: 220px;" name="' . $dd . '">';
         foreach ($filds['state']['options'] as $key => $value) {
             $state_html .= '<option value = "' . $key . '" ' . ($state == $key ? 'selected="selected"' : '') . '> ' . $value . '</option>';
         }
         $state_html .= '</select>';
     } else {
         $state_html .= '<input type="text" id="' . $dd . '" name="' . $dd . '" value="' . $state . ' " class="form-row-left address-field" />';
     }
     $html['state_html'] = $state_html;
     $html['state_label'] = $statelabel;
     $html['zip_label'] = $postcodelabel;
     $html['city_label'] = $citylabel;
     echo json_encode($html);
     die;
 }