Shop Gift card object is not working.

Topic summary

A developer is experiencing issues with Shopify’s shop.accepts_gift_cards Liquid object when trying to conditionally display a homepage section based on gift card availability.

The Problem:

  • An if/else condition using {% if shop.accepts_gift_cards == true %} is not working as expected
  • The section displays on the homepage regardless of whether gift cards are activated or deactivated in the store
  • The object appears to always return true, even when all gift cards are disabled

Code Context:

  • The developer created a custom section with the conditional logic
  • The code snippet shows a standard Liquid template structure with the gift card check at the top
  • The schema portion was not included in the shared code

Current Status:

  • Another user (Liam) referenced a related discussion thread addressing the same query
  • The issue remains unresolved, with the developer confirming the object consistently returns true regardless of actual gift card status in the store
  • No solution or workaround has been identified yet
Summarized with AI on November 17. AI used: claude-sonnet-4-5-20250929.

I have tried the if/else condition with giftcard object, so that I can hide a section in homepage basis on the giftcard(if the shop is accepting the giftcard then only it will be displayed) but it is not working as expected. I have created a different section just for giftcard with this condition in theme files, but the section use to display irrespective of the if/else condition i.e. even when I have deactivated all the giftcards from store the section is displaying on the homepage it doesn’t hide automatically? Can you please specify if I am doing something wrong here?

Why is this condition not working here?

Here is the code of the section:

Please note: I haven’t copied the schema here, but my main concern is why this if/else condition is not working?

