Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1355590

    Hi all,

    I’m trying to get the product columns on the same level on the Woocommerce shop page. Given the different lengths in terms of product title and product short description.

    The intention is that the short product description is shortened so that all columns are at the same height.

    What options are there?

    • This topic was modified 2 years, 6 months ago by thijmens.
    #1355607

    Hey thijmens,

    Please try the following in Quick CSS under Enfold->General Styling:

    @media only screen and (min-width: 768px) {
    div.inner_product.av-product-class- {
        min-height: 780px;
    }
    }

    Best regards,
    Rikard

    #1355612

    Thnx, that’s what I got myself.

    Is it also possible to limit the short product description?

    #1355728

    Hi,
    Thank you for the link to your site, try adding this code to the end of your functions.php file in Appearance ▸ Editor:

    function custom_limit_words_script() { ?>
      <script>
    (function($){
    $('#top.post-type-archive-product .template-shop .products.columns-3 .product .inner_product').contents().filter(function() {
      return this.nodeType == 3
    }).each(function(){
      var length=30
      this.textContent = this.textContent.split(" ",length).join(" ");
    });
    })(jQuery);
    </script>
      <?php
    }
    add_action('wp_footer', 'custom_limit_words_script');

    feel free to adjust the word length to suit, currently it is 30.

    Best regards,
    Mike

    #1355885

    Thank you! This is already looking better.

    How do you manage to put ‘…’ after X words? Otherwise it looks crazy that the description is suddenly shortened.

    #1355984

    Hi,
    Glad to hear, try this script instead:

    function limit_words_script() { ?>
      <script>
    (function($){
    $('#top.post-type-archive-product .template-shop .products.columns-3 .product .inner_product').contents().filter(function() {
      return this.nodeType == 3
    }).each(function(){
      var length=30
      this.textContent = this.textContent.split(" ",length).join(" ") + "...";
    });
    })(jQuery);
    </script>
      <?php
    }
    add_action('wp_footer', 'limit_words_script');

    Best regards,
    Mike

    #1356600

    This will help! But the ‘…’ shows after every product-description. It should only show behind the truncated descriptions.

    #1356720

    Hi,
    Thanks for the feedback I have adjusted the script to this:

    function limit_words_script() { ?>
      <script>
    (function($){
    $('#top.post-type-archive-product .template-shop .products.columns-3 .product .inner_product').contents().filter(function() {
      return this.nodeType == 3
    }).each(function(){
      var words=45
      if (this.textContent.length > 347) {
      this.textContent = this.textContent.split(" ",words).join(" ") + "...";
      }
    });
    })(jQuery);
    </script>
      <?php
    }
    add_action('wp_footer', 'limit_words_script');

    To understand how this works please note that since the script doesn’t know “words” and words are different lengths the script counts the spaces between the words to equal the desired “45”, the conditional property “length” counts characters, so in my test with console.log(this.textContent.length) for your language the average character length for 45 spaces, or words, is 347.

    Best regards,
    Mike

    #1356928

    is there a way to see the page it belongs to?
    I’m participant as you are – but sometimes we do also have good ideas ;)

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.