/* * * * * * * * * *
* Hide add to card buttons for certain products if in category slug = “not_for_sale”
* * * * * * * * * *
*
function themepaint_custom_cart_buttons(){
$product = get_product();
if ( has_term( ‘not-sale-sale’, ‘product_cat’) ){

// removing the purchase buttons
remove_action( ‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_loop_add_to_cart’ );
remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_add_to_cart’, 30 );
remove_action( ‘woocommerce_simple_add_to_cart’, ‘woocommerce_simple_add_to_cart’, 30 );
remove_action( ‘woocommerce_grouped_add_to_cart’, ‘woocommerce_grouped_add_to_cart’, 30 );
remove_action( ‘woocommerce_variable_add_to_cart’, ‘woocommerce_variable_add_to_cart’, 30 );
remove_action( ‘woocommerce_external_add_to_cart’, ‘woocommerce_external_add_to_cart’, 30 );
}
}
add_action( ‘wp’, ‘themepaint_custom_cart_buttons’ );
*/

/* * * * * * * * * *
* Hide add to card buttons if product is not purchaseable
* * * * * * * * * *
*
global $product;
if ( ! $product->is_purchasable() ) {
add_filter( ‘woocommerce_is_purchasable’, ‘__return_false’);
}
*/

/* * * * * * * * * *
* Apply different CSS if product in particular category, used to hide add to cart button
* * * * * * * * * *
*
add_filter(‘body_class’,’not_for_sale’);
function not_for_sale( $classes ) {
if( is_singular( ‘product’ ) ):
global $post;
foreach( get_the_terms( $post->ID, ‘product_cat’ ) as $cat )
$classes[] = $cat->slug;
endif;
return $classes;
}
*/

 

 

 

 

 

/**
* Change number of related products output
*/
function woo_related_products_limit() {
global $product;

$args[‘posts_per_page’] = 6;
return $args;
}
add_filter( ‘woocommerce_output_related_products_args’, ‘jk_related_products_args’, 20 );
function jk_related_products_args( $args ) {
$args[‘posts_per_page’] = 6; // 4 related products
$args[‘columns’] = 6; // arranged in 2 columns
return $args;
}