Search
 
SCRIPT & CODE EXAMPLE
 

RUBY

shopify: how to show percentage discount saved

    {% if template == 'product' %}
      {{ 'products.product.on_sale' | t }}
    {% else %}      
      {% assign percentage = 0 %}
      {% for variant in product.variants %}
      {% assign saving = variant.compare_at_price | minus: variant.price | times: 100 | divided_by: variant.compare_at_price | round %}
      {% assign percentage = saving | at_least: percentage %}
      {% endfor %} 


      Save up to {{ percentage }}%
    {% endif %}
Comment

PREVIOUS NEXT
Code Example
Ruby :: how to add font awesome icon in button for submit rails 
Ruby :: ruby remove last element of string 
Ruby :: ruby prepend array 
Ruby :: rails check routes in console 
Ruby :: ruby loop each with index 
Ruby :: rails send email from console 
Ruby :: super vs super() ruby 
Ruby :: rails scope syntax 
Ruby :: ruby get current process id 
Ruby :: how to find even number in an array ruby 
Ruby :: ruby check if constant exists 
Ruby :: ruby add content to file 
Ruby :: run Rspec 
Ruby :: create table index unique rails 
Ruby :: ruby on rails binding.pry 
Ruby :: deep copy and shallow copy in ruby 
Ruby :: rails sendgrid setup 
Ruby :: ruby map 
Ruby :: ruby merge arrays unique 
Ruby :: SoC partial class 
Ruby :: devise signout via get with https 
Ruby :: ruby find multiple indices in an array for a value the same value 
Ruby :: rails format number k - m 
Ruby :: ruby sinatra enable sessions 
Ruby :: link_to 
Ruby :: rails fixture without timestamping 
R :: r convert string to list of characters 
R :: counting by 2 columns in r 
R :: descending order a list in r 
R :: nls in r 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =