is_type( 'variable' ) && class_exists( 'AIEO_DMM_Swatches_Runtime', false ) && false !== has_filter( 'woocommerce_dropdown_variation_attribute_options_html' ) ) { $runtime = AIEO_DMM_Swatches_Runtime::instance(); $draws = method_exists( $runtime, 'swatches_draw' ) ? $runtime->swatches_draw( $product->get_id() ) : true; } if ( ! $draws && class_exists( 'AIEO_Option_Groups_Frontend', false ) && method_exists( 'AIEO_Option_Groups_Frontend', 'config_for_product' ) ) { $draws = (bool) AIEO_Option_Groups_Frontend::config_for_product( $product->get_id() ); } return (bool) apply_filters( 'aieo_block_parity_classic_add_to_cart', $draws, $product ); } public static function classic_add_to_cart( $pre, $parsed_block ) { if ( null !== $pre || empty( $parsed_block['blockName'] ) || 'woocommerce/add-to-cart-with-options' !== $parsed_block['blockName'] ) { return $pre; } if ( is_admin() || ! function_exists( 'woocommerce_template_single_add_to_cart' ) || ! is_singular( 'product' ) ) { return $pre; } $product = wc_get_product( get_queried_object_id() ); if ( ! $product || ! self::draws_add_to_cart( $product ) ) { return $pre; } $previous = isset( $GLOBALS['product'] ) ? $GLOBALS['product'] : null; $GLOBALS['product'] = $product; if ( WP_Block_Type_Registry::get_instance()->is_registered( 'woocommerce/add-to-cart-form' ) ) { $form = ( new WP_Block( array( 'blockName' => 'woocommerce/add-to-cart-form', 'attrs' => array( 'quantitySelectorStyle' => 'stepper' ), 'innerBlocks' => array(), 'innerHTML' => '', 'innerContent' => array(), ), array( 'postId' => $product->get_id(), 'postType' => 'product' ) ) )->render(); $form = preg_replace( '/^
' . $form . '
'; } $GLOBALS['product'] = $previous; if ( '' === $form ) { return $pre; } if ( class_exists( 'AIEO_Theme_Adapters' ) && method_exists( 'AIEO_Theme_Adapters', 'draw' ) ) { AIEO_Theme_Adapters::draw( 'variation_form', 'classic form inside the Add to Cart with Options block' ); } return $form; } } }