All things Shopify and commerce
I want to display all the offer in shopify store on my product page which applicable to it without an app
i have written the following code but its doesnt work
{%- assign original_price = product.price -%}
{%- if original_price > 0 -%}
{% assign applicable_discounts = '' %}
{% assign final_price = original_price %}
{%- for discount in shop.discounts -%}
{%- if discount.applies_to == "entire_order" and discount.minimum_order_amount <= original_price -%}
{%- assign applicable_discounts = applicable_discounts | append: discount.code | append: ':' | append: discount.value | append: '|' -%}
{%- elsif discount.applies_to == "specific_products" and product.id == discount.product_ids.first -%}
{%- assign applicable_discounts = applicable_discounts | append: discount.code | append: ':' | append: discount.value | append: '|' -%}
{%- elsif discount.applies_to == "quantity_based" and product.quantity >= discount.minimum_quantity -%}
{%- assign applicable_discounts = applicable_discounts | append: discount.code | append: ':' | append: discount.value | append: '|' -%}
{%- endif -%}
{%- endfor -%}
{% assign discount_details = applicable_discounts | split: '|' | uniq %}
{%- if discount_details.size > 0 -%}
<div class="product-offers">
<p>Special Offers:</p>
<ul>
{%- for details in discount_details -%}
{%- assign details_split = details | split: ':' -%}
{%- assign discount_code = details_split[0] -%}
{%- assign discount_percentage = details_split[1] -%}
{%- assign discount_value = original_price | times: discount_percentage | divided_by: 100 -%}
{%- assign discounted_price = original_price | minus: discount_value -%}
<li>Get this for Rs. {{ discounted_price | money_without_currency }} with discount code {{ discount_code }}!</li>
{%- endfor -%}
<!-- Add more offer details if needed -->
</ul>
</div>
{%- endif -%}
{%- endif -%}
further i have render it in
{% section 'product-offers-price' %}
with this code in main-product.liquid
but its not displaying anything please help
eg.
As per my research, there is no discount object in the shop, so we cannot get the discount information directly on the product page.
We can try to display discount information on the product page if you wish.
Hey Community 👋 Did you know that March 15th is National Everything You Think Is W...
By JasonH Apr 1, 2025Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025