diff --git a/packages/billing/core/src/create-billing-schema.ts b/packages/billing/core/src/create-billing-schema.ts index ce4f9c875..c0d79ad39 100644 --- a/packages/billing/core/src/create-billing-schema.ts +++ b/packages/billing/core/src/create-billing-schema.ts @@ -252,6 +252,11 @@ const ProductSchema = z description: 'Highlight this product. Displayed to the user.', }) .optional(), + hidden: z + .boolean({ + description: 'Hide this product from being displayed to users.', + }) + .optional(), plans: z.array(PlanSchema), }) .refine((data) => data.plans.length > 0, { diff --git a/packages/billing/gateway/src/components/plan-picker.tsx b/packages/billing/gateway/src/components/plan-picker.tsx index cbb291ba4..c186864aa 100644 --- a/packages/billing/gateway/src/components/plan-picker.tsx +++ b/packages/billing/gateway/src/components/plan-picker.tsx @@ -108,6 +108,11 @@ export function PlanPicker( const isRecurringPlan = selectedPlan?.paymentType === 'recurring' || !selectedPlan; + // Always filter out hidden products + const visibleProducts = props.config.products.filter( + (product) => !product.hidden, + ); + return (
- {props.config.products.map((product) => { + {visibleProducts.map((product) => { const plan = product.plans.find((item) => { if (item.paymentType === 'one-time') { return true; diff --git a/packages/billing/gateway/src/components/pricing-table.tsx b/packages/billing/gateway/src/components/pricing-table.tsx index 85adcc331..8e0a03b80 100644 --- a/packages/billing/gateway/src/components/pricing-table.tsx +++ b/packages/billing/gateway/src/components/pricing-table.tsx @@ -54,6 +54,9 @@ export function PricingTable({ const intervals = getPlanIntervals(config).filter(Boolean) as Interval[]; const [interval, setInterval] = useState(intervals[0]!); + // Always filter out hidden products + const visibleProducts = config.products.filter((product) => !product.hidden); + return (
@@ -72,7 +75,7 @@ export function PricingTable({ ' justify-center lg:flex-row lg:space-x-4' } > - {config.products.map((product) => { + {visibleProducts.map((product) => { const plan = product.plans.find((plan) => { if (plan.paymentType === 'recurring') { return plan.interval === interval;