Jump to content

Display SKU on product pages

Recommended Posts

  • Replies 9
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

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 me: I've been a SQSP User for 18 yrs. I was invited to join the Circle when it launched in 2016. I have been a Circle Leader since 2017. I don't work for Squarespace. I value honesty, transparency, diversity and good design ♥.
Work: I founded and run SF.DIGITAL, building Squarespace Extensions to supercharge your commerce website. 
Content: Views and opinions are my own. Links in my posts may refer to SF.DIGITAL products or may be affiliate links.
Forum advice is free. You can thank me by clicking one of the feedback emojis below. Coffee is optional.

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
  • 3 months later...
  • 1 month later...
On 10/9/2021 at 6: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>

 

Hi Sophik,

 

I installed this code to display the product SKU code on the product page itself and it works great. My only question is wether it is possible to have the SKU change when the viewer selected a different variant? Each variant has a different SKU code, but when I click a different variant, the SKU remains the same which is a bit misleading to the customer. image.thumb.png.7990b3c53792e4b1bc77e7e8d2f05241.png

Link to comment
  • 2 weeks later...
On 4/2/2023 at 9:22 AM, tuanphan said:

Yes. Settings > Advanced > Code Injection > Footer

Hi Tuan, 

Have you any ideas on how I might get this code to update when different variants are selected? Each variant has a different SKU code, but when I click a different variant, the SKU remains the same which is a bit misleading to the customer. 

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.