I have a theme Kalles v4.2.3 official and I set up a store on it www.neilguy.com. i want to add MRP before the price. How can I add this to my website? Kindly help with this issue.
It will require little bit change in the HTML. Have you wrote M.R.P. By yourself or it came like that prebuilt?
Hello Deepak Sharma … thanks for the reply yes I wrote this M.R.P. I was trying to do this by my self. if you say then I will remove it?
No need can you copy entire code where you wrote this line and provide here I will help you fix this real quick
i write this code in two files
-
product-price-liquid
-
product-price-single-liquid
Do you need both file codes or something else?
yes
Please change the file extension .csv to .txt
Hey @bhupinder_saggu
Open product-price-single.liquid
and replace entire code with this one
{% comment %}
Renders a list of product's price (regular sale unit)
Accompanies product forms and meant to be updated dynamically
Accepts:
- variant: {Object} Variant Liquid object (optional)
- product: {Object} Product Liquid object (optional)
- PR_no_pick: {Boolean} Product no pick (optional)
- type_sale: '1' '2' (optional)
- price_varies_style: {String} Product price varies (optional)
- style_inline: {CSS} Product price var css (optional)
Usage:
{%- render 'product-price-single' variant: current_variant product: product PR_no_pick:true -%}
{% endcomment %}
{%- liquid
if variant.title and price_varies_style == '0'
assign price = variant.price
assign compare_at_price = variant.compare_at_price | default: price
assign available = variant.available
elsif PR_no_pick or price_varies_style != '0'
assign price = product.price
assign compare_at_price = product.compare_at_price | default: price
assign available = product.available
else
assign price = 1999
assign compare_at_price = 1999
assign available = true
endif
assign price_varies = product.price_varies
if price_varies and settings.only_price_varies_stock and product.has_only_default_variant == false and product.available and price_varies_style != '0'
assign variants_price = product.variants | where: 'available' true | map: 'price' | compact | sort | uniq
if variants_price.size > 1
assign price = variants_price | first
assign price_max = variants_price | last
else
assign price_varies = false
assign variant = product.first_available_variant
assign price = variant.price
assign compare_at_price = variant.compare_at_price | default: price
endif
endif
assign on_sale = false
if compare_at_price > price
assign on_sale = true
endif
assign cur_code_enabled = settings.currency_code_enabled
assign saveAmountFixed = compare_at_price | minus: price
if cur_code_enabled
assign money_price = price | money_with_currency
assign money_compare_at_price = compare_at_price | money_with_currency
else
assign money_price = price | money
assign money_compare_at_price = compare_at_price | money
endif
assign variant_unit_price_measurement = variant.unit_price_measurement
if price_varies and price_varies_style != '0'
assign isRangePrices = true
assign pr_no_pick_prices = false
elsif price_varies and price_varies_style == '0' and PR_no_pick
assign isRangePrices = true
assign pr_no_pick_prices = true
else
assign isRangePrices = false
assign pr_no_pick_prices = false
endif
-%}
{%- capture sale_badge_html -%}
{%- if type_sale == '1' -%}
{%- assign save = saveAmountFixed | times: 100.0 | divided_by: compare_at_price | round %} {{ 'products.badge.save_amount_2_html' | t: saved_amount: save }}
{%- elsif type_sale == '2' %}
{%- liquid
if cur_code_enabled
assign priceFormatMoney = saveAmountFixed | money_with_currency
else
assign priceFormatMoney = saveAmountFixed | money
endif %} {{ 'products.badge.save_amount_fixed_2_html' | t: saved_amount: priceFormatMoney }}
{%- endif -%}
{%- endcapture -%}
M.R.P.
{%- if isRangePrices -%}
{%- if price_varies_style == '1' -%}
{%- liquid
if cur_code_enabled
assign price_max = price_max | default: product.price_max | money_with_currency
else
assign price_max = price_max | default: product.price_max | money
endif
-%}
{%- if on_sale -%}
{{ money_price }} – {{ price_max }}
{%- else -%}
{{- money_price }} – {{ price_max -}}
{%- endif -%}
{%- elsif on_sale -%}
<del>{{ money_compare_at_price }}</del><ins>{{ 'products.product.from_price_html' | t: price_min: money_price class: 't4s-price-from' }}</ins>
{%- else -%}
{{ 'products.product.from_price_html' | t: price_min: money_price class: 't4s-price-from' }}
{%- endif -%}
{%- elsif variant_unit_price_measurement -%}
{%- if on_sale -%}
<del>{{ money_compare_at_price }}</del> <ins>{{ money_price }}</ins>{{ sale_badge_html }}
{%- else -%}
{{ money_price }}
{%- endif -%}
{%- assign price_unit = variant.unit_price | money -%}
{%- capture unit_price_base_unit -%}
{%- if variant_unit_price_measurement -%}
{%- if variant_unit_price_measurement.reference_value != 1 -%}
{{- variant_unit_price_measurement.reference_value -}}
{%- endif -%}
{{ variant_unit_price_measurement.reference_unit }}
{%- endif -%}
{%- endcapture -%}
{{ price_unit }}/
{{- unit_price_base_unit -}}
{%- elsif on_sale -%}
<del>{{ money_compare_at_price }}</del> <ins>{{ money_price }}</ins>{{ sale_badge_html }}
{%- else -%}
{{ money_price }}
{%- endif -%}
Hopefully, it will help you. If yes then Please don’t forget to hit Like and Mark it as the solution!
Thanks Deepak
It worked? man to be honest I was not sure lol ![]()
Glad it worked