How To Add New Currency To WooCommerce

Woocommerce comes with quite many currencies. In fact, if you are selling items internationally, you got a plenty of options to choose from such as USD, GBP, EUR or even BTC (bitcoin). However, there are a lot of currencies isn’t in that list. For example, what if you want to accept ETH (Ethereum) as your currency? Don’t worry, we can make that work.

Check if your currency is supported by Woocommerce

Woocomemerce is updated frequently. Thus, chances are your currency get added in the latest release. The first thing you need to do is to:

  1. Update Woocommerce to the latest version
  2. Go to Woocommerce->Settings->General->Scroll to the bottom to see the currency options. You can see the list of supported currencies there

If your desired currency is in the list, that’s great! You don’t need to do anything else. If it isn’t, read on.

Introducing the necessary hooks

If you are unfamiliar with the term hooks, you can take a look at the official document here. However, it is not necessary to understand it thoroughly to add new currencies to Woocommerce.

There are two filter hooks you need to use to add new currency to Woocommerce

  1. woocommerce_currencies
  2. woocommerce_currency_symbol

As the names suggest, the first one will be used to register new currency and the second one will be used to register the currency’s symbol.

The actual code

I’m going to register the Ethereum currency to Woocommerce. However, you can define and add any type of currency you want. You can even invent a currency that isn’t available right now.

add_filter( 'woocommerce_currencies', 'bc_add_new_currency' );
add_filter( 'woocommerce_currency_symbol', 'bc_add_new_currency_symbol', 10, 2 );

