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 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.

[With Pictures] How To Install WordPress Themes, Plugins In CPanel Step By Step

Installing WordPress themes, plugins seems to be a simple task, even for beginner. However, due to the fact that there are many hosting providers out there and each of them have a different configuration, installing a new theme or plugin on your WordPress may not be straightforward.

Most of the time, you can install a theme or plugin by uploading the .zip file inside your site dashboard.

To install a plugin you may follow the following steps:

  1. Go to Plugins->Add New
  2. Click on Upload Plugin
  3. Select your plugin .zip file and click on Install now
  4. Wait for the installation process to complete and click on Activate Plugin

The same steps can be applied to installing a theme, though, there are some differences:

  1. Go to Appearance->Themes
  2. Click on Add new
  3. Click on Upload Theme
  4. Select your theme .zip file and click on Install now
  5. Wait for the installation process to complete and click on Activate Theme

However, there is a very common problem WordPress users have when using this method is the hosting provider may put a limit on file upload size, which, less than the size of the plugin’s or theme’s zip file.

For example, your host has a 2MB limit on file upload and your theme zip file is 3MB.

In this case, uploading the theme inside your dashboard will result in a failure.

Fortunately, if your host have CPanel, you can install the plugin/theme easily.

How to install WordPress plugins/themes using CPanel

What are the benefits of installing plugins, themes using CPanel?

The biggest benefit is you don’t have to worry about upload file limit. Secondly, you can upload a zip file and then extract in on your site later. This feature can save you a lot of time in comparison to using FTP. When uploading the plugins/themes via FTP, you cannot upload a zip file then upload in the FTP client. If you install the plugin/theme using FTP, you need to extract it first before uploading. If your theme/plugin has a lot of files (even though they may be small), you will have to wait for a very long time.

Now let’s get started with installing plugins/themes using CPanel

Step 1: Login to your CPanel

The first thing is to to login to your CPanel. In the image below, I’m in HostGator CPanel. Your CPanel dashboard may look a bit different if your CPanel version is different than mine. However, you will have no problem finding File Manager. You can press Ctrl + F ( or Command + F if you are on a Mac) and type in “File Manager” to locate it.

Login to your CPanel and locate File Manager
Login to your CPanel and locate File Manager

Step 2: Go to File Manager and locate your site’s folder

Your site’s folder usually have the same name as your domain name. In the picture below, I’m going to the folder of my site called excelautocomplete.com

Go to file manager and locate your site's folder
Go to file manager and locate your site’s folder

Step 3: Go to wp-content/plugins or wp-content/themes

Now, if you double click on your site’s folder, you will see something similar to this. There are many files and folders but you only need to pay attention to one folder called wp-content

Locate wp-content folder
Locate wp-content folder

Double click on that folder you will see a list of folders. Here, you will see two folders with the following names:

  1. themes
  2. plugins

The names of those folders are self-explanatory. If you want to install a plugin, click on plugins folder. If you want to install a theme, click on themes folder. I’m going to install a theme so I’m going to click on the themes folder. You will see that there are one or more folders inside. The number of folders inside themes/plugins folder depends on the number of themes/plugin you have.

plugins and themes folder inside wp-content
plugins and themes folder inside wp-content

Step 4: Upload your zip file

Now, I’m inside the themes folder. I can start uploading the theme zip file. Please make sure your theme is in a zip file. If you have extracted it to a folder, please compress it back to a zip file.

Now, click on the upload button in your CPanel

Start uploading theme zip file
Start uploading theme zip file

You will see a new tab opened:

Select your zip file to start uploading
Select your zip file to start uploading

Now, select your theme .zip file and wait until the upload complete:

select theme file to upload
select theme file to upload

In this example, I’m select the theme sydney.

Upload theme complete
Upload theme complete

The upload is complete. Now, we go back to the theme folder and hit reload button to see the zip file:

Reload themes folder
Reload themes folder

After that, you should see the zip file appears

Step 6: Extract your zip file

We can now right click on the zip file to see the context menu and select the option to extract the file.

Extract the theme zip file
Extract the theme zip file

Wait until the decompression completes,  now, if you click on the reload link, you will see your new theme folder appears:

You can (and should) delete the zip file. To do that, simply click on that file (single click) and select the delete action at the top.

Step 7: Go to your site’s dashboard to activate the plugin/theme

Now, your theme is installed. The last thing to do is to go to your dashboard and activate it. Go to Appearance->Themes. You will see the new theme appears:

New theme
New theme

You can hover on that theme and see the option to activate it:

Now, you have your new theme installed and activated. You can do the same with a plugin. However, instead of going to Appearance->Themes, you need to click on Plugins and find the new plugin in your list of plugins and click on Activate.

So, that’s how you install plugins/themes using CPanel. If you have any questions, please leave a comment below.

Thanks for reading!

 

[Picture Guide] How To Add MailChimp Optin-Box To Your WordPress Sidebar

With the new version of WordPress, adding HTML to a sidebar widget is easy. In this post, I will show you step by step instructions to put MailChimp form into your sidebar. You can do this with other email marketing services too. The key is to get the HTML code of your form.

