Overview:
Sometimes it may be necessary to sort the Accessory items on a product page regardless of Sort Order. The snippet of code below will sort all Accessories Products based on their Product Title.
Code:
The function relies on the following script (https://accessories.w3apps.co/js/sortelements.js)
Paste the following script at the bottom of your theme.liquid file just before the closing </body> tag.
<script type="text/javascript" src="https://accessories.w3apps.co/js/sortelements.js"></script>
<script type="text/javascript">
function accessoriesDoneLoadingCallback() {
$('.accessories-item').sortElements(function(a, b){
return $(a).find('.accessories-title').text() > $(b).find('.accessories-title').text() ? 1 : -1;
}); }
</script>