• Resolved davethedon

    (@davethedon)


    Hi Oscar,

    I’d like to report a potential bug in class-wcpbc-frontend-pricing.php, whereby on line 43 (add_filter( ‘the_posts’, array( __CLASS__, ‘remove_product_query_filters’ ) );), it runs a function that is removing the filter for filter_price_post_clauses before it gets a chance to do its thing.

    The end result is the args don’t get filtered and the SQL query generated doesn’t join the postmeta table and query the applicable price meta value for the products, rather relying on the default query, using the min_price and max_price fields in wc_product_meta_lookup, which obviously isn’t accurate.

    Could the solution here be to remove those filter further on from when “the_posts” fires? And what would the implications be for not removing it at all? I have been trying to trace the problem for the last hour and I’ve only come across this as being the cause just moments ago, so I haven’t delved into it at this time. I thought it would be better to report it to you anyway, potentially hoping for for an official fix.

    Thank you for your time.

    Best,
    Dave

    • This topic was modified 3 years, 7 months ago by davethedon.
    • This topic was modified 3 years, 7 months ago by davethedon.
    • This topic was modified 3 years, 7 months ago by davethedon.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Oscar Gare

    (@oscargare)

    Hi @davethedon ,

    Thanks for the feedback. The issue only could happen if another plugin uses the get_posts function before WordPress runs the main WP Query.

    In any case, we’ll add an IF to remove the filters only after the main WP Query is executed.

    Thread Starter davethedon

    (@davethedon)

    Hi Oscar,

    Off the top of my head it could be Advanced Custom Fields. Thanks for looking into it and coming up with a graceful solution.

    Best,
    Dave

    Thread Starter davethedon

    (@davethedon)

    Nope – it’s not ACF. I found the culprit: Post Types Order.

    Plugin Author Oscar Gare

    (@oscargare)

    Hi @davethedon
    The latest version of PBoC should solve the issue. Thanks for the feedback.

    Thread Starter davethedon

    (@davethedon)

    Looks like it! Thanks, Oscar.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Product query – Filter by Price – not working properly’ is closed to new replies.