Jump to content

Display SKU on product pages

Recommended Posts

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

On Product List pages like https://www.middleburgtack.com/jumping, the SKU is not in the markup and so it isn't straightforward to display it. The SKU can be extracted from the JSON but as you are using filtering, this will delay page loading. As you appear to be using the SKU for image filenames, an easier option will be to display the image name below the price.

 

About: Squarespace Circle Leader since 2017. I value honesty, transparency, diversity and great design ♥.
Work: Squarespace Developer and founder of SF Digital, building the features Squarespace didn't include™. 
Content: Links in my posts may refer to SF Digital products or may be affiliate links.

Catch up on all the release notes and announcements 2023 [for Circle members only]. There's a public version here too!
If I helped, you can thank me by clicking one of the emojis below. If you prefer, you can buy me a coffee.
Improve your online store with our extensions.

Link to comment
3 hours ago, paul2009 said:

On Product List pages like https://www.middleburgtack.com/jumping, the SKU is not in the markup and so it isn't straightforward to display it. The SKU can be extracted from the JSON but as you are using filtering, this will delay page loading. As you appear to be using the SKU for image filenames, an easier option will be to display the image name below the price.

 

That would be a great solution, thanks so much for the insight. Forgive me if I missed it in the styles and settings, would this need to be done through code injection or is that an option I'm missing somewhere? 

Link to comment
  • 1 year later...

this is what i did to insert the SKU right below the price on a single product page (don't have this for category/list page)... hope it helps.

<script>  
jQuery(document).ready(function() {
jQuery("<div id='sku'></div>").insertAfter(".ProductItem-product-price" );
    
var pathname = window.location.pathname;
jQuery.ajax({
  url: pathname + "?format=json-pretty",
  dataType: "json",
  success: function (data) {
    sku = data.item.structuredContent.variants[0].sku;
jQuery("#sku").html("<b>SKU:</b> " + sku);
}
});
});  
</script>

 

Link to comment
  • 1 year later...
On 10/9/2021 at 2:34 PM, Sophik said:

this is what i did to insert the SKU right below the price on a single product page (don't have this for category/list page)... hope it helps.

<script>  
jQuery(document).ready(function() {
jQuery("<div id='sku'></div>").insertAfter(".ProductItem-product-price" );
    
var pathname = window.location.pathname;
jQuery.ajax({
  url: pathname + "?format=json-pretty",
  dataType: "json",
  success: function (data) {
    sku = data.item.structuredContent.variants[0].sku;
jQuery("#sku").html("<b>SKU:</b> " + sku);
}
});
});  
</script>

 

Hey Sophik! Sorry about for my ignorance.. but where should i insert this code? Advanced -> code injection?  thanks

Link to comment
On 3/31/2023 at 1:32 AM, yuribtonani said:

Hey Sophik! Sorry about for my ignorance.. but where should i insert this code? Advanced -> code injection?  thanks

Yes. Settings > Advanced > Code Injection > Footer

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

How to: Setup Password & Share url Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment


×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.