How to "hide" a gift product

Learn how you can hide a product that customers should not be able to purchase

Bart Coppens avatar
Written by Bart Coppens
Updated over a week ago


  • Discount Ninja provides these tips for information only. Use the script outlined below at your own risk and modify where necessary.

  • Customers with a technical background and/or intimate understanding of Shopify's APIs will still be able to


Discount Ninja allows for products to be added to an order as a gift with purchase. These products need to be active and published to the Online Store channel.

To avoid customers adding more than the allowed amount of gifts to their order, we advise setting a price for the gift products. Gifts have a 100% discount, ensuring the price is reduced to zero for the gift products at checkout. The app knows how many gifts are allowed per order and charges the full amount for any surplus gifts that the customer has added to the order.

If you set the price of the gift product to zero, you run the risk that customers will add more gifts than allowed. If there is no price associated with the gift product the customer will not be charged for surplus gifts at checkout.

Discount Ninja can automatically add (and remove) the gift products to the cart (and therefore to the order), based on the rules of the promotion.

The tips below are useful if you want to avoid that customers can add the gift products manually.

How customers can discover (and order) gift products manually

Customers can add gift products in the same ways as any other product in your store. That is to say, they can find them in the following ways:

  • Collection page

  • Search results

  • Link to the product page (from cart page for example)

  • Via a search engine

To avoid customers finding the product, you'll need to implement logic to avoid each of those scenarios.

Marking products as gift products

First, we'll add a tag to those products that we don't want to be sellable, in other words, the gift products that we do not want customers to find and add to the cart manually.

IMPORTANT: the case of the tag matters. gwp is not the same as GWP.

To do this, open the product in Shopify and add the tag to the product. In this example, we're using the tag GWP, but you can choose a different name for your tag:

Product page

To avoid that customers can access the product page, add the following script at the top of the product template (product.liquid file):

{%- if product.tags contains 'GWP' -%}
{%- endif %}

This script detects products with a specific tag (in the above example GWP) and redirects the customer to the home page of the shop if the product has the tag.

Collection page

Find the collection template that contains the for loop that loops over the products in a collection.

Place the following script inside that for loop:

{%- assign limoniapps_discountninja_product = product -%}
{%- if limoniapps_discountninja_product.object_type == 'product' -%}
{%- if limoniapps_discountninja_product.tags contains 'GWP' -%}
{%- continue -%}
{%- endif -%}
{%- endif -%}

This script detects products with a specific tag (in the above example GWP) and filters them out. That is to say, the product card for those products with the GWP tag is not rendered on the collection page.

The above script expects to be placed in a for loop that loops over the products in a collection with the variable name product. Change the assign statement if the variable name is different.

Search results

Use the same logic for the search results.

Place the script in the for loop that renders the search results.

Search engine

Avoid that products are indexed by search engines.

In the theme.liquid, add the following to the head section:

{%- if template == 'product' and product.tags contains 'GWP' -%}<meta name='robots' content='noindex'>{%- endif -%}
Did this answer your question?