Skip to content

Early-bird lifetime licence: $199 once, for the first 200 buyers only. See the offer

Prices for logged-in customers only

Visitors who aren’t logged in see “Log in to see prices” instead of prices, and can’t add to the cart. For wholesale and trade shops.

  • Type PHP
  • Runs Everywhere (runs as WordPress loads)
  • Needs WooCommerce
  • Category WooCommerce
  • Tested with WordPress 7.1, WooCommerce 11.1

Before you switch it on: Nothing to fill in: it stays off after installing because visitors can no longer buy. Translate the link text, then switch it on.

It arrives switched off, even when you install its whole pack with "Switch on after installing".

PHP
<?php

add_filter(
	'woocommerce_get_price_html',
	static function ( $html ) {
		if ( is_user_logged_in() ) {
			return $html;
		}
		return '<a class="snipfire-login-price" href="' . esc_url( wc_get_page_permalink( 'myaccount' ) ) . '">Log in to see prices</a>';
	},
	99
);
add_filter( 'woocommerce_is_purchasable', static fn( $purchasable ) => is_user_logged_in() ? $purchasable : false, 99 );
add_filter( 'woocommerce_variation_is_purchasable', static fn( $purchasable ) => is_user_logged_in() ? $purchasable : false, 99 );

Good to know

Page caches must skip logged-in users (most do). Prices are still in the product feed and REST API: use a membership plugin for real secrecy. Translate the link text.

In these packs

Move your snippets over this afternoon.

Importing changes nothing until you switch over, and your old shortcodes keep working.