
List shipping zones, shipping methods and their IDs for use in custom code.
A few articles on BusinessBloomer.com about shipping in WooCommerce require the shipping method ID e.g. Hide Shipping By Shipping Class, and provide instructions to find it. It’s messy, involving looking at html source code. I’ve decided to make is much easier.
Hover reveal not an option
My first idea was to reveal the shipping method ID when you hover over the method section, like how the ‘Edit | Delete’ links show.
This html is rendered by Backbone.js. I could have written JavaScript to inject the method ID beside the Edit/Delete links but instead wrote code to produce a table of all the zones and methods. This puts all the information in one place instead of requiring the developer click into each shipping zone and hover over each method. And I could achieve this with PHP.
Back to businessbloomer.com
I copied the businessbloomer.com code to find all shipping zones and methods. Next up was to find the hook to display the information on the Shipping zones page. It needed a little tweaking to only display on the main Shipping zones page and not the ‘Shipping options’ and ‘Shipping classes’ sub pages.
I went back and forth with a simple unordered list and then a table, finally settling on a combination of the two.
Leave a Reply