How to query "variable products with sale price which are in stock" in woocommerce?
i didnt get any result so far. i use Jet-Engine to create custom query but it would be enough for me if someone knows the related meta-keys to query such products
How to query "variable products with sale price which are in stock" in woocommerce?
i didnt get any result so far. i use Jet-Engine to create custom query but it would be enough for me if someone knows the related meta-keys to query such products
Copyright © 2021 Jogjafile Inc.
Querying variable products with a sale price that are in stock in WooCommerce involves some complexities because the stock status and sale price are often stored at the variation level, not at the parent product level. You'll need to make use of WordPress's WP_Query or WooCommerce's WC_Product_Query and consider the metadata for both parent products and their variations.
Here are the relevant meta keys you might consider:
For variable products:
Here is a code snippet for querying variable products that are on sale and in stock. This query is relatively direct but keep in mind it may not handle all edge cases and might require optimization for performance: