Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #817220

    Hello people, any clue how to achieve to modify the product slider (woocommerce) to show products by attribute?

    With the shortcode of woocommerce i can show them in grid view…. [product_attribute attribute=’color’ filter=’red’]

    Thanks

    #817851

    Hey webvigo,

    Could you please give us a link to your website, we need more context to be able to help you.

    Best regards,
    Victoria

    #818479

    Hello Victoria,

    Yes let me provide you the demo page were i am working, thanks. I put the titles where i am using the directly shortcode of woocommerce that shows products by attributes and after, a block using the component of the theme “Products slider” that only allows us to show products by categories.

    #818788

    Hi webvigo,

    You need to modify the product slider query. Here is an idea on how to do it
    https://kriesi.at/support/topic/featured-products-in-product-slider-home-page/#post-566482

    If you need further assistance please let us know.
    Best regards,
    Victoria

    #818789

    Hi webvigo,

    You need to modify the product slider query. Here is an idea on how to do it
    https://kriesi.at/support/topic/featured-products-in-product-slider-home-page/#post-566482

    If you need further assistance please let us know.
    Best regards,
    Victoria

    #818804

    Thanks, i will try to work on that.

    #818870

    Thanks, it worked! I made the trick of using post_per_page to select the different attributes. I share my code for any other user:

    
    add_action( 'pre_get_posts', 'pre_get_posts_featured', 10);
    function pre_get_posts_featured( $query ) {
    	$vars = $query->query_vars;
    	if($query->is_archive && $query->is_post_type_archive)
    	{
    		//var_dump($query);
    		if( isset($vars['post_type']) && 'product' == $vars['post_type'] && $vars['posts_per_page'] >= '50')  {
    
    		if ($vars['posts_per_page'] == "50") { $attribute = "red"; }
    		if ($vars['posts_per_page'] == "51") { $attribute = "blue"; }
    
    	    $taxquery = array(
    	        array(
    	            'taxonomy' => 'pa_color',
    	            'field' => 'slug',
    	            'terms' => $attribute,
    	            'compare' => '='
    	        )
    	    );
    	    $query->set( 'tax_query', $taxquery );
    
    		}
    	}
        return $query;
    }
    
    #818899

    Victoria, any chance to do something similar with the related products in the single product view of woocommerce?

    #818937

    Hi webvigo,

    Great job! And thank you for sharing!

    Here is something for you
    https://github.com/woocommerce/woocommerce/issues/850
    You can use the filter from this thread:

    Enfold, WooCommerce Related products column number

    If you need further assistance please let us know.
    Best regards,
    Victoria

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.