Today I would like to share something easy to develop and helpful for your clients. WooCommerce is an awesome and powerful WordPress plugin. I personally tried other shopping carts but always made my way back to WooCommerce.
The tutorial for today is to add a column to your WooCommerce frontend order table. There are a lot of reasons why you want to make an extra column, but it all comes down to user/customer experience.
In this tutorial, we are going to create an extra billing field and then going to show it in the Order table. This is a fast and easy tutorial to make your customers happy.
First, create the extra billing field. You can read about WooCommerce filters and hooks in the documentation, the more you read and understand it the more you be able to develop custom functions like this. Beleive me it can get fun <- geek 🙂 You can also read more about Checkout fields here.
We are going to add a billing field called “Website URL”. We are going to add a Filter with the name “woocommerce_checkout_fields”. You do not have to add it to the billing fields but I am going to add it there for now.
We are also going to give this billing field a unique meta field name, let us call it “billing_wp_url“. Make the field also a required field. See the Action Filter below.
[snippet slug=checkout-field lang=php]
Awesome, that was it! Now we are going to add this WooCommerce checkout field to the Order table.
The first filter is to add the column and name it WordPress URL. I want it next to “Order total” and give the column a name. Again so easy, WooCommerce explains all this in their documentation.
[snippet slug=order-table-header lang=php]
The next filter is to link this column that we created with its data. Now we are going to call the “billing_wp_url” meta field we created on the checkout page and add it. We call this data in 2 lines of code.
[snippet slug=order-data lang=php]
All done! How easy was that? So you can call other billing fields also, WooCommerce really made it so easy. Read about it here. For example show the user Billing First Name: “$getfirstname = = $order->get_billing_first_name();”
Please let me know how this helped you, and how you improved your customers experience.