Automattic\WooCommerce\Internal\ProductAttributesLookup
LookupDataStore::update_stock_status_for()
Update the stock status of the lookup table entries for a given product.
Method of the class: LookupDataStore{}
No Hooks.
Return
null
. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->update_stock_status_for( $product );
- $product(\WC_Product) (required)
- The product to update the entries for.
LookupDataStore::update_stock_status_for() LookupDataStore::update stock status for code WC 9.8.2
private function update_stock_status_for( \WC_Product $product ) { global $wpdb; $in_stock = $product->is_in_stock(); // phpcs:disable WordPress.DB.PreparedSQL.NotPrepared $wpdb->query( $wpdb->prepare( 'UPDATE ' . $this->lookup_table_name . ' SET in_stock = %d WHERE product_id = %d', $in_stock ? 1 : 0, $product->get_id() ) ); // phpcs:enable WordPress.DB.PreparedSQL.NotPrepared }