In WooCommerce you have publicly accessible product archives for product categories e.g. “all tables“, product tags e.g. “all casual” and product attributes e.g. “all medium“. URLs are available to you and you can even define their custom permalink slug base via the settings e.g. /product-tag/, /product-cat/, etc.
What’s interesting though, is that there are many more “custom taxonomies” that are registered in WooCommerce, however they don’t seem to have their own archive, because it’s been decided they were not useful.
But what if you want to see, as a customer, all the shop products belonging to a specific shipping class? We’ve seen, for example, how to split the cart into packages based on shipping class – so it would be super helpful to customers, in such a case, to view all the products belonging to each shipping class at a given URL.
So, let’s do that!
PHP Snippet: Product Archive for WooCommerce Shipping Classes
Note: you may need to resave the WordPress permalinks once the snippet below is active. Also, please note that the archive pages will use the shipping class slug, and the “slug base” you set inside the snippet – the URL will be e.g. example.com/SLUG_BASE/shipping_class_slug
/**
* @snippet Product Archive for Shipping Classes
* @tutorial Get CustomizeWoo.com FREE
* @author Rodolfo Melogli, Business Bloomer
* @compatible WooCommerce 8
* @community Join https://businessbloomer.com/club/
*/
add_filter( 'woocommerce_taxonomy_args_product_shipping_class', 'bbloomer_taxonomy_args_product_shipping_class' );
function bbloomer_taxonomy_args_product_shipping_class( $args ) {
$args['query_var'] = true;
$args['rewrite'] = array(
'slug' => 'vendor', // SLUG_BASE
);
return $args;
}