Automattic\WooCommerce\Internal\ProductAttributesLookup
LookupDataStore::insert_lookup_table_data
Insert one entry in the lookup table.
Метод класса: LookupDataStore{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
// private - только в коде основоного (родительского) класса $result = $this->insert_lookup_table_data( $product_id, $product_or_parent_id, $taxonomy, $term_id, $is_variation_attribute, $has_stock );
- $product_id(int) (обязательный)
- The product id.
- $product_or_parent_id(int) (обязательный)
- The product id for non-variable products, the main/parent product id for variations.
- $taxonomy(строка) (обязательный)
- Taxonomy name.
- $term_id(int) (обязательный)
- Term id.
- $is_variation_attribute(true|false) (обязательный)
- True if the taxonomy corresponds to an attribute used to define variations.
- $has_stock(true|false) (обязательный)
- True if the product is in stock.
Код LookupDataStore::insert_lookup_table_data() LookupDataStore::insert lookup table data WC 10.3.4
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
}