The step by step guide

Step 1: Login to your account

First of all, please login to your MailChimp account

Here, I’m in my account dashboard. Now, look at the top menu, you will see a menu item called Lists. Click on that.

Step 2: Select your list

A list is a collection of your subscribers. For example, you are a sleep instructor. Your audience are interested in sleep training. However, instead of putting all the people in one big list, you can split them into multiple lists to make it easier to manage. Here, as you can see I have two lists: Time Management Tips and Software. I select the Time Management Tips list.

Now, notice that at the right side of each list, you will see a dropdown, click on that and select Signup forms.

Step 3: Get the HTML code of your form

Here, you will see the form editor. You can add or subtract the fields if you need to. Then, copy the part under the title Copy/Paste onto your site

Step 4: Go to your Widget area

You may go to this area before. It’s under Appearance->Widgets

Step 5: Add a custom HTML widget to your sidebar

Your theme could have one or more places for you to put the widgets. Those areas called sidebars (though sometimes you will see they appear at the footer). As you can see in my site here, I have one sidebar at the left and 4 areas in the footer.

I’m going to drag and drop a Custom HTML into the sidebar.

Step 6: Put the HTML code of your form into the widget

Now simply paste the HTML code into the Content box. You can give it a title (it will display as a h3 above your form). I don’t put anything this time.

Now click on Save and then Done.

Step 7: See your form

As you can see, the form is now on the left sidebar.

How To Use Visual Composer In The Category Page

Visual Composer is a very popular plugin to visually create your content. There are many widgets, components in the plugin. In addition, there are other plugins that add more functionalities and widgets to Visual Composer make it the love of many WordPress users.

However, Visual Composer can only be used on regular pages/posts. If you want to use it to create content for your category page, you are out of luck. Visual composer doesn’t support creating content for the category page.

In case you don’t know where to put content on your category, here it is:

 

As you can see, there is a text editor for you to put the content, descriptions for the category but that’s it. There is no visual composer editor available.

So, how can you enable visual composer in the category page?

Meet the plan

Our plan is quite simple. Instead of putting the content directly into the editor of the category page, we will create a draft post and then display the content of that draft post as the content of the category page.

Why a draft post?

Because you don’t want your visitor to see this post since it’s not a independent post by itself. The sole purpose of this post is to contain the content for the category page.

As a post, you can use all the features of Visual Composer to compose its content.

Let’s look at a diagram, shall we?

Now, let’s get to the step by step implementation.

Step-by-step to use Visual Composer to create content for your category page

  1. Create the content of your category page in a regular post using Visual Composer
  2. Save that regular post as a draft
  3. Get the draft post’s ID
  4. Install Display Posts Shortcode plugin
  5. Find out what theme your site is using
  6. Create a template file for your category page
  7. Display the content of the draft post in your category using shortcode

I assume that you are familiar with the steps 1 and 2. Creating a post and save it as a draft are quite trivial so I won’t explain in details here.

Step 3: Get a post’s ID

After creating the draft post, make sure you get the post ID and save it somewhere. You can get the post ID of any post by following the instructions below:

 

Step 4: Install Display Posts Shortcode plugin

You can navigate to Plugins->Add new and search for this term: Display Posts Shortcode and install the one as in the image below:

 

Step 5: Find out what theme your site is using

This step is quite simple, please go to Appearance->Themes and you will see what theme is currently active. We need to know this information for the next step.

Step 6: Create a template file for your category page

This step sounds scary for people who don’t know how to code. However, it is very simple. You need to access to your themes folder on your server to complete this step. You can access the files via cPanel or FTP or ssh. Please ask your hosting provider for those details. All hosting providers should have no problem sending you those details.

Here I use Filezilla FTP client to access my files. Please go to wp-content/themes on your sever.

In the previous step, I found out that my site is currently using the theme Blog One, I can see the folder of that theme here:

I will click inside that folder to see all the files:

 

Here, we pay close attention to the one file called single.php. We are going to create a template file for the category using that file.

Now, go find your category ID. The method is similar to finding post’s ID.

  1. Go to Posts->Categories
  2. Hover on the Edit link of your category
  3. Look at the status bar of your browser (bottom left)
  4. Locate the tag_ID value

And that’s your category ID.

For example, my Blog category ID is: 1

 

Now, copy the single.php file and name it category-1.php (if your category ID is 300, you need to create a file called category-300.php);

 

If you use an FTP client such as FileZilla, you need to download the single.php to your computer first, then rename the file to the new name.

Open the file with your favorite text editor. On Mac, you have Sublime text. I use Notepad++ since I’m on Windows.

Your file may be a bit different, however, it will look something like that.

Now, we need to remove the content of the file from the <?php to ?> in the image above:

Then, put the following code right at the place where you have just removed the old content:

Make sure you replace the your_draft_post_ID with the actual draft post ID you got from above.

Now, upload the file to your theme folder (sample folder with the single.php) and you are done.

Now, what you put in the draft post will appear on your category page.

One last thing, please NEVER publish the draft post.

I hope this post has been helpful. Now you can use Visual Composer to create content for your category page.