Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
/**
* Plugin Name: WooCommerce Product Bundles - Bundled Items Grid Layout column count
* Plugin URI: http://woocommerce.com/products/product-bundles/
* Description: Use this snippet to change the bundled items column count when using the 'Grid' Layout option.
* Version: 1.0
* Author: SomewhereWarm
* Author URI: http://somewherewarm.gr/
* Developer: Jason Kytros
*
*
* Copyright: © 2018 Jason Kytros (jask@somewherewarm.gr).
* License: GNU General Public License v3.0
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
add_filter( 'woocommerce_bundled_items_grid_layout_columns', 'wc_pb_grid_layout_change_number_of_columns', 10, 2 );
function wc_pb_grid_layout_change_number_of_columns( $columns, $bundle ) {
return 4;
}
@arturburkalo

This comment has been minimized.

Copy link

@arturburkalo arturburkalo commented Mar 31, 2021

Looking to change to this on a mobile view, is there another snippet that can help with this? Thnaks.

@somewherewarm-snippets

This comment has been minimized.

Copy link
Owner Author

@somewherewarm-snippets somewherewarm-snippets commented Mar 31, 2021

Hello there,

Thanks for reaching out!

Product Bundles ignores the layout you have selected when displaying the bundle form in small screens, such as mobile screens. In these screens, all bundled items are being displayed in a long list, one on top of the other. From a user experience, it is preferred to display items in this way in mobile screens — if bundled items showed up in a Grid format with multiple columns then it would be very hard for users to read the item’s data and make any selections.

If you are confident that you ’d like to display items in multiple columns in mobile screens, then you can achieve this with custom code. In this case, it might be a good idea to hire a developer to help. For WordPress/WooCommerce customizations, we highly recommend https://codeable.io/.

Cheers,
Maria Chekimoglou
Support Engineer | SomewhereWarm SMPC | https://somewherewarm.com/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment