Automattic\WooCommerce\Blocks\BlockTypes

Checkout::find_local_pickup_text_in_checkout_block │ private │ WC 1.0

Find the shipping methods block, then get the value of the localPickupText attribute from it.

Method of the class: Checkout{}

No Hooks.

Returns

null|string. The local pickup text if found, otherwise null.

Usage

// private - for code of main (parent) class only
$result = $this->find_local_pickup_text_in_checkout_block( $post_content );
$post_content(string) (required)
The post content to search through.

Checkout::find_local_pickup_text_in_checkout_block() code WC 11.2.2

private function find_local_pickup_text_in_checkout_block( $post_content ) {
	$scanner = Block_Scanner::create( $post_content );

	while ( $scanner->next_delimiter() ) {
		if ( $scanner->opens_block( 'woocommerce/checkout-shipping-method-block' ) ) {
			$attributes = $scanner->allocate_and_return_parsed_attributes();
			if ( isset( $attributes['localPickupText'] ) ) {
				return $attributes['localPickupText'];
			}
		}
	}

	return null;
}