diff --git a/includes/wc-template-functions.php b/includes/wc-template-functions.php index a7c364825d0..27803d06bab 100644 --- a/includes/wc-template-functions.php +++ b/includes/wc-template-functions.php @@ -879,9 +879,12 @@ if ( ! function_exists( 'woocommerce_variable_add_to_cart' ) ) { // Enqueue variation scripts wp_enqueue_script( 'wc-add-to-cart-variation' ); + // Get Available variations? + $get_variations = sizeof( $product->get_children() ) <= apply_filters( 'woocommerce_max_variations', 20 ); + // Load the template wc_get_template( 'single-product/add-to-cart/variable.php', array( - 'available_variations' => sizeof( $product->get_children() ) <= apply_filters( 'woocommerce_max_variations', 20 ) ? $product->get_available_variations() : false, + 'available_variations' => $get_variations ? $product->get_available_variations() : false, 'attributes' => $product->get_variation_attributes(), 'selected_attributes' => $product->get_variation_default_attributes() ) ); diff --git a/templates/single-product/add-to-cart/variable.php b/templates/single-product/add-to-cart/variable.php index a49f8cc928e..db8c7e14519 100644 --- a/templates/single-product/add-to-cart/variable.php +++ b/templates/single-product/add-to-cart/variable.php @@ -20,7 +20,7 @@ global $product, $post; - + $options ) : $loop++; ?>