Hidden Product Mode WordPress Function
What it does?
-
Per-product toggle in admin: Enable a “hidden/contact-only” mode right from the product editor.
-
Removes purchase paths: Marks the item as not purchasable, removes the add-to-cart UI on the product page, and blocks add-to-cart validation anywhere (including direct links).
-
Catalog & SEO controls: Sets catalog visibility to hidden and applies a noindex directive (via Rank Math, if present) to keep it out of search results.
-
Clear lead capture: Injects a Contact us button on the product page; the URL is WPML-aware for the correct language route.
-
Defense in depth:
-
CSS: Hides price, wishlist, and any cart controls.
-
JS fallback: If a theme/plugin bypasses hooks, hides purchase elements and inserts the contact button client-side.
-
-
Global cart validation: Prevents hidden items from being added from anywhere on the site.
Why it’s useful?
-
Perfect for quote-only or custom items: Showcase products without allowing checkout—ideal for made-to-order, B2B, MAP-restricted, or high-touch sales.
-
Avoids SEO/UX pitfalls: Keeps hidden items out of search while giving users a clear next step (contact), reducing confusion and support load.
-
Multilingual ready: Contact button respects language routing for international stores.
-
Reliable & resilient: Multiple layers (server, CSS, JS) ensure the product can’t be purchased even if a theme or plugin overrides parts of the template.
