WC_Product_Data_Store_CPT::is_existing_global_unique_id()
Check if product sku is found for any other product IDs.
Метод класса: WC_Product_Data_Store_CPT{}
Хуков нет.
Возвращает
true|false
.
Использование
$WC_Product_Data_Store_CPT = new WC_Product_Data_Store_CPT(); $WC_Product_Data_Store_CPT->is_existing_global_unique_id( $product_id, $global_unique_id );
- $product_id(int) (обязательный)
- Product ID.
- $global_unique_id(строка) (обязательный)
- Will be slashed to work around https://core.trac.wordpress.org/ticket/27421.
Список изменений
С версии 9.1.0 | Введена. |
Код WC_Product_Data_Store_CPT::is_existing_global_unique_id() WC Product Data Store CPT::is existing global unique id WC 9.8.1
public function is_existing_global_unique_id( $product_id, $global_unique_id ) { global $wpdb; // phpcs:ignore WordPress.VIP.DirectDatabaseQuery.DirectQuery return (bool) $wpdb->get_var( $wpdb->prepare( " SELECT posts.ID FROM {$wpdb->posts} as posts INNER JOIN {$wpdb->wc_product_meta_lookup} AS lookup ON posts.ID = lookup.product_id WHERE posts.post_type IN ( 'product', 'product_variation' ) AND posts.post_status != 'trash' AND lookup.global_unique_id = %s AND lookup.product_id <> %d LIMIT 1 ", wp_slash( $global_unique_id ), $product_id ) ); }