From dce81b4d4e098365efbb398b587390a3c136247d Mon Sep 17 00:00:00 2001 From: Claudiu Lodromanean Date: Wed, 8 Feb 2017 09:04:13 -0800 Subject: [PATCH] Use store's decimal settings when figuring out what's a sale product --- includes/data-stores/class-wc-product-data-store-cpt.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/includes/data-stores/class-wc-product-data-store-cpt.php b/includes/data-stores/class-wc-product-data-store-cpt.php index 707569585af..3d33d5c6e5f 100644 --- a/includes/data-stores/class-wc-product-data-store-cpt.php +++ b/includes/data-stores/class-wc-product-data-store-cpt.php @@ -661,6 +661,9 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da */ public function get_on_sale_products() { global $wpdb; + + $decimals = absint( wc_get_price_decimals() ); + return $wpdb->get_results( " SELECT post.ID as id, post.post_parent as parent_id FROM `$wpdb->posts` AS post LEFT JOIN `$wpdb->postmeta` AS meta ON post.ID = meta.post_id @@ -671,7 +674,7 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da AND meta2.meta_key = '_price' AND CAST( meta.meta_value AS DECIMAL ) >= 0 AND CAST( meta.meta_value AS CHAR ) != '' - AND CAST( meta.meta_value AS DECIMAL( 10, 2 ) ) = CAST( meta2.meta_value AS DECIMAL( 10, 2 ) ) + AND CAST( meta.meta_value AS DECIMAL( 10, {$decimals} ) ) = CAST( meta2.meta_value AS DECIMAL( 10, {$decimals} ) ) GROUP BY post.ID; " ); }