Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #249725

    hi again guys,

    i added some custom sorting filters to woocommerce to sort my own product group. the filter is shown in woo-backend, but does not show in the product grid frontend as an option. may you have an idea? here is the code i use to add the filter:

    // Sortierfilter zu Woocommerce hinzufügen
    function custom_woocommerce_get_catalog_ordering_args( $args ) {
      $orderby_value = isset( $_GET['orderby'] ) ? woocommerce_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
     
    	if ( 'MY-CUSTOM-FILTER-SELECT-1' == $orderby_value ) {
    		$args['orderby'] = 'A-CUSTOM-FIELD-1';
    		$args['order'] = '';
    		$args['meta_key'] = '';
    
    	}
    	
    	elseif ( 'MY-CUSTOM-FILTER-SELECT-2' == $orderby_value ) {
    		$args['orderby'] = 'A-CUSTOM-FIELD-2';
    		$args['order'] = '';
    		$args['meta_key'] = '';
    	}
     
    	return $args;
    }
     
    function custom_woocommerce_catalog_orderby( $sortby ) {
    	$sortby['A-CUSTOM-FIELD-1'] = 'CUSTOM-NAME-1';
    	$sortby['A-CUSTOM-FIELD-2'] = 'CUSTOM-NAME-2';
    	return $sortby;
    }
    
    add_filter( 'woocommerce_get_catalog_ordering_args', 'custom_woocommerce_get_catalog_ordering_args' ); 
    add_filter( 'woocommerce_default_catalog_orderby_options', 'custom_woocommerce_catalog_orderby' );
    add_filter( 'woocommerce_catalog_orderby', 'custom_woocommerce_catalog_orderby' );
    • This topic was modified 10 years ago by isee.
    #250252

    hi again, i found this part of code in /config-woocommerce/config.php
    can you help me to ADD my custom types within the child theme:

    (edit – code removed)

    • This reply was modified 10 years ago by Dude.
    #250938

    Hi!

    You just need to copy the entire avia_woocommerce_frontend_search_params function (located in /config-woocommerce/config.php) into your child theme functions.php file. Then modify the function code there. The child theme file will be loaded first and your custom sort function will overwrite the code in the parent theme files because we wrapped all functions into a function_exists() if statement. If you need help with the code implementation please hire a freelancer. I recommend a platform like: http://studio.envato.com/

    Best regards,
    Peter

    #250994

    hey dude, thanx for that, i integrated everything and its working fine :-)

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Product Grid Woocommerce / Custom Sorting Filters’ is closed to new replies.