Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #1351030

    Hi,
    in my template I’m calling the Product Slider via shortcode like this:
    echo do_shortcode("[av_productslider categories='48' items='-1' columns='4' image_size='woocommerce_thumbnail' autoplay='no']");

    The shortcode is working, because I get the output of the desired products.
    But instead of having 4 items per row, it breaks after 3, so the 4th item is within a new row.
    The problem is, that the shortcode processing somehow sets the wrong classes, therefore item number 4 gets “cleared”.

    Expected result should be like this:
    Item 1 – css-class: first
    Item 2 – css-class: none
    Item 3 – css-class: none
    Item 4 – css-class: last

    But my result is like this:
    Item 1 – css-class: none
    Item 2 – css-class: none
    Item 3 – css-class: last
    Item 4 – css-class: first

    I’ve no idea why it’s getting mixed up like this….very strange behaviour.
    Any ideas?

    #1351038

    Hey freddyB,

    Could you post a link to where we can see the results you are getting please?

    Best regards,
    Rikard

    #1351053

    Sorry, not possible at this point…local dev.
    But you can see the rendered code here…as described:
    https://pasteboard.co/DHMIUmMg1Hjd.png

    #1351099

    Hi,

    Thank you for the inquiry.

    We cannot reproduce the same issue on our installation. As you can see in the screenshot below, the product slider have the correct class names.

    Screenshot: https://1drv.ms/u/s!AjjTfXSRbKTvwGWIch5pswFxUe_9?e=pZ0VzL

    Are you using other product extensions that might affect the slider?

    Best regards,
    Ismael

    #1351126

    Very strange, I’ve turned of all plugins and custom code, same result. (WP, WC, etc. on latest version, PHP8)
    BUT: as I tested the code via functions.php on ALL pages, I’ve found out that it’s NOT working correctly ONLY on WC product pages (single),
    any other page type works fine, even blog post, which is also single.

    Please test the code also on your installation on all post types.

    add_action( 'ava_before_footer', 'related', 15 );
    function related(): void {
    
    	?>
        <div id="av_section_3"
             class="avia-section av-67b3u7-b76b4296f6d03b9bb4a425ab60d3cd36 alternate_color avia-section-default avia-no-border-styling  avia-builder-el-0  avia-builder-el-no-sibling  avia-bg-style-scroll container_wrap fullsize">
            <div class="container av-section-cont-open">
                <main role="main" itemprop="mainContentOfPage" class="template-page content  av-content-full alpha units">
                    <div class="post-entry post-entry-type-page post-entry-2559">
                        <div class="entry-content-wrapper clearfix">
                            <div class="flex_column av-3aftcf-0defea7f6cd2898ac4c585f671f6abd0 av_one_full  avia-builder-el-1  avia-builder-el-no-sibling  first flex_column_div ">
    
    							<?php
    							echo do_shortcode( "[av_productslider categories='207' wc_prod_visible='' wc_prod_hidden='' wc_prod_featured='' wc_prod_additional_filter='' sort='0' prod_order='' items='-1' offset='0' columns='4' image_size='woocommerce_thumbnail' autoplay='no' interval='5' alb_description='' id='' custom_class='' template_class='' element_template='' one_element_template='' av_uid='av-l2zt9pqe' sc_version='1.0']" );
    							?>
    
                            </div>
                        </div>
                    </div>
                </main>
            </div>
        </div>
    	<?php
    
    }
    #1351410

    So, the problem is still unsolved…any updates regarding this issue?

    #1351785

    Hi,
    Thank you for your patience, I tested your function above but couldn’t reproduce the error on a single product page:
    2022-05-14_115043.jpg
    I also checked shop pages, regular pages, posts, and portfolio pages.
    I do note that your code above is adding page specific classes which could cause conflicts, such as:
    av-67b3u7-b76b4296f6d03b9bb4a425ab60d3cd36
    avia-builder-el-0
    post-entry-2559
    av-3aftcf-0defea7f6cd2898ac4c585f671f6abd0
    avia-builder-el-1

    these didn’t cause and issues on my test site, but it’s the only thing that I can see as a possible issue.

    Best regards,
    Mike

    #1352622

    Hi Mike,
    thanks for the check-up.
    As I’ve mentioned before, this only occures on WC product page (single product).
    Now I’ve found where it is beeing set: wp-content/plugins/woocommerce/includes/wc-template-functions.php
    from line: 456 -> function wc_get_loop_class()

    There seems to be something wrong with the modulo calculation:

    $columns    = absint( max( 1, wc_get_loop_prop( 'columns', wc_get_default_products_per_row() ) ) );
    
    	$loop_index ++;
    	wc_set_loop_prop( 'loop', $loop_index );
    
    	if ( 0 === ( $loop_index - 1 ) % $columns || 1 === $columns ) {
    		return 'first';
    	}
    
    	if ( 0 === $loop_index % $columns ) {
    		return 'last';
    	}

    Maybe I did not mention, that in the enfold shop settings under “product gallery” I’m using: WC 3.0 product gallery (not enfold default).

    Could you please check again? Thanks!

    #1352628

    Hi,
    Sorry, I was not able to reproduce this on my site, so I don’t believe that there is an error in the in above code.
    Try rewriting your function without the wrapping divs and just inject the shortcode of the element.

    Best regards,
    Mike

    #1352631

    INTERESTING BEHAVIOUR:
    If I add exact 4 or more products to the upsell box, than my shortcode works as expected.
    So, somehow, the upsell (counter) and enfold productslider/wc must be linked.

    #1352632

    already tried that…same behaviour

    #1352728

    Hi,

    So, somehow, the upsell (counter) and enfold productslider/wc must be linked.

    Thank you for that info. Before echoing the product slider shortcode, try to reset the loop counter using this function.

    wc_reset_loop();
    // do product slider shortcode here
    

    If this doesn’t work, try to place the reset function after the product slider shortcode.

    Best regards,
    Ismael

Viewing 12 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic.