WooCommerce change products per row based on screen size
-
Lots of help on the web about how to change the number of products per row, as well as how to do the CSS for row widths, etc.
What I haven’t been able to solve is how to dynamically change the number of products per row based on the user’s device.
For example, I’d like 4 per row for desktop, 3 per row for tablets, and 2 per row for smartphones.
Again, I have the CSS for these three configurations, but the problem is the “first” and “last” classes. Those are being assigned to the appropriate products, based on the “loop_columns” quantity set in WooCommerce.
So I may be able to change the CSS for the columns from 4 per row to 3 per row, but the row is still ending at the 4th product because the quantity per row in WC is still set at 4.
Because PHP is server side and doesn’t know the browser size, I can’t write a function to dynamically change the “loop_columns.”
With CSS I can add “first” and “last” classes to the first and last products of a new row width, but don’t know how to get rid of the ones that WC placed.
What am I missing here?
- The topic ‘WooCommerce change products per row based on screen size’ is closed to new replies.