Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,154,260 members, 7,822,319 topics. Date: Thursday, 09 May 2024 at 09:59 AM

States Not Visible In Wordpress Woocommerce Y? :( - Science/Technology - Nairaland

Nairaland Forum / Science/Technology / States Not Visible In Wordpress Woocommerce Y? :( (1179 Views)

A Colossal Asteroid "Florence" Will Cruise By Earth Today, Visible To Human Eyes / Is The Eclipse Visible In Your State / Clear Visible 5mw-100mw Green Laser Diode Module (2) (3) (4)

(1) (Reply)

States Not Visible In Wordpress Woocommerce Y? :( by dplumptre(m): 2:12pm On Jun 25, 2015
Hi guys , some of us want to create an online store or basically want to do transactions online

then you go ahead to install woocommerce in wordpress and lets say your the shop is based in

Nigeria or some other country , but to your surprise you discover that the states are not included .

To make matters worse you get is this error saying “currency not supported” when trying to

include paypal as a means of payment .

Dont fret because I have go the solution for you.

Well all you need to do is to navigate to plugins/woocommerce/includes/gateways/paypal

then look for “function is_valid_for_use() “

Add NGN to the array , then you are done . But I wont recommend you adding code directly like

that its usually better to create a child theme first. I will cover creating of child theme in another

tutorial but if you already know it, what you need to do is to locate your functions.php in your child

theme folder and add this codes below


add_filter( 'woocommerce_paypal_supported_currencies', 'add_bgn_paypal_valid_currency' );
function add_bgn_paypal_valid_currency( $currencies ) {
array_push ( $currencies , 'NGN' );
return $currencies;




From the word 'array_push' its going to add NGN to the array , where NGN is the currency you

want to use ok.


For the states part , I discovered that some countries state are not included in woocommerce

you can check that out by navigating to /plugins/woocommerce/i18n/states then adding your state

like for Nigeria , you will add a NG.php , the content in the script is written below but if you are

working for a different country you can simply use the same format as far as you have the short

codes for your state , haven't said all that , jump into your funtions.php file in your child theme ,

you can still do this in your theme though but its better to use a child theme because once you do an

update on woo commerce all these changes will be lost, which is just annoying

Inside your functions.php file add this code below, this code is for Nigeria







add_filter( 'woocommerce_states', 'custom_woocommerce_states' );

function custom_woocommerce_states( $states ) {

$states['NG'] = array(
'FC' => __( 'Abuja', 'woocommerce' ),
'AB' => __( 'Abia', 'woocommerce' ),
'AD' => __( 'Adamawa', 'woocommerce' ),
'AK' => __( 'Akwa Ibom', 'woocommerce' ),
'AN' => __( 'Anambra', 'woocommerce' ),
'BA' => __( 'Bauchi', 'woocommerce' ),
'BY' => __( 'Bayelsa', 'woocommerce' ),
'BE' => __( 'Benue', 'woocommerce' ),
'BO' => __( 'Borno', 'woocommerce' ),
'CR' => __( 'Cross River', 'woocommerce' ),
'DE' => __( 'Delta', 'woocommerce' ),
'EB' => __( 'Ebonyi', 'woocommerce' ),
'ED' => __( 'Edo', 'woocommerce' ),
'EK' => __( 'Ekiti', 'woocommerce' ),
'EN' => __( 'Enugu', 'woocommerce' ),
'GO' => __( 'Gombe', 'woocommerce' ),
'IM' => __( 'Imo', 'woocommerce' ),
'JI' => __( 'Jigawa', 'woocommerce' ),
'KD' => __( 'Kaduna', 'woocommerce' ),
'KT' => __( 'Katsina', 'woocommerce' ),
'KE' => __( 'Kebbi', 'woocommerce' ),
'KO' => __( 'Kogi', 'woocommerce' ),
'KW' => __( 'Kwara', 'woocommerce' ),
'LA' => __( 'Lagos', 'woocommerce' ),
'NA' => __( 'Nasarawa', 'woocommerce' ),
'NI' => __( 'Niger', 'woocommerce' ),
'OG' => __( 'Ogun', 'woocommerce' ),
'ON' => __( 'Ondo', 'woocommerce' ),
'OS' => __( 'Osun', 'woocommerce' ),
'OY' => __( 'Oyo', 'woocommerce' ),
'PL' => __( 'Plateau', 'woocommerce' ),
'RI' => __( 'Rivers', 'woocommerce' ),
'SO' => __( 'Sokoto', 'woocommerce' ),
'TA' => __( 'Taraba', 'woocommerce' ),
'YO' => __( 'Yobe', 'woocommerce' ),
'ZA' => __( 'Zamfara', 'woocommerce' ),
);

return $states;
}




Then you are done , if you got questions you can holla if not till next time but you read more of my tutorials on http://overallheuristic.com/blog/

1 Like

Re: States Not Visible In Wordpress Woocommerce Y? :( by Netvest(f): 7:51pm On Jun 11, 2016
Great helpful information. I spent hours trying to work around codes for Nigerian states. I used 234 country code but was not getting it right. You have made my day with this post. Thanks

(1) (Reply)

Get Free MTN 150MB To Browse Unlimited Everyday On Android & Pc / How & Where To Buy/ Sell Usdt in Nigeria And Get Paid Instantly?. Try Bingtellar / Sony Prototype Sends Electricity Through The Air

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 11
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.