Viewing 19 posts - 1 through 19 (of 19 total)
  • Author
    Posts
  • #1331775

    Dear Enfold Team,

    Was wondering whether it is possible to make Products in grids and sliders the same height.

    Mike was kind enough to help me with adding product description*, however products now have different height. Maybe it is possible to limit the description to 10 words as well as adding a “read more” link for extra text to appear.

    * functions.php file in Appearance ▸ Editor:
    add_action( ‘woocommerce_after_shop_loop_item_title’, ‘woocommerce_template_single_excerpt’, 5);

    Looking forward to your reply.

    Best,
    Alex

    #1331804

    Hey Alex PS,

    Thank you for the inquiry.

    Try to use this filter in the functions.php file to modify the product description and limit it to a certain number of words.

    add_filter(" woocommerce_short_description", function($excerpt) {
        return wp_trim_words($excerpt, 10);
    }, 10, 1);
    

    Best regards,
    Ismael

    #1331820

    Hi Ismael,

    Thank you very much for your quick reply.

    Your solution however does not seem to work.

    Is there a way to make product boxes to be similar to the way the Row layout in Avia layout builder can be made to equal height and then be vertical aligned to the top?

    If not I am open to other suggestions.

    Best,
    Alex

    #1331910

    Hi,

    Thank you for the update.

    The filter above should have trimmed the product description and limited it to 10 words. Have you tried applying a minimum height to the grid items? Please provide the page URL in the private field so that we can check the items and provide the necessary css adjustments.

    Best regards,
    Ismael

    #1331973

    Hi Ismael,

    Just to be entirely sure I just tried the code once again and actually found a little typo, the reason why the code did not work…

    add_filter(” woocommerce_short_description”, function($excerpt) {
    return wp_trim_words($excerpt, 10);
    }, 10, 1);

    Right after add_filter there should be a bracket then space and then a quotation mark.

    So this instead:
    add_filter( “woocommerce_short_description”, function($excerpt) {
    return wp_trim_words($excerpt, 10);
    }, 10, 1);

    My question though is would it be possible to add the read more link still?

    Best,
    Alex

    #1331974

    Although I must say that if there is a way to alight everything to the top it would be better, if one resizes the browser window all boxes are different sizes again :(

    #1332074

    Hi,

    Thank you for the update.

    Where can we see the issue? We may be able to apply a minimum height to the items or content container to display or to align them consistently. Please provide the page URL in the private field.

    Best regards,
    Ismael

    #1332367

    Hi Ismael,

    Aligning according to the tallest one on the page would be great if that is of course easily reachable in terms of coding involved.

    One pf the pages where product grid is used is here: https://www.pearlsmile.com/shop/

    Looking forward.

    Best,
    Alex

    #1332497

    Hi,
    Thank you for your patience and the link to your page, to have all of the product grid items the same height try adding this code to the end of your functions.php file in Appearance ▸ Editor:

    function custom_product_height_script() { ?>
        <script>
    (function($){
      $(window).load(function(){
      	$('.avia-content-slider-inner').each(function(){  
         var $columns = $('li.product .inner_product',this);
         var maxHeight = Math.max.apply(Math, $columns.map(function(){
             return $(this).height();
         }).get());
         $columns.height(maxHeight);
    });
    });
    })(jQuery);
    </script>
        <?php
    }
    add_action('wp_footer', 'custom_product_height_script');

    Best regards,
    Mike

    #1332646

    Hi Mike,

    No worries, been busy with other stuff meanwhile. Thank you!

    I tried the code and it works. Although if one would have changed the size / dimensions of the browser something strange happens to the buttons on the bottom.

    Buttons also have a white space below them if descriptions are different size.

    Let me know if that is easily achievable more or less.

    Looking forward.

    Thank you very much again for the your help!

    Wish I could send you a screenshot.

    Best,
    Alexander

    #1332885

    Hi,

    Thank you for the inquiry.

    We adjusted the script a bit so that the maxHeight value is recalculated on browser resize. Please try this again.

    
    function ava_custom_product_height_script()
    {?>
        <script>
    	(function($){
    		var win = $(window);
    
    		$(document).ready(function() {
    			// just make sure that the column resizes
    			win.trigger("debouncedresize");
    		});
    
    		win.on("debouncedresize", function(){
    			console.log("test");
    			$('.avia-content-slider-inner').each(function(){
    				var $columns = $('li.product .inner_product',this);
    				var maxHeight = Math.max.apply(Math, $columns.map(function(){
    					return $(this).height();
    				}).get());
    				$columns.height(maxHeight);
    			});
    		});
    	})(jQuery);
    </script>
        <?php
    }
    add_action('wp_footer', 'ava_custom_product_height_script', 9999);
    

    Best regards,
    Ismael

    #1333139

    Hi Ismael,

    It works now. Really appreciate your help and time. Thank you guys!

    It seems to me that I have already taken lots of your time but I have one last question.

    After the resize “buy” and “read more” buttons have empty space below. I am sort of ready to let it go but if it would not take a ton of your time, would you be able to possibly stick it to the bottom of each box? If the fix is complicated and would take a lot of your time it is fine as it is already. So thank you!

    Best,
    Alex

    #1333308

    Hi,

    Glad to know to know that it is working. Regarding the button, try to use this css code to adjust the position of the read more link and ensure that it sticks to the bottom.

    .responsive #top .slide-entry .read-more-link {
        position: absolute;
        bottom: 0;
        left: 0;
        top: auto;
    }
    
    .responsive #top .slide-entry  .slide-entry-excerpt {
        position: relative;
        padding-bottom: 50px;
    }
    

    Best regards,
    Ismael

    #1333476

    Hi Ismael,

    The code you provided does not seem to worm for me.

    Alex

    #1333492

    Hi,

    Sorry about that. I thought that you are using the Blog Posts element. For the product grid, this css should work.

    .avia_cart_buttons {
        position: absolute;
        bottom: 0;
    }
    

    Please make sure to toggle or temporarily disable the Enfold > Performance > File Compression settings afterwards.

    Best regards,
    Ismael

    #1333546

    Hi Ismael,

    Is there any other bit of code I need to use with it?

    At the moment elements kind of overlap.

    Alex

    #1333981

    Hi Alex,

    I checked your website and buttons are side by side on my end. I am not sure if we understood the issue clearly. Could you please post a screenshot and show it? You can upload your screenshots on imgur.com and post the links here :)

    Best regards,
    Yigit

    #1353575

    Hi all,

    I’ve tried the above code to get the product gallery columns of equal height. Unfortunately it doesn’t work for me?

    Am I missing something?

    • This reply was modified 2 years, 6 months ago by thijmens.
    #1354017

    Hi,

    @thijmens
    thank you for your patience and the link to your site, the script in this thread is for the product slider element, your page is not using this element it is a Shop page.
    On your page the first 3 columns are equal height but the last one has double the product excerpt, so making all four equal height to the last one will make the first 3 look strange with a lot of white space, my recommendation is that you would be better to remove half of the product excerpt from the last one.
    If you would like further help with this please open a new thread and include an admin login in the Private Content area.
    We try to keep the threads focused on a single topic to help future searches, thank you for your understanding.

    Best regards,
    Mike

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