WC_Product_Data_Store_CPT::get_query_for_stock()
Returns query statement for getting current _stock of a product.
Метод класса: WC_Product_Data_Store_CPT{}
Хуков нет.
Возвращает
Строку|null
. Query statement.
Использование
$WC_Product_Data_Store_CPT = new WC_Product_Data_Store_CPT(); $WC_Product_Data_Store_CPT->get_query_for_stock( $product_id );
- $product_id(int) (обязательный)
- Product ID.
Код WC_Product_Data_Store_CPT::get_query_for_stock() WC Product Data Store CPT::get query for stock WC 8.7.0
public function get_query_for_stock( $product_id ) { global $wpdb; return $wpdb->prepare( " SELECT COALESCE( MAX( meta_value ), 0 ) FROM $wpdb->postmeta as meta_table WHERE meta_table.meta_key = '_stock' AND meta_table.post_id = %d ", $product_id ); }