Tag: woocommerce

0

WooCommerce: Purchase Order Payment Gateway

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.

Plugin Features

  • Adds an offline payment gateway for WooCommerce with the name Purchase Order
  • Allows the administrator to set the plugin to ask for a Purchase Order number (or not) – and whether to make it mandatory if one is asked for
  • Has a setting that gets the plugin to ask for a postal address for the invoice to be sent to
  • Has another setting that, if an address is being asked for, will pre-fill the address with the customer’s billing address if they are logged in to WooCommerce during checkout
  • Adds the submitted Purchase Order details to the Edit Order screen in the WooCommerce back-end
  • Has full internationalisation (i18n) and localisation (l10n) support – so if you want to translate the plugin into your own language, please get in touch!

Screenshot

The gateway itself looks very straightforward – the screenshot below has the “ask for address” options turned off, though. When turned on, the plugin asks for a Contact Name, Company/Organisation, and an address (two lines, plus city, county and postcode).

In the WordPress back-end, Purchase Order information is shown under the General Details section on the Edit Order screen:

Installation

As with all WordPress plugins, you just need to drop the plugin folder into your wp-content/plugins folder and then activate the “GazChap’s WooCommerce Purchase Order Payment Gateway” plugin.

Requirements

I’m using WordPress 4.9.4 and WooCommerce 3.2.6 – please let me know in the comments if it doesn’t work on other versions. I believe it requires at least WooCommerce 3.0.0.

Download

Download the plugin from the WordPress Plugin Repository (5.2KiB Zip)

Source

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

14

WooCommerce: Use Product Images as Category Images

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 the plugin (2.30 KiB Zip, version 1.1)