Created
May 26, 2019 22:16
-
-
Save git-willie/2e63de80abf024a9042eeaa0570a7288 to your computer and use it in GitHub Desktop.
Product price based warranty addon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% assign warranty = all_products['warranty'] %} | |
{% assign warrantyDesc = warranty.description | strip_html %} | |
{% for i in (1..100) %} | |
{% assign warranty_max_price = i | plus: 1 | times: 1000 %} | |
{% if product.price <= warranty_max_price %} | |
{% assign warranty_price = warranty_max_price | minus: 1 | divided_by: 10 %} | |
{% break %} | |
{% elsif product.price > warranty_max_price %} | |
{% assign warranty_price = 10099 %} | |
{% endif %} | |
{% endfor %} | |
{% for warranty_variant in warranty.variants %} | |
{% if warranty_variant.price == warranty_price %} | |
{% assign warranty_variant_id = warranty_variant.id %} | |
{% endif %} | |
{% endfor %} | |
<div class="product-information__warranty"> | |
<div class="product-information__warranty-button active" data-warranty-variant-id="{{ warranty_variant_id }}" data-warranty-lip-key="{{ warranty.title }} for" data-warranty-lip-value="{{ product.title }}"> | |
<div class="row is-table-row--mobile is-table-row--tablet is-table-row--desktop"> | |
<div class="col-xs-2 col-sm-2"> | |
<span class="warranty-select-box"></span> | |
</div> | |
<div class="col-xs-9 col-sm-7"> | |
<img src="{{ warranty.featured_image | product_img_url: 'x100' }}" alt="{{ warranty.title }}"> | |
</div> | |
<div class="col-xs-13 col-sm-15"> | |
<span style="margin-right: 30px; display: inline-block;"> | |
<input type="checkbox" name="properties[{{ warranty.title }}]" value="Added" style="display: none;" checked> | |
<span> | |
Add <span class="highlight">{{ warranty.title }}</span><br /> for only {{ warranty_price | money }} | |
</span> | |
</span> | |
</div> | |
</div> | |
</div> | |
<div class="product-information__warranty-tooltip"> | |
<span title="{{ warrantyDesc }}"><i class="fa fa-question-circle"></i></span> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment