Shopify themes, liquid, logos, and UX
Hi, I saw some questions about this subject but none of them was solved.
i want to do a % discount, and i want the price of the discounted products to be updated with the price after discount, like the compere at price but I can't go through all the products to do it manually.
Is there a way to do it?
Thanks in advance!
Hello @מלבושים ,
To display automatic discounts on your Shopify store using the Dawn theme. Here's a combined approach that incorporates the best aspects of previous suggestions and addresses potential issues:
Method 1: Using Shopify's Built-in Discount Functionality (Recommended for Most Users)
Create an Automatic Discount:
Verify Discount Application:
Method 2: Code-Based Approach (For More Customization or Complex Discounts)
Important Note: This method requires editing your theme code. It's recommended to duplicate your theme before making changes and to have basic coding familiarity. If you're not comfortable with code, consider hiring a Shopify expert or using a Shopify App (see Method 3).
Access Theme Code:
Modify the price.liquid File:
Find the code snippet that displays the product price. It might look similar to this:
<span class="price">{{ product.price | money_format }}</span>
{% if product.compare_at_price > product.price %}
<span class="price original">{{ product.compare_at_price | money_format }}</span>
<span class="price">{{ product.price | money_format }}</span>
{% else %}
<span class="price">{{ product.price | money_format }}</span>
{% if active_discounts %}
<span class="price-discount">You save {{ active_discounts.first.amount | money_format }}</span>
{% endif %}
{% endif %}
Save Changes:
Method 3: Using a Shopify App (For Easier Management)
Several Shopify apps can help you manage automatic discounts and display them on your product pages. These apps often offer a more user-friendly interface and additional features compared to code editing. Here are some popular options to consider:
Additional Considerations:
By following these steps, you can effectively display automatic discounts on your Shopify store using the Dawn theme, enhancing the user experience and potentially increasing sales.
@oscprofessional wrote:Method 3: Using a Shopify App (For Easier Management)
Several Shopify apps can help you manage automatic discounts and display them on your product pages. These apps often offer a more user-friendly interface and additional features compared to code editing. Here are some popular options to consider:
- Automatic Discounts by Booster Apps
- Discounts by POWr
- Discount Automations by Automizy
Hi, thanks for replying.
I can't find the code you told me to replace. adding my price.liquid file here:
{% comment %}
Renders a list of product's price (regular, sale)
Accepts:
- product: {Object} Product Liquid object (optional)
- use_variant: {Boolean} Renders selected or first variant price instead of overall product pricing (optional)
- show_badges: {Boolean} Renders 'Sale' and 'Sold Out' tags if the product matches the condition (optional)
- price_class: {String} Adds a price class to the price element (optional)
- show_compare_at_price: {Boolean} Renders the compare at price if the product matches the condition (optional)
Usage:
{% render 'price', product: product %}
{% endcomment %}
{%- liquid
if use_variant
assign target = product.selected_or_first_available_variant
else
assign target = product
endif
assign compare_at_price = target.compare_at_price
assign price = target.price | default: 1999
assign price_min = product.price_min
assign price_max = product.price_max
assign available = target.available | default: false
assign money_price = price | money
assign money_price_min = price_min | money
assign money_price_max = price_max | money
if settings.currency_code_enabled
assign money_price = price | money_with_currency
assign money_price_min = price_min | money_with_currency
assign money_price_max = price_max | money_with_currency
endif
if target == product and product.price_varies
assign money_price = 'products.product.price.from_price_html' | t: price: money_price
endif
-%}
<div
class="
price
{%- if price_class %} {{ price_class }}{% endif -%}
{%- if available == false %} price--sold-out{% endif -%}
{%- if compare_at_price > price and product.quantity_price_breaks_configured? != true %} price--on-sale{% endif -%}
{%- if compare_at_price > price and product.quantity_price_breaks_configured? %} volume-pricing--sale-badge{% endif -%}
{%- if product.price_varies == false and product.compare_at_price_varies %} price--no-compare{% endif -%}
{%- if show_badges %} price--show-badge{% endif -%}
"
>
<div class="price__container">
{%- comment -%}
Explanation of description list:
- div.price__regular: Displayed when there are no variants on sale
- div.price__sale: Displayed when a variant is a sale
{%- endcomment -%}
<div class="price__regular">
{%- if product.quantity_price_breaks_configured? -%}
{%- if show_compare_at_price and compare_at_price -%}
{%- unless product.price_varies == false and product.compare_at_price_varies %}
<span class="visually-hidden visually-hidden--inline">
{{- 'products.product.price.regular_price' | t -}}
</span>
<span>
<s class="price-item price-item--regular variant-item__old-price">
{% if settings.currency_code_enabled %}
{{ compare_at_price | money_with_currency }}
{% else %}
{{ compare_at_price | money }}
{% endif %}
</s>
</span>
{%- endunless -%}
{%- endif -%}
<span class="visually-hidden visually-hidden--inline">{{ 'products.product.price.regular_price' | t }}</span>
<span class="price-item price-item--regular">
{{- 'products.product.volume_pricing.price_range' | t: minimum: money_price_min, maximum: money_price_max -}}
</span>
{%- else -%}
<span class="visually-hidden visually-hidden--inline">{{ 'products.product.price.regular_price' | t }}</span>
<span class="price-item price-item--regular">
{{ money_price }}
</span>
{%- endif -%}
</div>
<div class="price__sale">
{%- unless product.price_varies == false and product.compare_at_price_varies %}
<span class="visually-hidden visually-hidden--inline">{{ 'products.product.price.regular_price' | t }}</span>
<span>
<s class="price-item price-item--regular">
{% if settings.currency_code_enabled %}
{{ compare_at_price | money_with_currency }}
{% else %}
{{ compare_at_price | money }}
{% endif %}
</s>
</span>
{%- endunless -%}
<span class="visually-hidden visually-hidden--inline">{{ 'products.product.price.sale_price' | t }}</span>
<span class="price-item price-item--sale price-item--last">
{{ money_price }}
</span>
</div>
<small class="unit-price caption{% if product.selected_or_first_available_variant.unit_price_measurement == nil %} hidden{% endif %}">
<span class="visually-hidden">{{ 'products.product.price.unit_price' | t }}</span>
<span class="price-item price-item--last">
<span>{{- product.selected_or_first_available_variant.unit_price | money -}}</span>
<span aria-hidden="true">/</span>
<span class="visually-hidden"> {{ 'accessibility.unit_price_separator' | t }} </span>
<span>
{%- if product.selected_or_first_available_variant.unit_price_measurement.reference_value != 1 -%}
{{- product.selected_or_first_available_variant.unit_price_measurement.reference_value -}}
{%- endif -%}
{{ product.selected_or_first_available_variant.unit_price_measurement.reference_unit }}
</span>
</span>
</small>
</div>
{%- if show_badges -%}
<span class="badge price__badge-sale color-{{ settings.sale_badge_color_scheme }}">
{{ 'products.product.on_sale' | t }}
</span>
<span class="badge price__badge-sold-out color-{{ settings.sold_out_badge_color_scheme }}">
{{ 'products.product.sold_out' | t }}
</span>
{%- endif -%}
</div>
Hi מלבושים,
If you would like to show automatically discounted prices on product pages, then you can use our app, Regios Automatic Discounts.
Every theme can use our "Discounted Price" app block to automatically apply discounts on product pages.
And depending on what theme you're on (or if you do custom setup), you can also integrate our app to display automatically discounted prices on collection pages, the home page, and the product recommendations section.
If you have any questions about this, just reply, and I'll be happy to help.
Best,
Tobe
hi @מלבושים ,
To implement the same kindly refer the below code file name would be card-product.liquid for DAWN theme as file may vary depends on theme and version.
{%- assign difference = card_product.compare_at_price | minus: card_product.price -%}
{%- assign float_difference = difference | times: 1.0 -%}
{%- assign discount_fraction = float_difference | divided_by: card_product.compare_at_price -%}
{%- assign discount_percentage = discount_fraction | times: 100 | round -%}
{{- discount_percentage }}
To implement the same on product page and line number details request you to refer the video.
Don't forget to mark answer as solution if it helps.
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024