Tagged: product slider, shortcode
-
AuthorPosts
-
May 9, 2022 at 11:14 am #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: lastBut my result is like this:
Item 1 – css-class: none
Item 2 – css-class: none
Item 3 – css-class: last
Item 4 – css-class: firstI’ve no idea why it’s getting mixed up like this….very strange behaviour.
Any ideas?May 9, 2022 at 12:07 pm #1351038Hey freddyB,
Could you post a link to where we can see the results you are getting please?
Best regards,
RikardMay 9, 2022 at 2:37 pm #1351053Sorry, not possible at this point…local dev.
But you can see the rendered code here…as described:
https://pasteboard.co/DHMIUmMg1Hjd.pngMay 10, 2022 at 6:19 am #1351099Hi,
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,
IsmaelMay 10, 2022 at 9:43 am #1351126Very 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 }
May 11, 2022 at 4:29 pm #1351410So, the problem is still unsolved…any updates regarding this issue?
May 14, 2022 at 6:04 pm #1351785Hi,
Thank you for your patience, I tested your function above but couldn’t reproduce the error on a single product page:
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,
MikeMay 23, 2022 at 12:10 pm #1352622Hi 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!
May 23, 2022 at 12:40 pm #1352628Hi,
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,
MikeMay 23, 2022 at 12:59 pm #1352631INTERESTING 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.May 23, 2022 at 1:00 pm #1352632already tried that…same behaviour
May 24, 2022 at 9:00 am #1352728Hi,
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 -
AuthorPosts
- You must be logged in to reply to this topic.