Well, it’s finally happened. I’ve actually written a plugin that might be useful to others and I’ve set it up as a public plugin on the WordPress repo.
I’ve just finished working on a site that used WooCommerce and the Stripe payment Gateway. I’d noticed during testing that orders were given a little meta data by the Stripe Gateway; what the fee was and the remaining net income.
I mentioned this to my client who said “Damn, that’s useful information. Can you make it so I can see that data?”. At first I thought there would be a setting in Woo or the Gateway pages, I couldn’t find anything. Seems that they’ve added the meta data (simply called “Stripe Fee” and “Net Revenue From Stripe”) but not really done anything with it.
This is WordPress we’re talking about here – someone will have made a plugin to show this info… Right???
Wrong! I haven’t found anything yet, Even searching for the meta names just returned the source code from Woo. No body had made something to do it.
Never one to back down from a challenge, I got to work.
It was pretty simple to add some extra rows under the order totals using the
woocommerce_admin_order_totals_after_refunded action and for a while this sated both the client and myself. However, after the site was launched I decided to flesh out this little snippet and see if it was ‘pluginable’.
After a little digging in the WooCommerce code, I found some actions and filters to hook into to add a couple of columns to the main Orders list in the admin view. Plus the option to order by those columns. Yes, yes that will do nicely.
Have a look in the Git repo: https://github.com/boswall/show-woostripe-revenue
Basically, you can use
manage_shop_order_posts_columns to add some columns and
manage_shop_order_posts_custom_column to output some HTML based on the column.
Then add your columns to
manage_edit-shop_order_sortable_columns to get sortable columns and use the
request filter to change the ordering.
Still amazed that no one had made a plugin, I decided to make… a plugin!
It was easier than I thought but working with SVN when you are used to Git is so confusing – hopefully it doesn’t need much updating.
That said, if anyone wants to add anything to this, I’m more than happy to take on pull requests on GitHub.