Automattic\WooCommerce\Blocks\BlockTypes

MiniCartShoppingButtonBlock::render_experimental_iapi_markupprotectedWC 1.0

Render experimental iAPI powered markup for the Mini-Cart Contents block.

Method of the class: MiniCartShoppingButtonBlock{}

No Hooks.

Returns

String. Rendered block type output.

Usage

// protected - for code of main (parent) or child class
$result = $this->render_experimental_iapi_markup( $attributes, $content, $block );
$attributes(array) (required)
Block attributes.
$content(string) (required)
Block content.
$block(WP_Block) (required)
Block instance.

MiniCartShoppingButtonBlock::render_experimental_iapi_markup() code WC 10.3.6

<?php
protected function render_experimental_iapi_markup( $attributes, $content, $block ) {
	ob_start();
	$shop_url                     = wc_get_page_permalink( 'shop' );
	$default_start_shopping_label = __( 'Start shopping', 'woocommerce' );
	$start_shopping_label         = $attributes['startShoppingButtonLabel'] ? $attributes['startShoppingButtonLabel'] : $default_start_shopping_label;
	$wrapper_attributes           = get_block_wrapper_attributes( array( 'class' => 'wc-block-components-button wp-element-button wc-block-mini-cart__shopping-button' ) );
	?>
	<div class="wp-block-button has-text-align-center">
		<a
			href="<?php echo esc_attr( $shop_url ); ?>"
			<?php echo $wrapper_attributes; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
		>
			<div class="wc-block-components-button__text">
				<?php echo esc_html( $start_shopping_label ); ?>
			</div>
		</a>
	</div>
	<?php
	return ob_get_clean();
}