Automattic\WooCommerce\Internal\ProductAttributesLookup
LookupDataStore::insert_lookup_table_data()
Insert one entry in the lookup table.
Method of the class: LookupDataStore{}
No Hooks.
Return
null
. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->insert_lookup_table_data( $product_id, $product_or_parent_id, $taxonomy, $term_id, $is_variation_attribute, $has_stock );
- $product_id(int) (required)
- The product id.
- $product_or_parent_id(int) (required)
- The product id for non-variable products, the main/parent product id for variations.
- $taxonomy(string) (required)
- Taxonomy name.
- $term_id(int) (required)
- Term id.
- $is_variation_attribute(true|false) (required)
- True if the taxonomy corresponds to an attribute used to define variations.
- $has_stock(true|false) (required)
- True if the product is in stock.
LookupDataStore::insert_lookup_table_data() LookupDataStore::insert lookup table data code WC 9.6.1
private function insert_lookup_table_data( int $product_id, int $product_or_parent_id, string $taxonomy, int $term_id, bool $is_variation_attribute, bool $has_stock ) { global $wpdb; // phpcs:disable WordPress.DB.PreparedSQL.NotPrepared $wpdb->query( $wpdb->prepare( 'INSERT INTO ' . $this->lookup_table_name . ' ( product_id, product_or_parent_id, taxonomy, term_id, is_variation_attribute, in_stock) VALUES ( %d, %d, %s, %d, %d, %d )', $product_id, $product_or_parent_id, $taxonomy, $term_id, $is_variation_attribute ? 1 : 0, $has_stock ? 1 : 0 ) ); // phpcs:enable WordPress.DB.PreparedSQL.NotPrepared }