# "Available In Store Only" Products by Category

> Lets customers browse products from chosen categories online but removes the Add to Cart button and shows an "available in store only" message instead.

- Type: PHP
- Runs: Run everywhere
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, catalog, categories, purchasing
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-category-in-store-only/

## Code

```php
$wpide_store_only = array(
    'categories' => array( 'furniture' ),                                      // Category slugs.
    'message'    => 'Available in our showroom only. Call us to reserve one.', // Shown instead of Add to Cart.
);

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

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

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

add_action( 'woocommerce_single_product_summary', function () use ( $wpide_store_only, $wpide_store_only_match ) {
    global $product;

    if ( $product instanceof WC_Product && $wpide_store_only_match( $product ) ) {
        printf( '<p class="wpide-store-only">%s</p>', esc_html( $wpide_store_only['message'] ) );
    }
}, 31 );

add_filter( 'woocommerce_product_add_to_cart_text', function ( $text, $product ) use ( $wpide_store_only_match ) {
    return $wpide_store_only_match( $product ) ? 'View details' : $text;
}, 10, 2 );
```

## Notes

Products stay visible with their price; add your opening hours or address to the message.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find ""Available In Store Only" Products by 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/
