• Resolved cambuff

    (@cambuff)


    Thanks for this awesome plugin. I installed it yesterday, works well and loving it. I’m gonna keep this plugin for my store forever!!!

    But there’s one issue, “Country/State” filed is bit problematic for postal/courier services to read.

    Eg: my home state is “Karnataka” (India) it appears as “KA” in address fields. Though it is technically right, it may not be legible for shipping company workers to sort and deliver. We can’t expect everyone to be smart with state codes. For making it fool proof, please allow us to use full name of the “state” in address fields.

    Thanks a million in advance,

Viewing 1 replies (of 1 total)
  • Plugin Author WebToffee

    (@webtoffee)

    Hi @cambuff,

    We have an option to enable the full state name display in the premium version of the plugin. You can use the code snippet below to have full state names with the basic version. Copy the code to your active theme’s functions.php

    add_filter('wf_pklist_alter_shipping_address','wf_pklist_alter_shipping_address_fn',10,3);
    function wf_pklist_alter_shipping_address_fn($address,$template_type,$order)
    {
    	$order_id = (WC()->version < '2.7.0') ? $order->id : $order->get_id();
    	$countries = new WC_Countries;
        $shipping_country = get_post_meta($order_id, '_shipping_country', true);
        $shipping_state = get_post_meta($order_id, '_shipping_state', true);
        $shipping_state_full = ( $shipping_country && $shipping_state && isset($countries->states[$shipping_country][$shipping_state]) ) ? $countries->states[$shipping_country][$shipping_state] : $shipping_state;
    	$address['state']=$shipping_state_full;
    	unset($countries);
    	return $address;
    }
    add_filter('wf_pklist_alter_billing_address','wf_pklist_alter_billing_address_fn',10,3);
    function wf_pklist_alter_billing_address_fn($address,$template_type,$order)
    {
    	$order_id = (WC()->version < '2.7.0') ? $order->id : $order->get_id();
    	$countries = new WC_Countries;
        $billing_country = get_post_meta($order_id, '_billing_country', true);   
        $billing_state = get_post_meta($order_id, '_billing_state', true);
        $billing_state_full = ( $billing_country && $billing_state && isset($countries->states[$billing_country][$billing_state]) ) ? $countries->states[$billing_country][$billing_state] : $billing_state;
    	$address['state']=$billing_state_full;
    	unset($countries);
    	return $address;
    }
    add_filter('wf_pklist_alter_shipping_from_address','wf_pklist_alter_shipping_from_address_fn',10,3);
    function wf_pklist_alter_shipping_from_address_fn($address,$template_type,$order)
    {
    	if(class_exists('Wf_Woocommerce_Packing_List'))
    	{
    		$the_options=Wf_Woocommerce_Packing_List::get_settings();		
    	    $country_selected=$the_options['wf_country'];
    	    $country_arr=explode(":",$country_selected);
    	    $country=isset($country_arr[0]) ? $country_arr[0] : '';
    	    $state=isset($country_arr[1]) ? $country_arr[1] : '';
    		if($country!="" && $state!="")
    		{
    			$order_id = (WC()->version < '2.7.0') ? $order->id : $order->get_id();
    			$countries = new WC_Countries;
    		    $state_full = ( isset($countries->states[$country][$state]) ) ? $countries->states[$country][$state] : $state;
    			$address['state']=$state_full;
    			unset($countries);
    		}
    	}		
    	return $address;
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Give us option to use full name for “State” in address fileds’ is closed to new replies.