Product per row function broken after update
-
I was using the function from this page https://docs.woothemes.com/document/change-number-of-products-per-row/ to change the number of products per row on the shop and it was working perfectly until the 2.6 update. Now the .last and .first classes are added to the wrong product
<li>
elements completely breaking the layout. I managed to fix this by overwriting the .last and .first styles entirely and using my own custom style with nth-child, but I don’t want to have to fix this on every website I’ve built using woocommerce. Is this a known issue that will be fixed?
https://www.ads-software.com/plugins/woocommerce/
-
carlosbolanosmx please post your own topic.
Posted a known issue thread here https://www.ads-software.com/support/topic/26-update-product-column-display-is-wrongwrong-number-of-products-shown?replies=1
HI i have a similar issue since updating to 2.6.
Instead of displaying 4 columns it displays 2 (and also removed the button formatting I had)
See https://care4catsibiza.org/sponsor/
It also does the same on the single cat sponsorship pages for the related products
Tried removing the woocommerce_loop lines in the content-product.php template but that just caused it all to go in one column rather than back to four and did not fix the button formatting I had (you can see an example of the button formatting here https://care4catsibiza.org/shop/ ). I cant remove products from cart now either or change quantities. Here is the code
<?php /** * The template for displaying product content within loops * * This template can be overridden by copying it to yourtheme/woocommerce/content-product.php. * * HOWEVER, on occasion WooCommerce will need to update template files and you (the theme developer). * will need to copy the new files to your theme to maintain compatibility. We try to do this. * as little as possible, but it does happen. When this occurs the version of the template file will. * be bumped and the readme will list any important changes. * * @see https://docs.woothemes.com/document/template-structure/ * @author WooThemes * @package WooCommerce/Templates * @version 2.5.0 */ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } global $product, $woocommerce_loop; // Store loop count we're currently on if ( empty( $woocommerce_loop['loop'] ) ) { $woocommerce_loop['loop'] = 0; } // Store column count for displaying the grid if ( empty( $woocommerce_loop['columns'] ) ) { $woocommerce_loop['columns'] = apply_filters( 'loop_shop_columns', 4 ); } // Ensure visibility if ( ! $product || ! $product->is_visible() ) { return; } // Increase loop count $woocommerce_loop['loop']++; // Extra post classes $classes = array(); if ( 0 === ( $woocommerce_loop['loop'] - 1 ) % $woocommerce_loop['columns'] || 1 === $woocommerce_loop['columns'] ) { $classes[] = 'sd-first'; } if ( 0 === $woocommerce_loop['loop'] % $woocommerce_loop['columns'] ) { $classes[] = 'sd-last'; } if ( $woocommerce_loop['columns'] == 2 ) { $classes[] = 'col-md-6'; } elseif ( $woocommerce_loop['columns'] == 3 ) { $classes[] = 'col-md-4 col-sm-6 col-xs-12'; } elseif ( $woocommerce_loop['columns'] == 4 ) { $classes[] = 'col-md-3 col-sm-4 col-xs-12'; } elseif ( $woocommerce_loop['columns'] == 5 ) { $classes[] = 'col-md-5ths'; } elseif ( $woocommerce_loop['columns'] == 6 ) { $classes[] = 'col-md-2'; } $classes[] = 'sd-loop-class'; ?> <div <?php post_class( $classes ); ?>> <div class="sd-product"> <?php do_action( 'woocommerce_before_shop_loop_item' ); ?> <div class="sd-thumb-add-cart"> <div class="sd-shop-thumb-overlay sd-opacity-trans"> <?php /** * woocommerce_after_shop_loop_item hook * * @hooked woocommerce_template_loop_add_to_cart - 10 */ do_action( 'woocommerce_after_shop_loop_item' ); ?> </div> <span class="sd-loading-cart"><i class="fa fa-spinner fa-pulse"></i></span> <?php /** * woocommerce_before_shop_loop_item_title hook * * @hooked woocommerce_show_product_loop_sale_flash - 10 * @hooked woocommerce_template_loop_product_thumbnail - 10 */ do_action( 'woocommerce_before_shop_loop_item_title' ); ?> </div> <!-- sd-thumb-add-cart --> <div class="sd-product-content clearfix"> <h3><a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( '%s', 'sd-framework' ), the_title_attribute( 'echo=0' ) ) ); ?>"><?php the_title(); ?></a></h3> <?php /** * woocommerce_after_shop_loop_item_title hook * * @hooked woocommerce_template_loop_rating - 5 * @hooked woocommerce_template_loop_price - 10 */ do_action( 'woocommerce_after_shop_loop_item_title' ); ?> <div class="sd-price"> <?php echo woocommerce_template_loop_price(); ?> </div> <?php if ( $rating_html = $product->get_rating_html() ) : ?> <div class="sd-stars"> <span class="sd-rating-text"><?php _e( 'RATING', 'sd-framework' ); ?></span> <?php echo $rating_html; ?> </div> <?php endif; ?> </div> <!-- sd-product-content --> </div> <!-- sd-product --> </div> <?php if ( 0 === $woocommerce_loop['loop'] % $woocommerce_loop['columns'] ) { echo '<div class="clearfix visible-md-block visible-lg-block sd-separate-rows"></div>'; } if ( $woocommerce_loop['columns'] == 3 ) { if ( 0 === $woocommerce_loop['loop'] % 2 ) { echo '<div class="clearfix visible-sm-block visible-xs-block sd-separate-rows"></div>'; } } elseif ( $woocommerce_loop['columns'] == 4 ) { if ( 0 === $woocommerce_loop['loop'] % 3 ) { echo '<div class="clearfix visible-sm-block sd-separate-rows"></div>'; } if ( 0 === $woocommerce_loop['loop'] % 2 ) { echo '<div class="clearfix visible-xs-block sd-separate-rows"></div>'; } } ?>
Also the theme developer is away for the next 8 days according to his themeforest account, so am at a loss as to what to do, it is beyond my scope.
Any ideas?
Thanks
Gregg
This one is more complicated because it has clearfix divs and doesn’t use standard WooCommerce markup. It needs fixing by the author – perhaps they ignored the beta testing period.
Try removing the clearfix code at the bottom of the file instead.
if ( 0 === $woocommerce_loop['loop'] % $woocommerce_loop['columns'] ) { echo '<div class="clearfix visible-md-block visible-lg-block sd-separate-rows"></div>'; } if ( $woocommerce_loop['columns'] == 3 ) { if ( 0 === $woocommerce_loop['loop'] % 2 ) { echo '<div class="clearfix visible-sm-block visible-xs-block sd-separate-rows"></div>'; } } elseif ( $woocommerce_loop['columns'] == 4 ) { if ( 0 === $woocommerce_loop['loop'] % 3 ) { echo '<div class="clearfix visible-sm-block sd-separate-rows"></div>'; } if ( 0 === $woocommerce_loop['loop'] % 2 ) { echo '<div class="clearfix visible-xs-block sd-separate-rows"></div>'; } }
Excellent, thanks that sorted the column issue. Any ideas with the button display css and the cart not being editable?
Thanks
Gregg
Looks like the products are sold individually, so these don’t get qty fields.
there are also physical products, its those ones that can have quantities https://care4catsibiza.org/shop/
Seems to be working..
its when you are on the cart page after having added a physical product from the shop that you cannot edit quantities or delete items from cart…
@greggashley – that seems to be working in the cart, too. Please start a new thread if you continue to have a problem that others can help you with. Thanks.
I just tried it. Both actions seem to work..
My WordPress Twenty Twelve theme is not putting my products in a row. They are all in one long line. Here is the link to one of my pages to view how the products are being displayed. The products were showing in rows, but then it changed after an update.
https://behinderoticdoors.com/products-page/bridal/
Thank you.
Tori
This is what I can see at your site address:
Doesn’t look right to me. The products don’t match the site description, the theme is not 2012, and its opencart not WooCommerce. Maybe you’ve been hacked.
Hey Mike,
Sorry to beat a dead horse and present a new version of the same problem, but I’m having the same problem.Here’s my code…
<?php /** * The template for displaying product content within loops. * * Override this template by copying it to yourtheme/woocommerce/content-product.php * * @author WooThemes * @package WooCommerce/Templates * @version 1.6.4 */ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly global $product, $woocommerce_loop,$wp_query; // Store loop count we're currently on if ( empty( $woocommerce_loop['loop'] ) ) $woocommerce_loop['loop'] = 0; // Store column count for displaying the grid $woocommerce_loop['columns'] = apply_filters( 'loop_shop_columns', 3 ); // Ensure visibility if ( ! $product || ! $product->is_visible() ) return; // Increase loop count $woocommerce_loop['loop']++; // Extra post classes $classes = ''; if ( 0 == ( $woocommerce_loop['loop'] - 1 ) % $woocommerce_loop['columns'] || 1 == $woocommerce_loop['columns'] ) $classes = 'first'; if ( 0 == $woocommerce_loop['loop'] % $woocommerce_loop['columns'] ) $classes = 'last'; $columns = 12/$woocommerce_loop['columns']; ?> <?php if( $woocommerce_loop['loop']%$woocommerce_loop['columns'] == 1 ) { ?> <div class="row"> <?php } ?> <div <?php post_class( 'shopcol '.$classes.' col-lg-'.$columns.' col-md-'.$columns.' col-sm-'.$columns.' col-xs-12' ); ?>> <?php wc_get_template_part( 'content', 'product-inner' ); ?> </div> <?php if( $woocommerce_loop['loop']%$woocommerce_loop['columns'] == 0 || $woocommerce_loop['loop'] == $wp_query->found_posts ) { ?> </div> <?php } ?>
I’ve tried removing the snippets you mentioned, but couldn’t get it to work. Thanks for any help you can give.
- The topic ‘Product per row function broken after update’ is closed to new replies.