Use store's decimal settings when figuring out what's a sale product

This commit is contained in:
Claudiu Lodromanean 2017-02-08 09:04:13 -08:00
parent 06c17d6be4
commit dce81b4d4e
1 changed files with 4 additions and 1 deletions

View File

@ -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;
" );
}