Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 0

Display product tags on product page


OzBrowning

Question

8 answers to this question

Recommended Posts

  • 1
Quote

I figured out how to do this last night, but it is a little slow.

As bangank36 mentioned you can get the tags from within the page.

let tags = $( '#productWrapper' )

  .attr ( 'class' )
  
  .split ( ' ' )
  
  .filter ( clss => clss.startsWith ( 'tag-' ) );

Let us know how it goes.

Find my contributions useful? Please like, upvote, mark my answer as best , and see my profile. Thanks for your support!

Link to comment
  • 1
5 hours ago, OzBrowning said:

Site URL: https://www.rookspress.com/products/babel

Hi,

Does anyone know if it is possible to use code injection and jquery to display a list of a product's tags on the product page?

Thanks,

Oz

You mean tag like this? And where you want to place them 

 

image.png

Greeting, it's BaNgan from BeyondSpace, I am Squarespace dev focus on provide solutions to enhance feature that squarespace.com can't provide.
Feel free to check my current Squarespace Plugins Developement: Enable Pinch/Zoom on lightbox, Delivery Date Picker, Portfolio hover Replace Link Style
If you find my answer fit your need, let's leave a like or upvote so others with the same issue can find their solution. Thank you

Link to comment
  • 1
17 hours ago, OzBrowning said:

Hi, thanks for the response. I figured out how to do this last night, but it is a little slow.

I used jquery to get the json for the current page and then render the item.tags array as a list of HTML a elements, which I then add into the design using jquery .after.

I gave the resulting element a class so I can style it using custom css.

However this is quite slow, and I think there might be a quicker and easier method so I will keep investigating.

Thanks to creedon, using our method is quicker since it does not have to parse all the product content via JSON, just read the tag class and use string manipulation to format it

Greeting, it's BaNgan from BeyondSpace, I am Squarespace dev focus on provide solutions to enhance feature that squarespace.com can't provide.
Feel free to check my current Squarespace Plugins Developement: Enable Pinch/Zoom on lightbox, Delivery Date Picker, Portfolio hover Replace Link Style
If you find my answer fit your need, let's leave a like or upvote so others with the same issue can find their solution. Thank you

Link to comment
  • 0

Hi, thanks for the response. I figured out how to do this last night, but it is a little slow.

I used jquery to get the json for the current page and then render the item.tags array as a list of HTML a elements, which I then add into the design using jquery .after.

I gave the resulting element a class so I can style it using custom css.

However this is quite slow, and I think there might be a quicker and easier method so I will keep investigating.

Link to comment
  • 0

Oh, one problem with this method is that all the tags are lower case. This would be problematic for me because the tags are author names with varying capitalisation (e.g. a surname like McCoy).

I think I will have to stick to the JSON method, but thanks for this alternative which I expect will be very helpful for others searching for this information.

Link to comment
  • 0
Quote

I think I will have to stick to the JSON method

As an alternative you might use the within page tag as a keyword into an author data structure.

const authorData = {

  'tag-david-blandy' : "David Blandy',
  'tag-real-mccoy' : 'Real McCoy'
  
  }

There is the downside of having to maintain the data but that seems a small price compared to the JSON loading.

Edited by creedon

Find my contributions useful? Please like, upvote, mark my answer as best , and see my profile. Thanks for your support!

Link to comment
  • 0

I was trying to use the tags to reduce the amount of data maintenance to be honest. Previously I was manually adding author to the description and manually linking it to the tag.

Right now the JSON pull is adding a very small time to load, and it’s asynchronous anyway so the worst case is the author blinks in shortly after load. But generally it’s not noticeable. I think this is the best balance I’m going to find! 

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...