Automattic\WooCommerce\Blocks\Utils
CartCheckoutUtils::find_express_checkout_attributes_in_parsed_blocks
Recursively search the checkout block to find the express checkout block and get the button style attributes using the parse_blocks function.
Method of the class: CartCheckoutUtils{}
No Hooks.
Returns
Array. Block attributes.
Usage
$result = CartCheckoutUtils::find_express_checkout_attributes_in_parsed_blocks( $blocks, $cart_or_checkout );
- $blocks(array) (required)
- Blocks to search.
- $cart_or_checkout(string) (required)
- The block type to check.
CartCheckoutUtils::find_express_checkout_attributes_in_parsed_blocks() CartCheckoutUtils::find express checkout attributes in parsed blocks code WC 10.7.0
public static function find_express_checkout_attributes_in_parsed_blocks( $blocks, $cart_or_checkout ) {
$express_block_name = 'woocommerce/' . $cart_or_checkout . '-express-payment-block';
foreach ( $blocks as $block ) {
if ( ! empty( $block['blockName'] ) && $express_block_name === $block['blockName'] && ! empty( $block['attrs'] ) ) {
return $block['attrs'];
}
if ( ! empty( $block['innerBlocks'] ) ) {
$answer = self::find_express_checkout_attributes_in_parsed_blocks( $block['innerBlocks'], $cart_or_checkout );
if ( $answer ) {
return $answer;
}
}
}
}