Available metafields
Create the following metafields as Product variant definitions in Shopify. The namespace isfirmhouse.
An unset metafield does not add a restriction.
firmhouse.requires_selling_plans does not by itself require a subscription; combine it with firmhouse.requires_subscription when a variant must be a subscription and only specific selling plans are allowed.
Do not set both firmhouse.requires_subscription and firmhouse.requires_otp to true on the same variant. One blocks one-time purchases and the other blocks subscription purchases, leaving no valid purchase option.
Metafields must be defined for Variants, not Products. The validation reads the selected variant’s values.
Create the metafield definitions
- In Shopify admin, go to Settings > Metafields and metaobjects.
- In the Metafields section, select Variants.
- Click Add definition.
- Enter a descriptive name, such as
Requires subscription. - Change Namespace and key to the exact value from the table, such as
firmhouse.requires_subscription. - Select the recommended type from the table.
- Click Save.
- Repeat these steps for each restriction you need.
firmhouse.requires_selling_plans, choose Single line text, then change One value to List of values. Add each allowed selling plan as its full Shopify global ID, for example gid://shopify/SellingPlan/1234567890.
Set restrictions on a variant
- In Shopify admin, go to Products and open the product.
- Open the variant you want to restrict.
- In the Metafields section, set the applicable Firmhouse values.
- Click Save.
Turn on the checkout rule
- In Shopify admin, go to Settings > Checkout.
- In Checkout rules, click Add rule.
- Select the Firmhouse Cart and checkout validation rule.
- Save the rule, then click Turn on.
Test the validation
Test each configured variant in your storefront:- For
firmhouse.requires_subscription, try adding the variant without a selling plan. Checkout should be blocked. - For
firmhouse.requires_otp, try adding the variant with a selling plan. Checkout should be blocked. - For
firmhouse.requires_selling_plans, try one allowed and one unlisted selling plan. Only the unlisted plan should be blocked.
Troubleshooting
If checkout is not blocked, check that:- the checkout rule is turned on in Shopify;
- the metafield definition belongs to Variants;
- the namespace and key match the table exactly;
- the metafield value is set on the variant being added to the cart; and
- every entry in
firmhouse.requires_selling_plansis a full selling plan ID, not a selling plan group ID or display name.