How can I modify the sale banner text in Turbo Theme?

Hi!

I need to change the text of the “sale” bagde to an automatic discount percentage calculation. Im al ready edit the code of “product-template.liquid” for this:

{% if product.compare_at_price_max > product.price %}-{{ product.compare_at_price_max | minus: product.price | times: 100.0 | divided_by: product.compare_at_price_max | money_without_currency | times: 100 | remove: '.0'}}%

But it doesn’t work and it only shows -0% always

Also on the home page nothing appears

I hope someone can help me please.

The theme i’m using is Turbo Theme and the url of the store is https://tienda-movilockers.myshopify.com/

Thank you!

@Dani_Guti

sorry for that issue i have checked but i can that code but can you please try this

https://liquify.design/shopify-developer-guide-display-percentage-discount-shopify/

Hi!

Thanks for your answer! but as i understand, the solution you share is for show the discount next to the price. And what i need is show the discount in the sale tag (the red sticker over the image) like this:

But mine shows nothing :disappointed_face:

@Dani_Guti

sorry for that are added code but i can’t see where do i check this

No problem!

mmm, i dont know if this will help but this is the entire code of my section “product-template.liquid1” after i added the new code to calculate the discount on the tag. The code for this is in line 32.

I hope you can help me to find the solution.

{% comment %}
** Product - default view **
- Product template
{% endcomment %}

{% if section.settings.product_breadcrumb == false %}
  {% style %}
    .breadcrumb__wrapper {
      display: none;
    }
  {% endstyle %}
{% endif %}

  

    

      {% render 'product-images',
              product: product,
              video_looping: section.settings.video_looping,
              set_product_height: section.settings.set_product_height
      %}
    

    
      {%- assign collection_handles = product.collections | map: 'handle' -%}
      {%- assign variant = product.selected_or_first_available_variant -%}

      {% if product.available %}
        {% if settings.sale_banner_enabled and product.compare_at_price > product.price %}
          
{{ 'collections.general.sale' | t }}
    {% if product.compare_at_price_max > product.price %}-{{ product.compare_at_price_max | minus: product.price | times: 100.0 | divided_by: product.compare_at_price_max | money_without_currency | times: 100 | remove: '.0'}}%
       

        {% endif %}
      {% endif %}
{% endif %}
      {% if collection_handles contains 'new' %}
        {{ 'collections.general.new' | t }}

      {% endif %}
      {% if collection_handles contains 'pre-order' %}
        {{ 'collections.general.pre_order' | t }}

      {% endif %}

      {% if section.settings.display_vendor %}
        

          {{ product.vendor | link_to_vendor }}
        

      {% endif %}

      {% if variant.sku != blank and section.settings.display_sku %}
        

          {{ variant.sku }}
        

      {% endif %}
      # {{ product.title }}
      {% if section.settings.enable_shopify_product_badges and settings.enable_shopify_review_comments %}
        
      {% endif %}
      

      {%- assign product_tags = product.tags | join: ' ' -%}
      {% if product_tags contains 'meta-size-chart-' %}
        {% for tag in product.tags %}
          {% if tag contains 'meta-size-chart-' %}
            {{ 'products.product.size_chart' | t }} 
            {% render 'popup-size-chart', product_id: product.id %}
          {% endif %}
        {% endfor %}
      {% elsif settings.size_chart != blank %}
        {{ 'products.product.size_chart' | t }} 
      {% endif %}

      {% if collection_handles contains 'coming-soon' %}
        

{{ 'collections.general.coming_soon' | t }}

      {% else %}
        
          {% unless product.available == false and settings.display_price == false %}
            

              
                
                  {% if variant.price > 0 %}
                    {% render 'price-element', price: variant.price %}
                  {% else %}
                    {{ settings.free_price_text }}
                  {% endif %}
                
              
              
                {% if variant.price < variant.compare_at_price %}
                  {{ 'products.product.savings' | t }}  {{ variant.compare_at_price | minus: variant.price | times: 100 | divided_by: variant.compare_at_price }}% ({%- assign compare_at = variant.compare_at_price | minus: variant.price -%}{% render 'price-element', price: compare_at %})
                {% endif %}
              
              {% if section.settings.display_savings %}
                
                  {% if variant.price < variant.compare_at_price %}
                    {{ 'products.product.savings' | t }}  {{ variant.compare_at_price | minus: variant.price | times: 100 | divided_by: variant.compare_at_price }}% ({%- assign compare_at = variant.compare_at_price | minus: variant.price %}{% render 'price-element', price: compare_at -%})
                  {% endif %}
                
            {% endif %}
            

          {% endunless %}
          
            {% if variant.available == false %}{{ settings.sold_out_text }}{% endif %}
          

        

      {% endif %}

      {% if section.settings.product_description_position == "top" %}
        {% if product.description != blank %}
          
            {{ product.description | split: '' | first }}
          

        {% endif %}
      {% endif %}

      {% unless collection_handles contains 'coming-soon' %}
        {% render 'product-form',
                context: 'product',
                collection_handles: collection_handles
        %}
        {% render 'product-notify-me', product: product %}
      {% endunless %}

      {% if section.settings.product_description_position == "bottom" %}
        {% if product.description != blank %}
          
            {{ product.description | split: '' | first }}
          

        {% endif %}
      {% endif %}

      {% if section.settings.review_position == "next_to_gallery" %}
        
          
{{ product.metafields.spr.reviews }}

        

      {% endif %}

      {% if section.settings.display_collections or section.settings.display_tags or section.settings.display_type %}
        
          {% if section.settings.display_collections %}
            

              {{ 'products.product.collections' | t }}:
              
                {% for col in product.collections %}
                  {{ col.title }}{% unless forloop.last %},{% endunless %}
                {% endfor %}
              
            

          {% endif %}

          {% if section.settings.display_type %}
            

              {{ 'products.product.product_types' | t }}:
              {{ product.type | link_to_type }}
            

          {% endif %}

          {% if section.settings.display_tags %}
            

              {% for tag in product.tags %}
                {% if forloop.first %}
                  {{ 'products.product.tags' | t }}:
                {% endif %}

                {% unless tag contains 'meta-' %}
                  
                    {{ tag }}{% unless forloop.last %},{% endunless %}
                    
                {% endunless %}
              {% endfor %}
            

          {% endif %}
        

      {% endif %}

      
        {% if section.settings.display_social_buttons %}
          {% render 'social-buttons', context: 'product' %}
        {% endif %}
      

    

  

{% if product.description contains ""  %}
  

  

    

      {{ product.description | split: '' | last }}
    

  

{% endif %}

{% if section.settings.review_position == "below_gallery" %}
  
    
{{ product.metafields.spr.reviews }}

  

{% endif %}

{% if section.settings.display_recently_viewed %}
  {% include 'include-recently-viewed' %}
{% endif %}

{% if section.settings.set_product_height %}
  {% style %}
    .gallery-wrap model-viewer {
      min-height: {{ section.settings.product_height }}px;
    }

    .gallery-wrap .product_gallery img,
    .gallery-wrap .product_gallery .plyr--html5 video,
    .gallery-wrap .product_gallery .plyr--youtube {
      max-height: {{ section.settings.product_height }}px;
    }
  {% endstyle %}
{% endif %}

{% comment %} Shopify-XR {% endcomment %}
{% if product.media %}
  
{% endif %}