{% if shop.accepts_gift_cards == true %}
  
    {%- liquid
      assign has_background_color = false
    
      if section.settings.background_color != blank and section.settings.background_color != 'rgba(0,0,0,0)'
        assign has_background_color = true
      endif
    
      assign show_animations = false
      if settings.enable_section_animations and section.settings.enable_animation
        assign show_animations = true
      endif
    -%}
    
    {%- capture image_sizes -%}
      {%- if section.settings.show_small_image -%}
        (min-width: 720px) calc(calc(50vw - clamp(18px, 3.3vw, 3.3vw)) * .93), calc((100vw - 80px) * .93)
      {%- else -%}
        (min-width: 720px) calc(calc(50vw - clamp(18px, 3.3vw, 3.3vw)), calc(100vw - 80px)
      {%- endif -%}
    {%- endcapture -%}
    
    {%- capture section_classes -%}
      section section--divider-{{ section.settings.divider_style }}
      {{ section.settings.section_padding }}
    {%- endcapture -%}
    
    <div
      class="
        image-with-text
        image-with-text--justify-{{ section.settings.text_alignment }}
        image-with-text--image-{{ section.settings.image_position }}
        {% unless section.settings.image_caption == blank %}
          image-with-text--has-image-caption
        {% endunless %}
        {% if section.settings.show_small_image %}
          image-with-text--has-small-image
        {% endif %}
        {% unless has_background_color %}
          {{ section_classes }}
        {% endunless %}
        {% if show_animations %}
          animation
          animation--image-with-text
        {% endif %}
      "
      data-section-id="{{ section.id }}"
      data-section-type="image-with-text"
      style="
        --section-background-color: {{ section.settings.background_color }};
        --color-text: {{ section.settings.text_color }};
        --color-text-alpha-60: {{ section.settings.text_color | color_modify: 'alpha', 0.6 }};
        --color-text-link: {{ section.settings.text_color }};
        --text-alignment: {{ section.settings.text_alignment }};
        --small-image-placeholder-color: {{ settings.color_text | color_modify: 'alpha', 0.7 }};
        {% render 'overlay-button-vars' with color_button_text: section.settings.button_text_color, color_button_background: section.settings.button_background_color %}
      "
    >
      <div
        class="
          image-with-text__inner
          {% if has_background_color %}
            {{ section_classes }}
          {% endif %}
        "
      >
        <div class="image-with-text__content">
          <div class="image-with-text__image-container">
            <div class="image-with-text__image-container-inner">
              <figure class="image-with-text__image-wrapper">
                {%-
                  render 'image' with
                  wrapper_class: "image-with-text__image",
                  image: section.settings.image,
                  sizes: image_sizes,
                  aspect_ratio: section.settings.aspect_ratio,
                  focal_point: section.settings.focal_point,
                  include_placeholder: true,
                  animate: show_animations
                -%}
    
                {%- unless section.settings.image_caption == blank -%}
                  <figcaption class="image-with-text__image-caption ff-body fs-body-50">
                    {{ section.settings.image_caption }}
                  </figcaption>
                {%- endunless -%}
              </figure>
    
              {%- if section.settings.show_small_image -%}
                <div class="image-with-text__small-image-wrapper">
                  {%-
                    render 'image' with
                    wrapper_class: "image-with-text__small-image",
                    image: section.settings.image_small,
                    sizes: "(max-width: 720px) calc(90vw * .42), (max-width: 1500px) calc(50vw * .42), 300px",
                    aspect_ratio: section.settings.image_small_aspect_ratio,
                    focal_point: section.settings.image_small_focal_point,
                    include_placeholder: true,
                    animate: show_animations
                  -%}
                </div>
              {%- endif -%}
            </div>
          </div>
    
          <div class="image-with-text__text-container">
            <div
              class="
                image-with-text__text-container-inner
                section-blocks
                {% if show_animations %}animation--section-blocks{% endif %}
              "
            >
              {%- for block in section.blocks -%}
                {%- case block.type -%}
                  {%- when 'accent' -%}
                    {%- unless block.settings.accent == blank -%}
                      <p class="image-with-text__text-container-accent fs-accent section-blocks__accent">
                        {{ block.settings.accent }}
                      </p>
                    {%- endunless -%}
                  {%- when 'heading' -%}
                    {%- unless block.settings.title == blank -%}
                      <h2 class="image-with-text__text-container-heading ff-heading {{ block.settings.heading_font_class }} section-blocks__heading">
                        {{ block.settings.title }}
                      </h2>
                    {%- endunless -%}
                  {%- when 'subheading' -%}
                    {%- unless block.settings.subheading == blank -%}
                      <h2 class="image-with-text__text-container-subheading ff-subheading {{ block.settings.subheading_font_class }} section-blocks__subheading">
                        {{ block.settings.subheading }}
                      </h2>
                    {%- endunless -%}
                  {%- when 'text' -%}
                    {%- unless block.settings.text == blank -%}
                      <div class="image-with-text__text-container-text rte ff-body {{ block.settings.text_font_class }} section-blocks__text">
                        {{ block.settings.text }}
                      </div>
                    {%- endunless -%}
                  {%- when 'image' -%}
                    {%-
                      render 'image-block' with
                      shopify_attributes: block.shopify_attributes,
                      wrapper_class: 'image-with-text__text-container-image section-blocks__image  section-blocks__image',
                      image: block.settings.image,
                      width: block.settings.image_size,
                      mobile_width: block.settings.image_size_mobile,
                      break_to_mobile_at: '720',
                      align: section.settings.text_alignment
                    -%}
                  {%- when 'button' -%}
                    {%-
                      render 'button-block' with
                      wrapper_class: "image-with-text__text-container-button section-blocks__button",
                      link: block.settings.link,
                      label: block.settings.link_text,
                      button_style: block.settings.button_style,
                      is_overlay: true,
                      button_alignment: section.settings.text_alignment,
                      buttons_can_inline: true,
                      forloop: forloop
                    -%}
                  {%- when 'play-button' -%}
                    {%-
                      render 'play-button-block' with
                      wrapper_class: 'image-with-text__text-container-play-button section-blocks__video-button',
                      shopify_attributes: block.shopify_attributes,
                      poster_image: block.settings.poster_image,
                      poster_aspect: block.settings.aspect_ratio,
                      video_url: block.settings.video_url,
                      label: block.settings.text,
                      button_alignment: section.settings.text_alignment,
                      icon_style: block.settings.icon_style
                    -%}
                  {%- when 'border' -%}
                    {%- render 'border-block' -%}
                  {%- when 'spacer' -%}
                    {%- render 'spacer-block' with space: block.settings.space -%}
                {%- endcase -%}
              {%- endfor -%}
            </div>
          </div>
        </div>
      </div>
    </div>
{% endif %}
1 Like

Where you want me to reply? As there is no way I can connect with you over your inbox.

Hi Sahilrev - I replied to this query here: https://community.shopify.com/c/online-store-and-theme/can-we-hide-a-section-on-home-page-if-the-gift-card-is-not/m-p/2211444/highlight/true#M8291

Hi @Liam but there is an issue with the object as it’s always returning true instead of all the gift cards are disabled in the store. No matter what it is just returning true value.