Show a block only for specific products
In short
Open the block, turn on Enable conditional block visibility, and add a Product in cart condition with the products you want. The block then shows only when at least one of those products is in the cart. Use Variant in cart, Product type in cart or Vendor Name in cart to target more narrowly or more broadly.
✓ Applies to
- Advanced and Deluxe plans
- Any Checkout Ninja block, in any checkout position
- Products, variants, product types and vendors
✕ Doesn't apply to
- Hiding a single block type inside a block. Conditions apply to the whole block
- Hiding payment methods or changing the cart. Use checkout rules for that
Before you start
- Create and save the block you want to control. See create a block.
- Know how you’ll identify the products: specific products, specific variants, a product type or a vendor. For product type and vendor, copy the exact text from the product page in your Shopify admin.
Steps
- In Checkout Ninja, go to Blocks and open the block.
- In the Block Visibility card, turn on Enable conditional block visibility.
- Click Add new visibility condition.
- In the Condition menu, choose Product in cart.
- Under Product, select one or more products.
- Click Save.
The block now shows only when at least one of the selected products is in the cart.
Other product conditions
| Condition | Shows the block when |
|---|---|
| Product in cart | Any of the selected products is in the cart |
| Product not in cart | None of the selected products is in the cart |
| Variant in cart | Any of the selected variants is in the cart |
| Variant not in cart | None of the selected variants is in the cart |
| Product quantity in cart | The combined quantity of the selected products, across all their variants, meets the operator and Quantity you set |
| Product type in cart | A product with exactly this product type is in the cart |
| Product type not in cart | No product with this product type is in the cart |
| Vendor Name in cart | A product from exactly this vendor is in the cart |
| Vendor Name not in cart | No product from this vendor is in the cart |
Every condition with its operators: visibility conditions reference.
When a block has more than one condition, it shows if any condition matches. For example, a Product in cart condition for Product A plus another for Product B shows the block when either is in the cart. You can’t require two conditions to both match on the same block.
Verify it worked
- Go to checkout with one of the selected products in the cart. The block shows.
- Remove it and keep a different product in the cart. The block disappears. This negative check matters: if the block still shows, another condition on the block is matching, or visibility is turned off.
- If you used Product quantity in cart, test just below and just at your quantity.
Limitations
- Conditions apply to the whole block. To show different content for different products, create a separate block for each and place each Block ID in its own Custom Block app block.
- Conditions on one block are combined with OR. There’s no setting to require all of them.
- Product type in cart and Vendor Name in cart take one exact, case-sensitive value each. To match several, add one condition per value.
- There’s no collection-based condition for block visibility. Use Product in cart with the products you want, or a shared product type or vendor.
Troubleshooting
The block shows for every cart. Check that Enable conditional block visibility is on and saved. If you used a “not in cart” condition next to other conditions, remember any single match shows the block.
The block never shows. Check that you picked products, not left the Product field empty, and that you saved. For Product type in cart and Vendor Name in cart, check the spelling and capitals against the product in your admin.
Product quantity in cart doesn’t match. Pick an operator. A condition left on ”-” never matches. Enter a whole number in Quantity.
Frequently asked
If I select several products, do they all have to be in the cart? +
No. Product in cart matches when any one of the selected products is in the cart. Product not in cart matches only when none of them are.
Can I show the block when product A is in the cart AND the buyer is in a certain country? +
Not with one block. When a block has several conditions, it shows as soon as any one of them matches. Conditions are combined with OR, not AND.
Can I show the block only when a buyer has 2 or more of a product? +
Yes. Use Product quantity in cart, select the product, choose Greater Than or Equal, and enter 2. Quantities are added up across all variants of all selected products.
Does Product type in cart ignore upper and lower case? +
No. Product type and vendor names must match exactly, including capital letters, as they're written in your Shopify admin.