Automattic\WooCommerce\Internal\ProductAttributesLookup

LookupDataStore::update_stock_status_forprivateWC 1.0

Update the stock status of the lookup table entries for a given product.

Method of the class: LookupDataStore{}

No Hooks.

Returns

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() code WC 10.8.1

private function update_stock_status_for( \WC_Product $product ) {
	global $wpdb;

	$in_stock = $product->is_in_stock();

	$wpdb->query(
		$wpdb->prepare(
			'UPDATE %i SET in_stock = %d WHERE product_id = %d',
			$this->lookup_table_name,
			$in_stock ? 1 : 0,
			$product->get_id()
		)
	);
}