Tweak get_children to look for empty transient
This commit is contained in:
parent
fe12b330c0
commit
7f825a98ce
|
@ -83,21 +83,17 @@ class WC_Product_Grouped extends WC_Product {
|
|||
* @return array
|
||||
*/
|
||||
public function get_children() {
|
||||
if ( ! is_array( $this->children ) || empty( $this->children ) ) {
|
||||
$transient_name = 'wc_product_children_ids_' . $this->id;
|
||||
$this->children = get_transient( $transient_name );
|
||||
|
||||
if ( ! is_array( $this->children ) ) {
|
||||
|
||||
$this->children = array();
|
||||
|
||||
$transient_name = 'wc_product_children_ids_' . $this->id;
|
||||
|
||||
if ( false === ( $this->children = get_transient( $transient_name ) ) ) {
|
||||
if ( empty( $this->children ) ) {
|
||||
|
||||
$this->children = get_posts( 'post_parent=' . $this->id . '&post_type=product&orderby=menu_order&order=ASC&fields=ids&post_status=publish&numberposts=-1' );
|
||||
|
||||
set_transient( $transient_name, $this->children, YEAR_IN_SECONDS );
|
||||
}
|
||||
}
|
||||
|
||||
return (array) $this->children;
|
||||
}
|
||||
|
||||
|
|
|
@ -128,11 +128,11 @@ class WC_Product_Variable extends WC_Product {
|
|||
* @return array of children ids
|
||||
*/
|
||||
public function get_children( $visible_only = false ) {
|
||||
if ( ! is_array( $this->children ) ) {
|
||||
$this->children = array();
|
||||
if ( ! is_array( $this->children ) || empty( $this->children ) ) {
|
||||
$transient_name = 'wc_product_children_ids_' . $this->id;
|
||||
$this->children = get_transient( $transient_name );
|
||||
|
||||
if ( false === ( $this->children = get_transient( $transient_name ) ) ) {
|
||||
if ( empty( $this->children ) ) {
|
||||
$args = array(
|
||||
'post_parent' => $this->id,
|
||||
'post_type' => 'product_variation',
|
||||
|
|
Loading…
Reference in New Issue