function bc_add_new_currency( $currencies ) {
     $currencies['ETH'] = __( 'Ethereum', 'your-theme-text-domain' );
     return $currencies;

function bc_add_new_currency_symbol( $symbol, $currency ) {
     if( $currency == 'ETH' ) {
          $symbol = '♦';
     return $symbol;

There are a few places in the code above you need to pay attention to:

  1. The symbol of ETH is ♦. You can replace this with your currency’s symbol .
  2. Name of your currency. In the code, it is “Ethereum”. You can change this to the name of your currency. For example: Bitcoin Cash
  3. The index key ‘ETH’. This can be anything but unique across all currencies.

Now, after you modify the code to match your currency of choice, put it at the end of the functions.php file in your active theme folder:

The result

Now, if you go to Woocommerce->Settings->General and scroll down to Currency Options, you can search for the new currency:

That’s it! That’s how you can add new currencies to Woocommerce. You can add as many new currencies as you want, there is no limit.

How To Resize and Copy Images Files To Android Drawable Folders Quickly

I’m not a full time Android developer. I make Android apps such as this. Android studio is great and I can develop my ideas quickly. However, there is one thing I don’t like is the way I have to deal with images. Every time I need to add an icon to my app, I need to resize that image to the following sizes:

  1. 144 x 144
  2. 96 x 96
  3. 72 x 72
  4. 48 x48

And put them in the following folders, respectively:

  1. drawable-xxhdpi
  2. drawable-xhdpi
  3. drawable-hdpi
  4. drawable-mdpi

The task is boring and tedious. So, I decided to make a tool to make this task less painful.

How does the tool work?

Let’s say you want to use a new icon like this in your app:

Now, instead of resize and copy the file 4 times, you just need to open the tool:

The first step is to select your /res folder which contains the drawable-..dpi folders. The Directory Chooser will make this step simple an easy.

Now, look at the checkboxes, they are self-explanatory. If for some reasons, you don’t want to copy the image to a particular folder, simply uncheck the checkbox in front of it.

Then, click on select Image to select your image. The image should be square and have resolution at lest 144 x 144 pixel to avoid pixelation.

If your image is in JPG format, you select JPG, if it is PNG, select PNG.

After that, you click on open to complete the process.

And that’s all. You don’t need to open your image editor to resize the images. With less time spent, you have your images in all drawable folders.

Further features

I made this tool out of my need. I think there are more improvements to be made. Here are some ideas:

  • Let user set the resolution (instead of fixed size as of now)
  • Let user select more folders, even add folders outside the /res folder

The app is free and the repo is open on github. You can download the source and the app here

I hope the app can save you some precious time. Let me know if you have any suggestions.


How To Find Big Images That Makes Your Site Load Slowly

Images is one of the biggest reasons why sites take a very long time to load. I should say big image to be exact. Some website owners are not aware of this fact and they still upload big images to their website and set the size smaller by using width and height attribute. A classic example is you use your images from a digital camera (or your phone) and upload directly to your website without scaling it down first. The images could be a few MB to over ten MB in size. This is a big problem if you know that in order for a web page to load fast, its total size should not exceed a few MB (except you own a gallery site).

How to find big images in your web pages

Fortunately, finding big images in your web pages is very simple with browser’s tools. You can use any browser to find big images. However, I would recommend you use Google Chrome for the ease of use.

Step 1: Navigate to the URL you want to inspect

In this example, I go to a post in my local site which writes about tiger:

Step 2: Right click any where on the post and select inspect

You will see the console panel appears. Click on Network tab:

Step 3: Reload your page

You will see a new panel appears listing all request your make to the web server.

Step 4: Click on the size tab to sort the request in size order

As you can see, the image is the biggest resource listed at the top.

How do you avoid using big images in your posts

Images is an indispensable part of your content. Without images, your site will look boring and your visitors may not return the second time. However, uploading big images can cause a strain on users’ precious data limit (especially when they use 3G connection). The obvious solution is to resize the image before uploading. Doing so not only help you serve smaller images but also save your server storage. However, this task is tedious, especially when you have to upload many pages for your posts.

A better solution for WordPress users

If you use WordPress, the solution is very simple. WordPress allow you to set the size of the images after you upload.

When uploading images, you notice this section after the image is uploaded:

You can see that we can select sizes for the image. In this case, my picture has the original resolution is 2560 x 858 pixel, which is very large (both in dimensions and in size ). However, I see that if the image is 640 x 214, my visitors can view the details just fine and it saves me a huge amount of bandwidth. So, I choose this option.


Many of us have the luxury of unlimited connection, fast wi-fi… However, there are many people access the internet with limited data plan. Reducing your images size can reduce the time your visitors have to wait on your site and also their cost on mobile data. Your site will also load faster and your visitors will be more happy.


How To Change Categories’ URLs In WordPress

Changing URL is something you shouldn’t do frequently because of SEO. However, there are times you need to change the URL to reflect the content of your pages/posts.

In WordPress, you can choose to include the category in the URL. For example, my permalink structure is:

category in permalink
category in permalink

Then my post URL will container the category. For example, I have an article in the World News category. The URL of that post will be

Now, for example, I would like the change the world-news into breaking-news. How would I do that?

Let me show you how.

How to change the category in your post URL

First, you need to go to Posts->Categories. You will see your category listed there:


List of categories
List of categories

As you can see, the category we want to change is World News. If you notice at the right of World News row, there is field called slug. This is what displays in the URL of every posts of that category.

Now, if we want to change world-news to breaking-news, simply change the slug to breaking-news.

Step 1: Click on Quick Edit link under World News

Quick Edit category
Quick Edit category

Step 2: Change the slug to breaking-news. Remember, you don’t need to change the name to Breaking News to update the URL. Changing the slug only is sufficient.

Step 3: Hit the Update Category button

Now, if I view the URL of the post mentioned at the beginning of the article, I can see the new category slug:

So, that’s how you change the category name in the URL. However, it is not recommended to change the URL of any pages/posts frequently because it will take time for search engines to update your new URL. After changing the URL, you also should do a redirect from the old url to the new URL to make sure when the visitors go to the old URL, they will get redirected to the new URL, not a 404 page.

Extract List Of Unique Words From a Book, Article (Supports .txt, .pdf format)

As an ESL, I usually wonder: “how many words I need to know to speak English well?”. I read somewhere that you don’t need more than 2,000 words to carry out 99% of daily conversations. 2,000 words don’t seem to be a lot and if I can learn 10 words a day, I can be conversational in any language in just 200 days (less than a year).

So, what if I want to enjoy the novels, books in English, how many words I need to know.

I doubt the number would be a lot more than 2,000 words.

So I made a tool to read all the text in a book (you can select more than one book in .pdf or .txt format) and it will export all the words in that book into a table.

Here are some results:

Adventures of Huckleberry Finn

As you can see at the top, there are 6461 different words in this book.

Wuthering Heights

for Wuthering Heights, you need to know 9,456 words.

That’s a lot of words.

The numbers aren’t 100% correct. There are some gibberish such as website address, two letter (like country codes) may get in the list. However, you can roughly estimate that there are 95% of the numbers are real words.

I find that this is a good way to quickly find out new words that I don’t know. I can click on the words to get the definition (if available) on the right.

You can download the program here for free. If you have any suggestion, please let me know.

Download Word Extraction app here