Category

Plugins

Woocommerce – Add an Important Admin Note to the Order Report for Order pickers to view

By | Ecommerce, PHP, Plugins, Programming, Woocommerce, Wordpress | 3 Comments

In this article I’ll show you how to add an Important Admin Note to the Order Report, very useful if there’s some information you want to add for Order pickers to view. For instance maybe the item is fragile you can highlight this to the order picker.

 

Screen Shot 2016-01-14 at 15.21.07

This plugin allows you to enter an Admin note on the order and then displays this note on order report screen.

Screen Shot 2016-01-14 at 15.23.27

If you just want to get the plugin please click here to download the plugin. The rest of this article will run over how to create a plugin like this, so if you have an interest int he programming side of wordpress, this is for you.

Essentially to write this plugin we need todo 3 things:

  1. display the important Order Note input field on Woocommerce edit order screen
  2. save it when needed (i.e. when you save the order)
  3. display the note (in red in the graphic above) on the Woocommerce Order Report

So lets dive in:

Display the important Order Note input field on Woocommerce edit order screen

To display the order note field we need to do something like this (below). Print out the html for the text input field and add some explanatory note for the admin user.

 

Save it when needed (i.e. when you save the order)

In the code below I’m saving the Import Order Note, and before doing so checking that its valid.

 

finally

Display the note (in red in the graphic above) on the Woocommerce Order Report

In this function I use the relevant hook to drop my Import Order Note into the Order Report in the correct place.

 

I hope you found that interesting, if you need any help with Programming WordPress or Woocommerce please get in touch.

Wordpress create admin reports using WP_List_Table

WordPress create admin reports using WP_List_Table

By | PHP, Plugins, Programming, Wordpress | No Comments

In this post I’m going to discuss how to use WP_List_Table to create reports/tables/lists that are similar in style to the standard WordPress reports for Posts, Pages etc.

To achieve this I’ll use the WP_List_Table core WordPress class, this contains the functionality to create said tables/reports.

This example will look at the links table and display the data from it. This code used here is adapted from an example plugin on WordPress.org by Matt Van Andel

Important information to mention about creating admin reports using WP_List_Table

Its important to mention that this class is marked private by WordPress and they could change it in the future, without warning  (I’d be surprised if they did, given alot of peoples code relies on this class, but you never know). To be extra safe you can make a copy of the class in your own code and include this.

Explanation of the Code

The complete source code for the how to create admin reports using WP_List_Table plugin, is below. I’ve stripped out alot of the original comments. Please download the original plugin from WordPress.org to see the original version with comments (my version is adapted to run a SQL query and output the results as a report, the original doesn’t use SQL instead a pre-populated array is used for simplicity).

I’ll discuss in brief what the plugin does, first include the links report (this is hidden by default now in wp), I’m going to use this functionality to load wp_links with data that I can show on my report (for testing purposes):

Next the WP_List_Table class is included, this isn’t available by default to plugins. Then a class is created that inherits from WP_List_Table (this class will override the necessary methods of its parent class to give us the functionality we require).

Following this we have the column_default and get_columns methods. Column default tells class what to print in the report for each column. get_columns tells the class what our columns are.

The next part is the prepare_items method, this is where the magic happens. We query the database and setup the required information for our pagination and so on. After this the final 2 functions deal with putting a menu item on the left of the admin dashboard and the actual report display and we’re all good.

I hope you’ve found this interesting. Creating admin reports using WP_List_Table, is very useful for creating reports that are in the style of wordpress admin.

The complete code for how to create admin reports using WP_List_Table

 

woocommerce table rate shipping plugin

Woocommerce Table Rate Plugin charge per item example

By | E-commerce, Ecommerce, Plugins, Woocommerce, Wordpress | No Comments

The Table Rate Plugin is one of the most useful plugins for Woocommerce. However if you’ve never used it before it may have you scratching your head as to how to use it. In this tutorial I’ve go over how to use it to charge per item and how to apply different rates based on the shipping location.

1. Create Shipping Classes

Select Products on left menu and choose shipping class from the submenu. From this page you can set up your shipping classes. For this example I’ve setup 2 Shipping classes called: Small and Large (e.g. in add/edit product for a small item you’d select the Small shipping class).

2. Create Shipping Zones

Firstly we need to create Shipping Zones in this example we’ll have 3:

  • UK
  • Europe
  • Rest of World

After we configure them we’ll end up with this:

Screen Shot 2015-06-19 at 16.08.22

Table Rate Plugin charge per item example

So lets start with the Table Rate Plugin charge per item example. In the left menu goto Woocommerce -> Shipping Zones, fill in the zone name e.g. UK and fill in the countries for that zone (just the UK in this case) and click ‘add shipping zone’. Do the same for Europe but add the different countries (or select EU states if you only doing EU).

Woocommerce has a catch all Zone (Default Zone) so we can use this as the zone for the rest of the world. Use the method title to change what the user will see on the front end (in this case I changed it to Rest of World).

woocommerce configing the table rate plugin

Configuring Shipping Zones to have their own shipping costs

Next we can configure each of our shipping zones to use the relevant shipping class/es. Click on a zone (see below):

Shipping Zones

On the page below select Table Rates and click add:

blog_flatrate2

Table Rate Plugin charge per item example

Scroll to the bottom of the page below (and use the setting in the screenshot). Then we can configure the costs of the shipping for the first shipping class:

blog_flatrate4

Finally we add in the other shipping class and configure it as below:

table rate shipping expert london

In the  screenshot above I have configured shipping costs for large and small items for this particular shipping zone. To setup shipping costs of the other zones, repeat the steps from Configuring Shipping Zones to have their own shipping costs section to here.

This way you end up with different costs for Small and Large items based on where they will be delivered to. So logically you have something like this table below (for the cost of delivery for the different items to different parts of the world):

 

UKEuropeRest of World

Small Items £2 £6 £10
Large Items £4 £10 £18

 

Hello World tutorial on Advanced Custom Field (ACF) WordPress Plugin

By | Plugins, Wordpress | No Comments

The Advanced Custom Field plugin is one of the most useful plugins for WordPress developers. In this quickstart guide I’ll show you why.

Advanced Custom Field allows you to easily add a field (and save it) to a particular page, without having to write any programming code. To retrieve the field you have to add a very short (less than one line) snippet of code.

Lets go through an example, lets say you want to add a custom greeting to a page and you want to change this depending on your mood or the weather!

e.g. if your a local service (for example a florist in London) you might want a different greeting such as:

If its raining: ‘Welcome to our Florists, our flowers love the rain !’
or if its sunny: ‘Welcome, our flowers smile in the Sunshine’.

Ok lets run through how you actually achieve this. First goto the WordPress plugin directory, download and install the plugin.

1. select Custom Fields from the left hand side of the admin menu.
2. Fill in the field details (field name) and location of where the field will appear. Select Add field

 

advanced_custom_field1

 

3. Next fill in the field details (e.g. the field type for our field we are using a text field) and save it (publish).

 

advanced_custom_field2

 

4. Open the page that you have selected you have the field on and edit it in the wordpress wysiwyg editor. Then save the field like i’ve done below.

 

advanced_custom_field3

 

5. Next we want to display the field (our message) on the page, so we need to open the relevant page template in the editor of your choice. We simply add get_field(‘custom_flower_field’, $post->ID); to the place in the page where we want our message displayed (save the file).

Finally lets view the homepage to see our message being displayed. So there it is, easily display your field without writing any code to save your field into the database. Of course when mood takes us or the weather changes, we can simply go back to the homepage (in the wordpress editor), and easily change/update our message without having todo anything technical.

 

advanced_custom_field4