Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save projoomexperts/8888ad587081d9d9b3b1f380739e1b69 to your computer and use it in GitHub Desktop.
Save projoomexperts/8888ad587081d9d9b3b1f380739e1b69 to your computer and use it in GitHub Desktop.
Very simple code to show tabs in your shopify product description. All you need is to replace {{ product.description }} with the code below. It will separate every <h3> tag and contents after it into a tab. feel free to contact me if you want it implemented on your website for a small one time fee. `projoomexperts@gmail.com` "Shopify product des…
{% assign description = product.description | replace: '<h3', '</div><div class="tab-content"><h3' %}
<div class="prod_description">
<div class="spacer">
{{ description }}
</div>
</div>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script>
jQuery(document).ready(function(){
var tabTitle = '<ul>';
jQuery('.prod_description > div.tab-content').each(function(i, item){
jQuery(this).attr('id', "tabs-" + i);
var titletext = jQuery(this).find('h3').text();
var titlelist = '<li><a href="#tabs-' + i + '">' + titletext + '</a></li>'
tabTitle += titlelist ;
});
tabTitle += '</ul>';
jQuery( tabTitle ).insertAfter('.spacer');
jQuery('.spacer').remove();
jQuery( ".prod_description" ).tabs();
})
</script>
@projoomexperts
Copy link
Author

@wesdoesdev
Your website has some javascript conflicts. To get the script working you need to solve them.
Screenshot_35

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment