WooCommerce One Page Checkout is a premium plugin that let’s you create a page that shows a product, or a list of products, and the checkout form.
From that page, your customers can add products to their cart and buy them from the same page, without having to visit more different pages to complete the checkout process.
That is amazing, because less clicks and distractions means more chances that the user converts to a customer.
One Page Checkout allows you to specify which products to show on the page, and obviously they will show also on the default Shop page of your site and customers will be able to buy it also in the normal way they do with WooCommerce.
Sometimes though, that is not what you want. You created a landing page to sell a special product in your store, and you don’t want to show that product also in the catalog. How can you solve that?
The first thing you think to do is to go edit that product and change its visibility to Hidden. And then it’s hidden both in the catalog and in the One Page Checkout page.
Did you think that it was going to work eh?
If you think about it, it makes sense that it does not show now. It’s hidden, why should it show on the One Page Checkout page if it is not supposed to show on the catalog? The product is not purchasable, there must be a reason if it’s hidden.
But there’s a filter in One Page Checkout that allows you to change the visibility settings allowed, so you can show hidden products on the One Page Checkout page but not on the catalog.
Open the file functions.php located in wp-content/themes/your-theme-name/ and add this code at the end of the file:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'wcopc_products_query_args', 'wc_opc_show_hidden_products' ); | |
function wc_opc_show_hidden_products( $args ) { | |
if ( isset( $args['meta_query'] ) ) { | |
array_push( $args['meta_query'][0]['value'], 'hidden' ); | |
} | |
return $args; | |
} |
After doing so, the product will show only on the One Page Checkout page, but not in the catalog.
Leave a Reply