Created
January 8, 2019 17:09
-
-
Save HenriqueSilverio/ef7b3a1a0de8b416a59123cbecb0dfb5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function getChildrenProducts() | |
{ | |
$productId = get_the_ID(); | |
$product = wc_get_product($productId); | |
$childrenIds = $product->get_children(); | |
if (empty($childrenIds)) { | |
return []; | |
} | |
$children = wc_get_products([ | |
'include' => $childrenIds, | |
]); | |
if (empty($children)) { | |
return []; | |
} | |
return $children; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment