• Resolved Bhanu Singh

    (@bhanusingh)


    I am trying to query products with price range. My code is leaving variable products as they don’t have the value in the key _regular_price.

            'meta_query' => array(
              'relation' => 'OR',
                array (
                  'key' => '_regular_price',
                  'compare' => 'NOT EXISTS',
                  'value' => '',
                ),
                array(
                  'key' => '_regular_price',
                  'value' => array( intval($price_init[0]), intval($price_init[1]) ),
                  'compare' => 'BETWEEN',
                  'type' => 'numeric',
                ),
            ),
    

    I tried to add NOT EXISTS as well but then also it drops variable product.

    How can I query for variable products with the price that appears on the product admin page again the variable product

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support RK a11n

    (@riaanknoetze)

    Hi there,

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Thread Starter Bhanu Singh

    (@bhanusingh)

    Hey RK,

    I have tried #developers channel in slack, but haven’t got any reply there yet. I will go through the developer resources portal if I can find the solution there.

    Hope someone can help me out as this is a prominent e-commerce functionality (to search products between two price ranges.)

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to query product with price range using WP_Query’ is closed to new replies.