Jump to content

7.1 empty product category

Recommended Posts

  • 9 months later...
On 4/1/2021 at 9:32 PM, creedon said:

Add the following to Settings > Advanced > Code Injection > HEADER. You've already done this step but others will need to if they haven't.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

Add the following to Store Settings > Advanced > Page Header Code Injection for the store page.

<script>

  $( ( ) => {
  
    /*
    
      add text to empty products pages
      
      SS Version : 7.1
      
      */
      
    const text = 'Please check back soon!';
    
    // do not change anything below, there be the borg here
    
    if ( ! $( '.view-list' ).length ) return;
    
    const $listGrid = $( '.list-grid' );
    
    if ( $listGrid.children ( ).length ) return;
    
    $( '<p id="tc-empty-products-pages-text">' +
    
      text +
      
      '</p>' )
      
      .appendTo ( $listGrid );
       
    } );
    
  </script>

This is for v7.1.

I've supplied a CSS id selector #tc-empty-products-pages-text if you want to style the text.

Let us know how it goes.

How would you do this for 7.0?

Link to comment
8 hours ago, sdinsmore said:

How would you do this for 7.0?

I can't make any promises that I can come up with a solution but I'm willing to take a look.

Please post the URL for a page on your site where we can see your issue.

If your site is not public please set up a site-wide password, if you've not already done so.

Post the password here.

Adding a site-wide password does not allow anyone to alter your site. It only allows those with the password to see your site. Please read the documentation at the link provided to understand how it works.

Please read the documentation at the link provided on how to share a link to your site to understand how it works. A link to the backend of the your site won’t work for us, i.e. a url that contains /config/.

We can then take a look at your issue.

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

Link to comment

Website is public. Here is an empty category at the store: https://www.dancingastronautdesigns.com/store?category=Headcovers. 7.0, Brine.

So not only is there nothing to display (which is why I would like to add a message), but the webpage height is absurdly short; it ends just after the store nav bar, leaving the remaining area white (while my site is a black background).

Ideally, I would like to:

*Make any page in the store a default minimum height so that the background color (black) is always displayed; never white.

*Display a message if a store category is empty.

*Even add a footer to the store pages? Not sure why this isn't allowed or editable. Only an Intro is allowed.

Link to comment
2 hours ago, sdinsmore said:

So when it comes to Store pages, you have to have it full of items in order to not have a webpage with a height of ~150 pixels??

I can only guess the design decisions Squarespace had to make. It appears SS didn't anticipate many folks having totally empty categories. I think they probably expected most folks to have categories with sold out products. So they would still be listed but tagged as sold out.

Try this. Add the following to Store Settings > Advanced > Page Header Code Injection for the store page. Please see per-page code injection.

<style>

  body.tweak-site-width-option-full-width {
  
    background-color : black;
    
    }
    
  </style>

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

Just to clarify the reason why (in case SS is listening), our company sells unique, one-of-a-kind products, which we REMOVE after they sell. So when categories sell out, then we have an empty category, although we don't want to remove/hide that category.

Regarding your code for the background and the script for an empty product list, both of those worked to an extent. There isn't a white background anymore, which is, at a minimum, a safe backup plan. The script also adds some basic text (which you can see at the original link I posted). I made a donation on your website as a thank you, I appreciate your help!

From an earlier post in this thread, I see I can style the text using CSS, which I can probably figure out myself.

One more advanced question... would it be possible, instead of just inserting text, to also insert spacers and, say, a footer at the bottom of the page, the location of which is calculated from the screen height? It would also be nice to insert a footer on all store pages. The "footers" across my site are actually simple Markdown boxes with "<h4>©DANCING ASTRONAUT DESIGNS 2022, ALL RIGHTS RESERVED</h4>" in them.

Link to comment
4 hours ago, sdinsmore said:

The script also adds some basic text (which you can see at the original link I posted).

Note that you'll need to disable Ajax Page Loading (in Site Styles) if you want this text to appear for all users - or @creedon will need to update his code. To see this issue, click open the site by clicking on this Accessories link (whilst not logged on) and then click on the Headcovers category. 

Improve your online store with our extensions.
About: Squarespace Circle Leader since 2017. I value honesty, transparency, appreciation 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.

Buy me a coffee

Link to comment
13 hours ago, sdinsmore said:

would it be possible, instead of just inserting text, to also insert spacers and, say, a footer at the bottom of the page, the location of which is calculated from the screen height? It would also be nice to insert a footer on all store pages.

The text variable can contain HTML if you wish. However it wasn't written with the idea of using complex HTML in the area that the text is being stuffed into. My code doesn't allow for the use of spacers as in the sense of space blocks as provided in the SS interface. My code also doesn't do anything with the footer.

One technique folks use for having a footer appear on only some pages is to add it to the site wide footer and then use CSS to hide it for most pages and then turn it on for those you want it on.

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

Link to comment
  • 3 weeks later...
  • 5 months later...

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.