How to remove discount on out of stock products?

Topic summary

Issue: A user wants to hide or remove discount pricing on products that are out of stock in their Shopify store.

Proposed Solutions:

  • ProtoMan44 suggests adding a conditional check using {% if product.available %} around the discount badge code to only display it when products are in stock.

  • niraj_patel provides a more detailed solution involving Liquid template modifications:

    • Locate the product price display file (typically product-template.liquid or product-card.liquid)
    • Wrap pricing logic in {% if product.available %} conditional
    • Use {% if product.compare_at_price > product.price %} to check for discounts
    • Display both regular and sale prices only when product is available
    • Show only regular price when out of stock
    • Test changes after saving

Status: The discussion appears resolved with working code examples provided. The solution uses Shopify’s Liquid templating to conditionally display pricing based on inventory availability.

Summarized with AI on November 6. AI used: claude-sonnet-4-5-20250929.

https://ryusei.co.id/collections/men

@Ryusei_1 hi, can you please add this condition to the discount badge :
{% if product.available %}

Hello @Ryusei_1

To remove or hide discounts on out-of-stock products in your Shopify store, you can use Liquid code to check the product’s inventory status and conditionally display or hide the discount price.

Here’s how you can do it:

Step 1: Modify the Product Price Display in Liquid

You’ll need to modify the Liquid template where the product price is displayed, typically found in product-template.liquid, product-card.liquid, or a similar file depending on your theme.

Here’s an example of how you can structure the code:
{% if product.available %}

{% if product.compare_at_price > product.price %}
{{ product.price | money }}
{{ product.compare_at_price | money }}
{% else %}
{{ product.price | money }}
{% endif %}
{% else %}

{{ product.price | money }}
{% endif %}

Step 2: Explanation of the Code- {% if product.available %}: This checks if the product is in stock.

  • {% if product.compare_at_price > product.price %}: This checks if there is a discount by comparing the regular price with the sale price.
  • {% else %} inside {% if product.available %}: If the product is out of stock, this section ensures that only the regular price is displayed without any discount.

Step 3: Save and Test

Save the changes to your Liquid template file and test the product pages. Products that are out of stock should now only display the regular price without any discount.

Was my reply helpful? Click Like to let me know!
Was your question answered? Mark it as an Accepted Solution.