Automattic\WooCommerce\Blocks\Utils

CartCheckoutUtils::find_express_checkout_attributespublic staticWC 1.0

Recursively search the checkout block to find the express checkout block and get the button style attributes

Method of the class: CartCheckoutUtils{}

No Hooks.

Returns

Array|null. Block attributes, if present and valid, otherwise null.

Usage

$result = CartCheckoutUtils::find_express_checkout_attributes( $post_content, $cart_or_checkout );
$post_content(string|array) (required)
The post content.
$cart_or_checkout(string) (required)
The block type to check.

CartCheckoutUtils::find_express_checkout_attributes() code WC 10.3.6

public static function find_express_checkout_attributes( $post_content, $cart_or_checkout ) {
	if ( is_array( $post_content ) ) {
		// If an array is passed, assume it's already been parsed with parse_blocks,
		// use the old method, and show a deprecation warning.
		wc_deprecated_argument(
			'post_content',
			'10.3.0',
			'Passing parsed blocks as an array in $post_content is deprecated. Please pass the post content as a string.'
		);
		return self::find_express_checkout_attributes_in_parsed_blocks( $post_content, $cart_or_checkout );
	}

	$express_block_name = 'woocommerce/' . $cart_or_checkout . '-express-payment-block';

	$scanner = Block_Scanner::create( $post_content );

	while ( $scanner->next_delimiter() ) {
		if ( $scanner->opens_block( $express_block_name ) ) {
			return $scanner->allocate_and_return_parsed_attributes();
		}
	}

	return null;
}