WC_Product_Variable_Data_Store_CPT::child_has_weight( WC_Product $product )
Does a child have a weight set?
Description Description
Parameters Parameters
- $product
-
(Required) Product object.
Return Return
(boolean)
Source Source
File: includes/data-stores/class-wc-product-variable-data-store-cpt.php
public function child_has_weight( $product ) { global $wpdb; $children = $product->get_visible_children(); if ( ! $children ) { return false; } $format = array_fill( 0, count( $children ), '%d' ); $query_in = '(' . implode( ',', $format ) . ')'; return null !== $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_weight' AND meta_value > 0 AND post_id IN {$query_in}", $children ) ); // @codingStandardsIgnoreLine. }
Changelog Changelog
Version | Description |
---|---|
3.0.0 | Introduced. |