Change WooCommerce Product Columns - woocommerce

Looking to have 3 column layout on https://sweetheartshair.com but can not override the 4 column layout
// Change number or products per row to 3
add_filter('loop_shop_columns', 'loop_columns');
if (!function_exists('loop_columns')) {
function loop_columns() {
return 3; // 3 products per row
}
}
code sample is not doing anything - added this to the themes functions.php file as suggested in other samples.

code sample above is correct -> I had it twice in functions file so was conflicting

Related

where add a WooCommerce script for product variation?

I'm trying to add a script to php/Woocommerce (theme: customify) because beyond 20 product variation, I cannot add more.
My question is : where add the script and what is the script ?
I found some informations but not the solution. I tried this one :
add_filter( 'woocommerce_admin_meta_boxes_variations_per_page', 'handsome_bearded_guy_increase_variations_per_page' );
function handsome_bearded_guy_increase_variations_per_page() {
return 50;
}
but no results.

Change number of products displayed per page in woocommerce shop page

im trying to display number of products in shop page (woocommerce) as my requirement but following code seems to not working any more with latest version of WooCommerce
add_filter( 'loop_shop_per_page', 'new_loop_shop_per_page', 20 );
function new_loop_shop_per_page( $cols ) {
// $cols contains the current number of products per page based on the value stored on Options -> Reading
// Return the number of products you wanna show per page.
$cols = 9;
return $cols;
}

WooCommerce select x number of items from large group for single product

I have a Woocommerce site where customers can order color samples with the following characteristics:
Select multiple colors from a list of over 100
First 3 choices are free
Each subsequent color choice will add 1 dollar to price of order
It does not seem appropriate in this case to make 100+ separate simple products for each color and bundle them (neither do we track inventory on samples) I just want customers to make their multiple choices in the context of one product called "Samples". I have looked at the bundled products page docs and none of these seem appropriate for what I am trying to do.
I solved this using a plugin and some custom code. The plugin is here, and the custom code counts the number of items in the grouping and modifies the price based on that number. In my case, I wanted each option to cost a dollar, but have the first 3 be free. I use a woo hook to change the price before adding it to the cart (this gets fired off when the add to cart button is clicked after selections are made):
add_action( 'woocommerce_before_calculate_totals', 'add_custom_price' );
function add_custom_price( $cart_object ) {
$target_product_id = 9516; // my product ID
foreach ( $cart_object->cart_contents as $key=>$value ) {
if ( $value['product_id'] == $target_product_id ) {
if (count($value['tmdata']['tmcp_post_fields'])>=3){
$value['data']->set_price($value['tm_epo_options_prices'] - 3);
} elseif (count($value['tmdata']['tmcp_post_fields'])==2){
$value['data']->set_price($value['tm_epo_options_prices'] - 2);
} elseif (count($value['tmdata']['tmcp_post_fields'])==1){
$value['data']->set_price($value['tm_epo_options_prices'] - 1);
}
}
}
}
Please note that above code is calling data (tm_epo_options_prices) provided by the plugin.

Woocommerce plugin : issue editing number of columns in shop page

Woocommerce by default displays 4 categories and products per row in shop page. I want to display 5 categories / products per row, I edited CSS to have 5 columns and to resize the thumbnails, it worked, but the last / 5th column is always empty : the 5th category or product goes to the 2nd line.
If you are using custom theme add this code in your functions.php
// Change number or products per row to 5
add_filter('loop_shop_columns', 'loop_columns');
if (!function_exists('loop_columns')) {
function loop_columns() {
return 5; // 5 products per row
}
}
and If you are using any woothemes then add this code in your functions.php
// Override theme default specification for product # per row
function loop_columns() {
return 5; // 5 products per row
}
add_filter('loop_shop_columns', 'loop_columns', 999);

How to show Woocommerce product per label as per my wish?

Please see the photo. Here showing 3 products by default. Here I want to keep 4 products per label. Product container contain more space for per product. I also want to reduce this space for keep more products per label.
How can I keep 4 products per label? Please help me experienced man....
Thanks
Adding this to your functions.php file should work, it should change the 3 products per row to 4 products.
// Change number or products per row to 4
add_filter('loop_shop_columns', 'loop_columns');
if (!function_exists('loop_columns'))
{
function loop_columns()
{
return 4; // 4 products per row
}
}

Resources