{% schema %}
  {
    "name": "Product",
    "class": "shopify-section--product-template has-sidebar-option",
    "settings": [
      {
        "type": "header",
        "content": "Product gallery"
      },
      {
        "type": "checkbox",
        "id": "product_thumbs",
        "label": "Show thumbnails",
        "default": true
      },
      {
        "type": "checkbox",
        "id": "gallery_arrows",
        "label": "Show arrows",
        "info": "Only applies to desktop",
        "default": true
      },
      {
        "type": "checkbox",
        "id": "enable_product_lightbox",
        "label": "Enable lightbox",
        "default": true
      },
      {
        "type": "checkbox",
        "id": "activate_zoom",
        "label": "Magnify product images on hover"
      },
      {
        "type": "range",
        "id": "slideshow_speed",
        "label": "Gallery speed",
        "min": 0,
        "max": 6,
        "unit": "sec",
        "default": 0,
        "info": "Set to 0 to disable autoplay."
      },
      {
        "type": "select",
        "id": "slideshow_animation",
        "label": "Transition",
        "options": [
          {
            "value": "slide",
            "label": "Slide"
          },
          {
            "value": "fade",
            "label": "Fade"
          }
        ],
        "default": "slide"
      },
      {
        "type": "select",
        "id": "thumbnail_position",
        "label": "Thumbnails",
        "default": "bottom",
        "options": [
          {
            "value": "bottom",
            "label": "Bottom"
          },
          {
            "value": "left",
            "label": "Left"
          },
          {
            "value": "right",
            "label": "Right"
          }
        ]
      },
      {
        "type": "checkbox",
        "id": "enable_thumbnail_slider",
        "label": "Enable thumbnail slider",
        "default": true
      },
      {
        "type": "header",
        "content": "Product information"
      },
      {
        "type": "checkbox",
        "id": "display_vendor",
        "label": "Show vendor"
      },
      {
        "type": "checkbox",
        "id": "product_breadcrumb",
        "label": "Show breadcrumb links"
      },
      {
        "type": "checkbox",
        "id": "display_sku",
        "label": "Show SKU"
      },
      {
        "type": "checkbox",
        "id": "display_collections",
        "label": "Show collections"
      },
      {
        "type": "checkbox",
        "id": "display_type",
        "label": "Show type"
      },
      {
        "type": "checkbox",
        "id": "display_tags",
        "label": "Show tags"
      },
      {
        "type": "checkbox",
        "id": "display_social_buttons",
        "label": "Show social media share icons",
        "default": true
      },
      {
        "type": "radio",
        "id": "product_description_position",
        "label": "Description position",
        "options": [
          {
            "value": "top",
            "label": "Above product form"
          },
          {
            "value": "bottom",
            "label": "Below product form"
          }
        ]
      },
      {
        "type": "checkbox",
        "id": "display_savings",
        "label": "Show price savings",
        "default": true
      },
      {
        "type": "header",
        "content": "Dynamic checkout button"
      },
      {
        "type": "checkbox",
        "id": "show_payment_button",
        "label": "Show dynamic checkout button",
        "default": true,
        "info": "Each customer will see their preferred payment method from those available on your store, such as PayPal or Apple Pay. [Learn more](https://help.shopify.com/manual/using-themes/change-the-layout/dynamic-checkout)"
      },
      {
        "type": "header",
        "content": "Media",
        "info": "Learn more about [media types](https://help.shopify.com/en/manual/products/product-media)"
      },
      {
        "type": "radio",
        "id": "product_images_position",
        "label": "Media position",
        "options": [
          {
            "value": "left",
            "label": "Left"
          },
          {
            "value": "right",
            "label": "Right"
          }
        ]
      },
      {
        "type": "checkbox",
        "id": "set_product_height",
        "label": "Set height of product media",
        "default": false
      },
      {
        "type": "range",
        "id": "product_height",
        "label": "Product media height",
        "min": 200,
        "max": 800,
        "step": 10,
        "default": 500,
        "unit": "px"
      },
      {
        "type": "checkbox",
        "id": "video_looping",
        "label": "Enable video looping",
        "default": false
      },
      {
        "type": "header",
        "content": "Product reviews"
      },
      {
        "type": "paragraph",
        "content": "Reviews app must be enabled. [Learn more](https://help.outofthesandbox.com/hc/en-us/articles/360008549274#section2)"
      },
      {
        "type": "checkbox",
        "id": "enable_shopify_product_badges",
        "label": "Display star rating on product",
        "default": false
      },
      {
        "type": "radio",
        "id": "review_position",
        "label": "Reviews position",
        "default": "next_to_gallery",
        "options": [
          {
            "value": "next_to_gallery",
            "label": "In product description area"
          },
          {
            "value": "below_gallery",
            "label": "Below image\/description"
          }
        ]
      },
      {
        "type": "header",
        "content": "Recently viewed products"
      },
      {
        "type": "paragraph",
        "content": "To test the recently viewed products, view your online store outside of the Editor and visit multiple product pages. [Learn more](https:\/\/help.outofthesandbox.com\/hc\/en-us\/articles\/115008765228)"
      },
      {
        "type": "checkbox",
        "id": "display_recently_viewed",
        "label": "Show recently viewed products",
        "default": false
      },
      {
        "type": "text",
        "id": "rv_title",
        "label": "Title",
        "default": "Recently Viewed Items"
      },
      {
        "type": "radio",
        "id": "rv_products_style",
        "label": "Layout",
        "default": "grid",
        "options": [
          {
            "value": "slider",
            "label": "Slider"
          },
          {
            "value": "grid",
            "label": "Grid"
          }
        ]
      },
      {
        "type": "range",
        "id": "rv_max_display",
        "label": "Products limit",
        "min": 3,
        "max": 10,
        "step": 1,
        "default": 4
      },
      {
        "type": "range",
        "id": "rv_per",
        "label": "Products per row",
        "min": 3,
        "max": 5,
        "step": 1,
        "default": 4
      }
    ],
    "default": {
      "settings": {

      }
    }
  }
{% endschema %}

Thanks!