# "Price on Request" for a Category

> Hides prices and the Add to Cart button for products in chosen categories and shows a "Request a price" button that links to your contact page.

- Type: PHP
- Runs: Run everywhere
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, catalog, prices, quotes
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-category-price-on-request/

## Code

```php
$wpide_por = array(
    'categories' => array( 'bespoke' ), // Category slugs.
    'label'      => 'Price on request',
    'button'     => 'Request a price',
    'url'        => '/contact/',        // Contact page URL.
);

$wpide_por_match = function ( $product ) use ( $wpide_por ) {
    $id = $product->get_parent_id() ? $product->get_parent_id() : $product->get_id();

    return has_term( $wpide_por['categories'], 'product_cat', $id );
};

add_filter( 'woocommerce_get_price_html', function ( $html, $product ) use ( $wpide_por, $wpide_por_match ) {
    return $wpide_por_match( $product ) ? '<span class="wpide-por">' . esc_html( $wpide_por['label'] ) . '</span>' : $html;
}, 20, 2 );

add_filter( 'woocommerce_is_purchasable', function ( $purchasable, $product ) use ( $wpide_por_match ) {
    return $purchasable && ! $wpide_por_match( $product );
}, 10, 2 );

add_action( 'woocommerce_single_product_summary', function () use ( $wpide_por, $wpide_por_match ) {
    global $product;

    if ( $product instanceof WC_Product && $wpide_por_match( $product ) ) {
        printf(
            '<p><a class="button alt wpide-por-button" href="%s">%s</a></p>',
            esc_url( add_query_arg( 'product', rawurlencode( $product->get_name() ), home_url( $wpide_por['url'] ) ) ),
            esc_html( $wpide_por['button'] )
        );
    }
}, 30 );
```

## Notes

The product title is added to the contact link as ?product=, which form plugins can use to prefill a field.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find ""Price on Request" for a Category" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
