An addition to a WordPress website was the presentation of a number of products for viewing, but not for sale.
The products were to be listed, a thumbnail, title and excerpt text. Clicking through to the product there would be the usual details:
- title
- one or more images
- a summary
- a full description
The items should be easily managed by the client. There was a limited budget.
Rather than develop a custom WordPress plugin or use a custom field plugin, I chose to use the WooCommerce plugin to show and manage a number of product items.
By excluding the price from a product WooCommerce does not show the Buy Now button when showing the product details, or list of products. This is on a per product basis.
However, there is always the possibility that a price is added and the Buy Now button is consequently shown.
I don’t like using CSS or JavaScript to simply hide a portion of the web page. In this case protecting against accidental addition of a price. Better to keep exclusions server side rather than public/client side. I feel that it is a clumsy approach to take. If the JavaScript is not run on the page will the hidden item show? Page content can be manipulated within the browser showing content which has been hidden.
With a little customisation this can be made more robust – the initial implementation relies on the user not adding a price to the product.
The exclusion of the buy now button can be configured by code in the functions.php file. There are two parts to this:
- The price on the listings page(s).
/* * WooCommerce - Hide Prices on the Shop Page */ remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
- The price on the product summary page
/* * WooCommerce - Hide Prices on Summary page */ remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
An approach would be to return empty content for the price fields.
/*
* WooCommerce Hide Prices on Except Cart / Checkout
*/
function vntweb_remove_prices( $price, $product ) {
if ( ! is_admin() ) $price = '';
return $price;
}
add_filter( 'woocommerce_variable_sale_price_html', 'vntweb_remove_prices', 9999, 2 );
add_filter( 'woocommerce_variable_price_html', 'vntweb_remove_prices', 9999, 2 );
add_filter( 'woocommerce_get_price_html', 'vntweb_remove_prices', 9999, 2 );
But this doesn’t allow for a price to be given with no option to buy.
add_filter( 'woocommerce_is_purchasable', '__return_false');
Add an overriding filter to hide the buy now button.
I like this approach in that the pricing of the products can still be given. There is also no danger of inadvertently making a product available for purchase.
Also to completely remove the Add to Cart button add these two items
remove_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 20);
Pros
WooCommerce as a brochure of products has a ready made structure and presentation.
Its simple to deploy a gallery of categorised products.
If you wish to sell products on-line then its easy to add the extra payment and cart actions – the products are already there!
Cons
The most recognised disadvantage will be the overhead of WooCommerce itself. If you aren’t making best use of the features regards presentation then maybe a minimal custom fields approach would be more beneficial.
Like all pre-built packaged offerings, WooCommerce will most likely do all that you wish but there may be some niggling missing parts or presentation deficiencies. If you can’t live with these then unfortunately a custom built solution will be required.


