Tag: programming

WooCommerce: getAddress.io Postcode Lookup

Update: Version 2.2 released on 10th February 2022, on the WordPress plugin repository.

This, my third WordPress plugin (and also my third WooCommerce plugin, apparently I really like doing stuff with WooCommerce!) adds a postcode lookup tool to the checkout in WooCommerce 3.x that lets your UK-based customers quickly fill in their billing/shipping addresses based on their postcode.

It utilises the great getAddress.io API for the postcode lookup, and as such requires an API key for their service. I’d always recommend the £10 per month pricing plan, simply because it offers the best value, but they have a number of others available.

WooCommerce: Purchase Order Payment Gateway

Update: Version 1.1.5 released on 4th May 2021, on the plugin repository.

A recent project required the ability for customers on a client’s WooCommerce website to be able to request an invoice for their order (and thus pay offline) – but with the added twist that it required a Purchase Order number. This twist meant that simply changing the name of WooCommerce’s built-in “Offline” gateway was not enough.

I had a quick look around and found an existing plugin for WooCommerce that added this functionality, but as seems to be common when I do this, the functionality left a little bit to be desired.

First of all, the plugin required the customer to enter a postal address for the invoice (and curiously, didn’t automatically pull through the customer’s billing address) – I only needed a Purchase Order number field.

Additionally, it wasn’t very well internationalised – some strings were set as translated, but others – particularly in the HTML output that the plugin generated on the front-end and the admin back-end, were not.

So, I’ve taken it upon myself to learn a bit more about WooCommerce’s Payment Gateway API, and have written my own – which you can download below.

How to enable checkbox lists for non-hierarchical taxonomies in WordPress

WordPress’ taxonomy features are one of the most powerful aspects of the platform, giving you the capabilities to group posts (including custom post types) in pretty much as many ways as you can think of.

There are two types of WordPress taxonomy – hierarchical and non-hierarchical. In case it’s not obvious from the name, a hierarchical taxonomy has a hierarchy – that is, you can create terms that are children of a parent term (and even children of those children) – standard post categories in WordPress are an “out of the box” example of a hierarchical taxonomy.

A non-hierarchical taxonomy has no parent/child structure, and is basically just a “flat” list of terms. Post tags are the “out of the box” example here.

When you’re developing a plugin for WordPress (or maybe even a theme) you may find that you have a need to create custom taxonomies – for example, if creating a plugin for a property/real estate website, you may have a custom taxonomy for “Property Type”, that contains terms like “House”, “Apartment” etc.

It’s at this point that you may run into a bit of an annoyance with the default WordPress user interface…

WooCommerce: Use Product Images as Category Images

Update: Version 1.3.1 released on the 25th August 2020.

So, earlier this morning I found myself wishing that WooCommerce had the capability to use a product thumbnail when displaying a category link in situations where the category doesn’t have its own thumbnail defined.

I went on a bit of a hunt and found a couple of small plugins. One didn’t work at all, which I attribute mainly to it having not been updated for two years and much changing in both WordPress and WooCommerce since then, and another one that I found didn’t work until I made a couple of code changes – and had a couple of noteworthy problems;

  • it would only fetch product thumbnails from that immediate category – not delving deeper down into the category tree and fetch product thumbnails from child categories, and
  • it did no filtering for products that had no thumbnails set, so would in some cases return products that had no thumbnail

So, I’ve made my own. A zip download can be found below, you just need to drop the folder inside it into your wp-content/plugins folder and then activate the “WooCommerce Category Product Thumbnails” plugin.

I’m using WordPress 4.9.4 and WooCommerce 3.3.0 – please let me know in the comments if it doesn’t work on other versions.

Update version 1.1 –  23rd March 2018: Add option (found under WooCommerce -> Settings -> Products -> Auto Category Thumbnails) to change the image size used for the automatic thumbnails. By default it remains as “shop_thumbnail”, but you may find that “shop_catalog” is a better choice.

Download

Download the plugin from the WordPress Plugin Repository

Source

This plugin is open-source – view the source code on the GitHub repository.

My Old Game Reviews

I’ve been programming these computer-ma-whatsits since the tender age of 6, when my Dad brought home from work a Sinclair Spectrum 48K.

Well, I say that, but my time with that machine was somewhat limited as I had two brothers living at home then as well, Bob and Mike, and they were even more interested in this alien bit of kit than I was, both of them being nearly 10 years older than I was.

Nevertheless, that lovely old squidgeboard was my introduction to the world of computer programming. 48K Sinclair BASIC isn’t exactly a powerhouse of a language, but it was more than enough for my tiny brain.

I never really managed to do anything particularly great with it though – it was only after I’d migrated to the Commodore Amiga that I started really digging my teeth into the biscuit that was creating my own computer programs. Initially I used AMOS BASIC, followed by AMOS Professional, and ended up using Blitz Basic 2.

Using AMOS/AMOS Pro, I created a number of games for the Amiga that I released on Aminet in the mid-to-late 90s. At the time, I was a subscriber to Amiga Format, and they ran a seemingly popular “Reader Games” segment – kind of like Readers’ Wives, but (certainly the first couple of times) making myself look more of a tit. Naturally I submitted my games for review in this magazine section.

I present these reviews to you now, for you to make up your own mind. They’re in the order of publication.

getaddrinfo failed: A non-recoverable error occurred during a database lookup.

I faced an interesting (and by interesting, I mean incredibly frustrating) issue with a client yesterday, who had installed a PHP-based application of mine on their new Windows 7 laptop only to find that it was unable to connect to the MySQL database that powered it.

Xinha – hidden editors do not initialise correctly

As most web developers will know, there’s a plethora of tools out there on the Web that can provide What You See Is What You Get (WYSIWYG) editing capabilities within web browsers.

My weapon of choice in this arena has always been Xinha – pronounced Xena (like the Warrior Princess) – mainly because the editor itself is very configurable and easily integrates into my custom Content Management platform.

I came across an issue this morning however, where having multiple instances of the Xinha editor on a single web page – with some of the instances initially hidden, caused problems. When the hidden editors were made visible, they didn’t work properly – they were frozen and did not respond to mouse or keyboard input.

Games That Never Were: Arena

As some people may know, I’ve dabbled in the world of game development before. I’ve never been particularly good at it, if I’m honest, not really down to anything other than a lack of good ideas, and a lack of time to do any ideas I had justice.

It’s something I keep meaning to have another bash at, not in any serious manner of course, just in a “bedroom programmer” kind of way.

Still, I thought I’d make a post about a game of mine that never quite made it past development. It ranks as the most ambitious game project I ever undertook, and actually got quite far down the line.

Privacy Policy & Powered by WordPress & Theme by Anders Norén