Top

Hide Elements on Donation Products

When you create a product to be designated for use with the donations app there's often elements you don't want to show up. For example you probably don't want the price to appear, related products, bundles etc... 

To remove an element from the page ONLY if it's a donation product wrap the following code around anything you want to hide.  

 {% unless product.metafields.bold_donation.donation_key == 1 %}

...anything you want hidden on donation pages...

  {% endunless %}

Here is an example of this

Let's say I want to remove the price from a product if it's a donation product. This is a common thing to do since the person can choose any donation price they want controlled by they app, there's no need to show the Shopify price. 

Here is what the price code might look like in your store's product.liquid

<div class="purchase">
<h2 class="price" id="price-preview">{{ variant.price | money }}{% if variant.price < variant.compare_at_price %} <del>{{ variant.compare_at_price | money }}</del>{% endif %}</h2>
</div>

To make it so this is not visible if it's a donation product I simply wrap the special donations code around as shown below in bold:

{% unless product.metafields.bold_donation.donation_key == 1 %}
<div class="purchase">
<h2 class="price" id="price-preview">{{ variant.price | money }}{% if variant.price < variant.compare_at_price %} <del>{{ variant.compare_at_price | money }}</del>{% endif %}</h2>
</div>
{% endunless %}

Have more questions? Submit a request