From d1c0f7774bad93bcb35b910340aa74c628dbfe22 Mon Sep 17 00:00:00 2001 From: James Allan Date: Mon, 3 Aug 2020 14:01:31 +1000 Subject: [PATCH] Remove duplicate function argument --- includes/class-wc-product-variable.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/includes/class-wc-product-variable.php b/includes/class-wc-product-variable.php index fe9b1e4416c..93c1c237724 100644 --- a/includes/class-wc-product-variable.php +++ b/includes/class-wc-product-variable.php @@ -282,12 +282,11 @@ class WC_Product_Variable extends WC_Product { /** * Get an array of available variations for the current product. * - * @param bool $render_variations Prepares a data array for each variant for output in the add to cart form. Pass `false` to only return the available variations as objects. - * @param bool $return_array_of_data If true, return an array of data for the variation; if false, return a WC_Product_Variation object. + * @param string $return Optional. The format to return the results in. Can be 'array' to return an array of variation data or 'objects' for the product objects. Default 'array'. * - * @return array|WC_Product_Variation + * @return array[]|WC_Product_Variation[] */ - public function get_available_variations( $render_variations = true, $return_array_of_data = true ) { + public function get_available_variations( $return = 'array' ) { $variation_ids = $this->get_children(); $available_variations = array(); @@ -309,14 +308,14 @@ class WC_Product_Variable extends WC_Product { continue; } - if ( $render_variations ) { - $available_variations[] = $return_array_of_data ? $this->get_available_variation( $variation ) : $variation; + if ( 'array' === $return ) { + $available_variations[] = $this->get_available_variation( $variation ); } else { $available_variations[] = $variation; } } - if ( $render_variations ) { + if ( 'array' === $return ) { $available_variations = array_values( array_filter( $available_variations ) ); } @@ -622,7 +621,7 @@ class WC_Product_Variable extends WC_Product { } ); - $variations = $this->get_available_variations( true, false ); + $variations = $this->get_available_variations( 'objects' ); foreach ( $variations as $variation ) { if ( $this->variation_matches_filters( $variation, $attributes_with_terms ) ) { return true;