Automattic\WooCommerce\Internal\ProductAttributesLookup
LookupDataStore::delete_data_for
Delete all the lookup table entries for a given product, if it's a variable product information for variations is deleted too.
Method of the class: LookupDataStore{}
No Hooks.
Returns
null. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->delete_data_for( $product_id );
- $product_id(int) (required)
- Simple product id, or main/parent product id for variable products.
LookupDataStore::delete_data_for() LookupDataStore::delete data for code WC 10.8.1
private function delete_data_for( int $product_id ) {
global $wpdb;
// Single query handled with `index_merge` strategy, while separate with `range` (better performing) on available indexes.
$wpdb->query(
$wpdb->prepare(
'DELETE FROM %i WHERE product_or_parent_id = %d',
$this->lookup_table_name,
$product_id
)
);
$wpdb->query(
$wpdb->prepare(
'DELETE FROM %i WHERE product_id = %d',
$this->lookup_table_name,
$product_id
)
);
}