Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #348677

    Hi,

    I’m trying to figure out how to set the number of items & columns displayed in the ‘related products’ area but independent of the general enfold added setting found in woocomerce/settings/products/Column and Product Count/

    I have tried the woo-commerce suggested method by adding the following function but it does not work as i assume enfold has overwritten this method.

    /**
     * WooCommerce Extra Feature
     * --------------------------
     *
     * Change number of related products on product page
     * Set your own value for 'posts_per_page'
     *
     */ 
    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' );
      function jk_related_products_args( $args ) {
     
    	$args['posts_per_page'] = 6; // 6 related products
    	$args['columns'] = 6; // arranged in 6 columns
    	return $args;
    }
    • This topic was modified 6 years, 10 months ago by  raineysw.
    #349080

    Hey raineysw!

    Try adding this to the bottom of your /enfold/functions.php file.

    add_action( 'init', 'enfold_customization_change_related_products' );
    function enfold_customization_change_related_products() {
    	global $avia_config;
    	$avia_config['shop_single_column'] = 2;
    	$avia_config['shop_single_column_items'] = 4;
    }

    Cheers!
    Elliott

    #349088

    Hi Elliot,

    That seems to work and it appears that ‘5’ is the maximum number of columns supported yes?

    Sean.

    #349468

    Hey!

    That’s right, let us know if you have any other questions.

    Regards,
    Elliott

    #1105265
    This reply has been marked as private.
    #1106573

    Hi,

    Try to set the “orderby” parameter to “meta_value_num” and the “meta_key” to “_price”. Example:

    add_filter('woocommerce_output_related_products_args', 'avf_woocommerce_output_related_products_args_mod', 10, 1);
    function avf_woocommerce_output_related_products_args_mod($args) {
        $args['orderby'] = 'meta_value_num';
        $args['order'] = 'asc';
        $args['meta_key'] = '_price';
    
        return $args;
    }

    Best regards,
    Ismael

    #1146976

    Is there any way to get more product columns (for related as well as in the product slider) as 5?

    Unfortunality 5 is to less for bigger shops in these days. way to much space wasted with 5 products only.

    Thx in advance for fast help :)

    #1147087

    Hi,

    @caiven: Thank you for the inquiry. How did you add the products? Are you using Product Grid element? You can use the following hook to increase the number of items in the related products section.

    function avia_chance_wc_related_columns(){
       global $avia_config;
       $avia_config['shop_single_column'] = 5;			// columns for related products and upsells
       $avia_config['shop_single_column_items'] = 5;	// number of items for related products and upsells
    }
    add_action('wp_head', 'avia_chance_wc_related_columns', 6);

    Best regards,
    Ismael

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.