WC_Product_Variable_Data_Store_CPT::child_has_dimensions
Does a child have dimensions set?
Метод класса: WC_Product_Variable_Data_Store_CPT{}
Хуков нет.
Возвращает
true|false.
Использование
$WC_Product_Variable_Data_Store_CPT = new WC_Product_Variable_Data_Store_CPT(); $WC_Product_Variable_Data_Store_CPT->child_has_dimensions( $product );
- $product(WC_Product) (обязательный)
- Product object.
Список изменений
| С версии 3.0.0 | Введена. |
Код WC_Product_Variable_Data_Store_CPT::child_has_dimensions() WC Product Variable Data Store CPT::child has dimensions WC 10.7.0
public function child_has_dimensions( $product ) {
global $wpdb;
$children = $product->get_visible_children();
if ( ! $children ) {
return false;
}
$format = array_fill( 0, count( $children ), '%d' );
$query_in = '(' . implode( ',', $format ) . ')';
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
return null !== $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key IN ( '_length', '_width', '_height' ) AND meta_value > 0 AND post_id IN {$query_in}", $children ) );
}