In WooCommerce 3.3 we introduced a new uncategorized category all product will default to when no other category is assigned to them. This is the same behavior that WordPress uses for posts. With that, unfortunately, if your shop is set up to display categories on the shop page then this new uncategorized category will also show up.
Although we give you the possibility to rename the category to whatever you would like, there might be cases where you would like to rather not display this on your shop page. To do that you can simply add the following piece of code to your site via your theme’s functions.php file, or via a custom plugin. Remember to not include the opening tag<?php if you are adding this to an existing file.
Since WooCommerce 3.2 the option to resend the admin new order email was removed. The reason was that it was a pretty much-unused feature as admins already have access to the orders so they could just look it up.
However, if you relied on this feature for some reason and now all of sudden can’t use it, fear not as it can easily be added back with the following snippet.
As always include the following code in your theme’s functions.php file omitting the opening <?php tags
Refunds can be a sore subject but it is something that every store has to deal with, keeping track of refund reasons can be very beneficial to you so you can keep pushing your refund rate down further and further.
The problem is that you do not always want your customer to see the reason you enter for when doing a refund, which WooCommerce will display by default to each customer.
Good news is that you can easily replace the refund reason in your customer-facing emails and pages with static text like just “Refund”.
Add the following code to end of your theme’s functions.php file omitting the opening <?php tag
ECommerce is serious business, that is why when a customer signs up to your store you want the most accurate information to stay in touch, promote your products and offer decent after sales service. Unfortunately, there are lots of chancers out there on the internet that use fraudulent cards and fake emails to purchase products from your store, which can leave you to foot the bill.
The following piece of code will prohibit usage of fake emails for creating accounts, it focuses on sharklashers.com but can easily be expanded to include other email domains by just adding to the array.
Add the following code to end of your theme’s functions.php file omitting the opening <?php tag
In WooCommerce 2.1 the repeat password fields was removed as it was decided it was easy enough to reset your password with one click should you have gotten in wrong.
If you would still like to add a password confirm field on your register page all you have to do is add the code below to your theme’s functions.php file.
This will add a new field underneath the password field with a label Password Repeat, and then when the customer clicks register it will match the password and password repeat fields against each and and proceed with registration it it matches, or throw an error if it does not match.
The last couple of weeks I have spent a lot of time working on some tutorials to reverse some of the changes introduced in WooCommerce 2.1 to the ways it was in WooCommerce 2.0.
This tutorial is another one of this cases, WooCommerce 2.1 removed the password confirm field and functionality from the checkout page as it was thought that should a customer make a typo in the password field they can easily just reset it via the password reset functionality in WooCommerce.
However if you would still like add this password confirm field to your WooCommerce 2.1 checkout page, good news is this is still possible.
The code below will add an additional field underneath your password field on the checkout page called Confirm Password and when the customer places the order it will check the two password field against each other and give an error message and prohibit checkout if they do not match.
Place the code below in your theme’s functions.php file
With WooCommerce 2.1 just being released a couple of days ago, a lot of users may have noticed a couple of big changes to the plugin, like a refined settings section and the introduction of an all new REST API.
The aim with each major WooCommerce release is to simplify and make it faster and more scalable, and with WooCommerce 2.1 this meant that a lot of the setting that was rarely uses was removed and a few formatting changes was made based on customer feedback.
One of the formatting changes that was made was to remove the “From: $x” price formatting of variation products in favor of a range ie “$x – $y”. This new range format for variable product may not appeal to everyone and that is where the following snippet comes into play.
The code snippet will change the new range price format back to the “From:” price format that users are accustomed to in WooCommerce 2.0.
To revert your WooCommerce variation prices back to the “From:” price format add the following code to your theme’s functions.php file
The WooCommerce REST API comes bundled with WooCommerce 2.1+ and allows you all sorts of API calls to interact with your WooCommerce store data. You can get access to your Order, Customer, Coupon, Product and Reporting data all through the API.
Having it be a new API interacting with it can sometimes be a difficult task, that is why most software with API’s offer some sort of API Client Library which makes interacting with the API a breeze.
I have been spending quite a lot of time playing around and testing the API since its first commit into WooCommerce core and due to this built quite an easy to use and extendable API Client Library that I used to test and later on refined to make available to the public for use.
The WooCommerce REST API has two authentication methods, one legged oAuth 1.1, and Basic HTTP authentication, the method being used is all dependent on whether your WooCommerce store has a valid SSL certificate and if you have secure checkout enabled. I have developed the WooCommerce REST API Client Library to support both methods as the WooCommerce REST API require you to use oAuth when you have no valid SSL certificate and Basic authentication when you have secure checkout enabled with a valid SSL certificate.
Enabling the WooCommerce REST API
In order to enable the WooCommerce REST API and to start using it you will need to enable it in your WooCommerce settings.
This can be done by going to WooCommerce -> Settings -> General tab in the WordPress admin area, and then making sure the Enable the REST API option is checked. This should be checked by default.
Generating API Keys
In order to access data through the WooCommerce REST API you will require a Consumer Key and Secret. This is used to authenticate the API calls and to ensure that the call being made can access the data it is trying to access.
API Consumer Keys and Secrets are tied to users, which allows WooCommerce to restrict access to certain data based on the user role, so for instance if you set up the user to only have access to products and they try to access orders with their API details they will not be able to.
To generate API details head to either Users -> All Users or Users -> Your Profile in the WordPress admin area. If you followed the Users -> All Users path you will need to search for the user you want to generate API credentials for and edit it.
Once you are on the edit profile page, scroll down to the bottom of the page, there should be a checkbox to generate API Keys, check this and save the profile. Once the page refreshes, if you scroll down again there will be a Consumer Key and Consumer Password listed, and if you are a site admin you will also have the option to select read/write access.
Communicating with the WooCommerce REST API
Once you have the Consumer Key and Consumer Secret you are now ready to start interacting with the WooCommerce REST API.
This is where the WooCommerce REST API Client Library comes into play, you can now head to the WooCommerce REST API Client Library page on GitHub and download the PHP client library from there.
Once you have downloaded the PHP client library you will find a couple of file, the important one here is class-wc-api-client.php, this is the file you will need to use to be able to make use of the client library and make calls to the WooCommerce REST API. There is also a folder called example which shows you how to interact with the client library in order to make calls to your WooCommerce store.
Using the WooCommerce REST API Client Library
If the example code provided with the client library is not enough and the documentation listed on the GitHub page does not explain it well enough here is a quick intro on how to get started using the client library with the WooCommerce REST API.
Connecting to the REST API
In order to connect to the REST API of your store you will need to have the URL to your store as well as your Consumer Key and Consumer Secret ready. Use the following PHP code to include the client library and access the WooCommerce REST API of your store. Be sure to use https if you have secure checkout enabled on your site.
Making a call to the REST API
Once the client library has been initiated you can use the api object to make calls to the WooCommerce REST API, all the calls will return the data in JSON decoded format.
And that is it, for more documentation on all the available function calls, and how to call custom API endpoints added through extensions etc please see the README.md file on the GitHub page
Contributions are welcome, if you spot a bug or would like to add an enhancement feel free to fork and send a pull request.