WC_Product_Data_Store_CPT::get_starting_sales()
Returns an array of IDs of products that have sales starting soon.
Method of the class: WC_Product_Data_Store_CPT{}
No Hooks.
Return
Array
.
Usage
$WC_Product_Data_Store_CPT = new WC_Product_Data_Store_CPT(); $WC_Product_Data_Store_CPT->get_starting_sales();
Changelog
Since 3.0.0 | Introduced. |
WC_Product_Data_Store_CPT::get_starting_sales() WC Product Data Store CPT::get starting sales code WC 9.4.2
public function get_starting_sales() { global $wpdb; // phpcs:ignore WordPress.VIP.DirectDatabaseQuery.DirectQuery return $wpdb->get_col( $wpdb->prepare( "SELECT postmeta.post_id FROM {$wpdb->postmeta} as postmeta LEFT JOIN {$wpdb->postmeta} as postmeta_2 ON postmeta.post_id = postmeta_2.post_id LEFT JOIN {$wpdb->postmeta} as postmeta_3 ON postmeta.post_id = postmeta_3.post_id WHERE postmeta.meta_key = '_sale_price_dates_from' AND postmeta_2.meta_key = '_price' AND postmeta_3.meta_key = '_sale_price' AND postmeta.meta_value > 0 AND postmeta.meta_value < %s AND postmeta_2.meta_value != postmeta_3.meta_value", time() ) ); }