Automattic\WooCommerce\Blocks\Utils
CartCheckoutUtils::find_express_checkout_attributes
Recursively search the checkout block to find the express checkout block and get the button style attributes
Метод класса: CartCheckoutUtils{}
Хуков нет.
Возвращает
array|null. Block attributes, if present and valid, otherwise null.
Использование
$result = CartCheckoutUtils::find_express_checkout_attributes( $post_content, $cart_or_checkout );
- $post_content(строка|массив) (обязательный)
- The post content.
- $cart_or_checkout(строка) (обязательный)
- The block type to check.
Код CartCheckoutUtils::find_express_checkout_attributes() CartCheckoutUtils::find express checkout attributes WC 11.3.0
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;
}