Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
snippets:receipt:conditional_content [2014/10/01 04:09] – created foxyjoshsnippets:receipt:conditional_content [2017/04/26 07:02] (current) – external edit 127.0.0.1
Line 1: Line 1:
 ---- dataentry snippet ---- ---- dataentry snippet ----
-type          : snippet     # do not change this line +type          : snippet # do not change this line 
-category      : receipt            # mention the category like 'shipping', 'checkout' etc +category      : receipt # mention the category like 'shipping', 'checkout' etc 
-name          : Conditional Content             # the name of the snippet +name          : Display Conditional Content # the name of the snippet 
-description   : Display conditional content based on any type of criteria.             # description about snippet +description   : Display conditional content based on any type of criteria. # description about snippet 
-versions_tags : 2.0             # compatible versions ( always use the dots between the numerals e.g 0.6.0 or 0.7.1 ) +versions_tags : 2.0 # compatible versions ( always use the dots between the numerals e.g 0.6.0 or 0.7.1 ) 
-reference_url :             # External link +reference_url :  # External link 
-tags_tags     :             # tags, separated by commas. +tags_tags     :  # tags, separated by commas. 
-date_dt       :             # the date in YYYY-MM-DD format+date_dt       :  # the date in YYYY-MM-DD format
 ---- ----
  
 +
 +====== Display Conditional Content  ======
 +
 +Using the sample code below, you can display custom html, javascript, etc. based on any criteria. For example, set parameter as false if specific product category is found:
 +
 +<code>
 +{% if context == 'receipt' %}
 +
 +    {% set candy = true %}
 +
 +    {% for item in items %}
 +        {% if item.category == 'WHOLESALE' %}
 +            {% set categoryFound = false %}
 +        {% endif %}
 +    {% endfor %}
 +
 +    {% if categoryFound %}
 +<h1>Success!</h1>
 +    {% endif %}
 +
 +{% endif %}{# context == receipt #}
 +</code> 

Site Tools