Unlock Cyber Week Deals On Ella Shopify Theme + 40% OFF Before It’s Gone!

Okay
  Print

Unit price is compulsory in Germany. If you want to include Unit prices for the product on the product page, please follow instructions below:

  • Go to Editor -> Theme settings -> Multiple Layouts -> Product Page -> Product Page Layout 


  • Go to the Admin -> Edit Code -> Sections / main-product.liquid -> find the corresponding template then click the arrow to go to the file to be changed. Follow the picture below.


  • In the file that needs to be changed, please paste the code below into the end file as shown in the image below:

 

   {% assign current_variant = product.selected_or_first_available_variant %}

   {%- if current_variant.unit_price_measurement -%}

     {{ current_variant.unit_price | money }} /

      

{%- if

 current_variant.unit_price_measurement.reference_value != 1 -%}

    {{- current_variant.unit_price_measurement.reference_value -}}

   {%- endif -%}                                

    {{ current_variant.unit_price_measurement.reference_unit }}

 {%- endif -%}

 

 

  • Go to the Admin -> Edit Code -> Sections / main-product.liquid -> please paste the code below into file like image.

{% if product.selected_or_first_available_variant != '' %}

   if (variant.unit_price !== 'undefined') {

   var unit = Shopify.formatMoney(variant.unit_price,          

"{{ shop.money_format }}");

var unit_v = variant.unit_price_measurement.reference_value +           variant.unit_price_measurement.reference_unit;

$(".unit-price").html(unit + ' / ' + unit_v); 

    } else {

        $(".unit-price").html('');

    }

{% endif %}

  • Also in Sections / main-product.liquid file, please paste the code below into file like image.

 if( '{{product.selected_or_first_available_variant}}' == ' {{product.selected_or_last_available_variant}} ' ){        

   $('.unit-price').html('{{ product.selected_or_first_available_variant }}');

   $('.unit-price').html('Code');

}