// Add checkbox to product edit page to show/hide price add_action('woocommerce_product_options_general_product_data', function() { woocommerce_wp_checkbox(array( 'id' => '_cgp_hide_price', 'label' => __('Hide Price in Catalog', 'cgp-catalog'), 'description' => __('Check this to hide the product price on shop/category/tag pages.', 'cgp-catalog'), 'desc_tip' => true, )); }); // Save the checkbox value add_action('woocommerce_process_product_meta', function($post_id) { $hide_price = isset($_POST['_cgp_hide_price']) ? 'yes' : 'no'; update_post_meta($post_id, '_cgp_hide_price', $hide_price); }); // Conditionally hide price on frontend add_filter('woocommerce_get_price_html', function($price, $product) { if (is_shop() || is_product_category() || is_product_tag()) { $hide_price = get_post_meta($product->get_id(), '_cgp_hide_price', true); if ($hide_price === 'yes') { return ''; // hide the price } } return $price; }, 10, 2);