Support » Plugin: WooCommerce Filter Orders by Product » Filter by variation

  • Resolved americanknight


    Hi, I love how this plugin adds the ability to filter orders by products. I’m wondering if it could be extended to also filter by product variations. For example, we sell tickets to an event. Filtering orders by the show is useful, but what we really need to see is all of the order far a particular night. I’d be willing to help fund this feature.

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author Kowsar Hossain


    Sorry, currently I don’t have time to extend it at the moment. Maybe in future.

    Hi @kowsar89,

    Would you reconsider implementing a filter?
    I made this, where all you have to do is change 2-3 lines in the Filter_By_Product class.

    $status    = apply_filters( 'wfobp_product_status', 'publish' );
    		$post_type = apply_filters('wfobp_product_filter_product_variation', false);
    		$sql       = "SELECT ID,post_title FROM $wpdb->posts WHERE ";
    		$sql      .= ! $post_type ? "post_type = 'product'" : "(post_type = 'product' OR post_type = 'product_variation')";
    		$sql      .= ( $status == 'any' ) ? '' : " AND post_status = '$status'";
    		$all_posts = $wpdb->get_results( $sql, ARRAY_A );

    And users can add the filter add_filter( 'wfobp_product_filter_product_variation', '__return_true' );

    Great plugin!

    @vorodk Thanks for providing that snippet. Can you please clearify where to put the add_filter part?

    There was an error in the code. I’ll jus review it and get back

    • This reply was modified 1 year, 7 months ago by Philip Rosing. Reason: Error in code

    @vorodk Thanks a lot for reviewing it. I only get the dropdown with all variations, but the result ist always empty. So thanks for making this cool plugin even better.

    @89garvhf23 I removed the comment because i found a mistake in my own code, but there is also an error in the plugin where it shows orders that doesn’t have the selected product. So i decided to investigate that first.
    I think i will make my own plugin based on this one, where i fix the issue i found and add the variation part. I will message you here in the weekend where i have time.

    @vorodk Okay, sounds very good. Thanks for the effort!

    @vorodk I am also looking for the variation to show in the dropdown and wonder how you are getting on with this?

    • This reply was modified 1 year, 6 months ago by rmitch3012.

    @americanknight I added a modified version in the comment above this one

    @vorodk very nice, thanks!

    Thanks @vorodk I have added your plugin but can only see products instead of variations, do I need to change anything?

    • This reply was modified 1 year, 6 months ago by rmitch3012.

    @rmitch3012 my bad, it was the wrong version i uploaded. I have updated the repo.
    In version 1.1.0 you don’t have to do anything

    OR you can keep the one you have now, version 1.0.0, and add this code to your functions.php:

    add_filter( 'wfobp_filter_post_types', function( $post_types ) {
        return ['product', 'product_variation']
    } );
Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Filter by variation’ is closed to new replies.