Last active
November 19, 2018 08:23
-
-
Save iwillhappy1314/1695baa1b8a15c71aedc69fdaacb7e23 to your computer and use it in GitHub Desktop.
WooCommerce 可变产品改为点击选择
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
.woocommerce{ | |
.variations{ | |
.reset_variations{ | |
display: none; | |
} | |
.reset_variations, | |
select{ | |
display: none; | |
} | |
.label, | |
.value{ | |
display: block; | |
} | |
.label{ | |
margin-bottom: 5px; | |
line-height: normal; | |
} | |
.c-filters{ | |
margin-bottom: .5rem; | |
li{ | |
display: inline-block; | |
border: 1px solid #eee; | |
height: 40px; | |
line-height: 40px; | |
padding: 0 12px; | |
margin-right: 10px; | |
cursor: pointer; | |
&:first-child{ | |
display: none; | |
} | |
&.is-selected{ | |
border: 1px solid #e51919; | |
color: #e51919; | |
position: relative; | |
&:after{ | |
content: ''; | |
width: 14px; | |
height: 14px; | |
bottom: 0; | |
right: 0; | |
position: absolute; | |
background: url(../images/chose-t-icon.png); | |
} | |
} | |
} | |
} | |
} | |
} |
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
<script> | |
jQuery(document).ready(function($){ | |
$('.variations select').parent().append('<ul id="js-sku-selector" class="c-filters"></ul>'); | |
$('.variations select option').each(function(){ | |
$('#selector').append('<li data-value="' + $(this).val() + '">'+$(this).text()+'</li>'); | |
}); | |
$('.variations select').hide(); | |
$('.selector li').click(function(){ | |
$(this).siblings().removeClass('is-selected'); | |
$(this).addClass('is-selected'); | |
$('.variations select').val($(this).data('value')).trigger('change'); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment