Created
December 11, 2019 14:08
-
-
Save loughlincodes/53bb61b2f23969132577cbf4afb04ae7 to your computer and use it in GitHub Desktop.
Shopify - Show a percentage discount "on sale" button
This file contains 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 percentageDiscount = product.compare_at_price_max | minus: product.price | times: 100.0 | divided_by: product.compare_at_price_max | money_without_currency | times: 100 | remove: '.0' -%} | |
{% if product.compare_at_price_max > product.price %} | |
<div class="sale-banner"><span>{{ 'collections.general.sale' | t }}</span><p>{{percentageDiscount}}%<span>OFF!</span></div> | |
{% endif %} | |
... | |
... |
This file contains 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
... | |
... | |
.sale_banner { | |
position: absolute; | |
top:20px; | |
left:20px; | |
background: #326ca9; | |
padding: 0; | |
width: 70px; | |
height: 70px; | |
text-align: center; | |
color: #fff; | |
font-family: "Gill Sans Nova", sans-serif; | |
font-weight: 400; | |
font-size: 12px; | |
text-transform: uppercase; | |
letter-spacing: 0px; | |
border-radius: 50%; | |
display: flex; | |
align-items: center; | |
justify-content: center; | |
flex-direction: column; | |
} | |
.sale_banner > span{ | |
line-height: 1; | |
display: block; | |
color:#a3cfff; | |
} | |
.sale_banner p{ | |
font-size: 24px; | |
text-align: center; | |
line-height: 1; | |
margin: 0; | |
padding: 0; | |
} | |
.sale_banner p span{ | |
display: block; | |
font-size:14px; | |
} | |
... | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment