Home Forums WoodMart support forum Price filter for variations

Price filter for variations

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #163392

    lofer
    Participant

    The price filter on products and variations is done by querying the wc_product_meta_lookup table, but the post_type ‘product’ in this table are priced NULL, only variations are priced. This returns min (minimum_price) and maximum (maximum_price) NULL and the price filter does not appear.

    In your code the queries are for post_type = ‘product’ do you get a solution for the filters and the results are about variation?

    Thank you.

    #163441

    lofer
    Participant

    Please see this link:
    https://stackoverflow.com/questions/49342704/product-variation-wp-query-with-a-product-category-in-woocommerce

    HERE: Important Notes on Product Variations:
    Product categories (or product tags) are not handled by product variations, but by the parent variable product.

    Thus, in queries to the wc_product_meta_lookup table your are looking for IDs (wp_posts.ID) that are in certain categories (table wp_term_relationships), but you should also search (wp_posts.ID) whose post_parent were also in these categories (variations are not related to categories, but parents yes)

    This happens in the class-widget-price-filter.php file (when calculate price range for filter (min and max), but also should look for classes that return searches.

    I would like to resolve this as soon as possible, because is a important issue.

    Thank you.

    #163442

    Artem Temos
    Keymaster

    Hello,

    We use code from the WooCommerce core widget for the price filter. Check how it works with a default theme and WooCommerce widget to see if it is our theme issue or core WooCommerce problem.

    Kind Regards

    #163475

    lofer
    Participant

    Thanks I already changed the queries to include in the variations and it works. This is a problem that should be corrected in the future, assuming that variations have different prices, the current filter does not work.

    #163521

    Artem Temos
    Keymaster

    Do you mean that this problem is with our theme’s price filter only or it is a general WooCommerce issue?

    #163591

    lofer
    Participant

    From what I found, it’s a problem with woocommerce, not your theme.

    It’s simple, when querying the lookup table, it looks for IDs that are related to taxonomies, but variations (product_variation) are never related to taxonomies (but rather product), so they never appear as a result of the query.

    Thank you.

    #163594

    Artem Temos
    Keymaster

    OK, thank you. In this situation, we suggest you to report this issue on WooCommerce github and if there is some bug, they will fix in the update.

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