Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save somewherewarm-snippets/7195d887f3f901a87eca4dbe8b6e9f5c to your computer and use it in GitHub Desktop.
Save somewherewarm-snippets/7195d887f3f901a87eca4dbe8b6e9f5c to your computer and use it in GitHub Desktop.
<?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: WooCommerce
* Author URI: http://woocommerce.com
* Developer: Jason Kytros
*
*
* Copyright: © 2021 Automattic.
* 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;
}
Copy link

ghost 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
Copy link
Author

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