Automattic\WooCommerce\Blocks\BlockTypes
MiniCartFooterBlock::render_experimental_iapi_mini_cart_footer
Render experimental iAPI powered Mini-Cart Footer block.
Method of the class: MiniCartFooterBlock{}
No Hooks.
Returns
String. Rendered block type output.
Usage
// protected - for code of main (parent) or child class $result = $this->render_experimental_iapi_mini_cart_footer( $attributes, $content, $block );
- $attributes(array) (required)
- Block attributes.
- $content(string) (required)
- Block content.
- $block(WP_Block) (required)
- Block instance.
MiniCartFooterBlock::render_experimental_iapi_mini_cart_footer() MiniCartFooterBlock::render experimental iapi mini cart footer code WC 10.7.0
<?php
protected function render_experimental_iapi_mini_cart_footer( $attributes, $content, $block ) {
ob_start();
$cart = $this->get_cart_instance();
$subtotal_label = __( 'Subtotal', 'woocommerce' );
$other_costs_label = $this->get_totals_item_description();
$display_cart_price_including_tax = get_option( 'woocommerce_tax_display_cart' ) === 'incl';
$subtotal = $display_cart_price_including_tax ? $cart->get_subtotal_tax() : $cart->get_subtotal();
$formatted_subtotal = '';
$html = new \WP_HTML_Tag_Processor( wc_price( $subtotal ) );
$wrapper_attributes = get_block_wrapper_attributes(
array(
'data-wp-interactive' => 'woocommerce/mini-cart-footer-block',
'class' => 'wc-block-mini-cart__footer',
)
);
if ( $html->next_tag( 'bdi' ) ) {
while ( $html->next_token() ) {
if ( '#text' === $html->get_token_name() ) {
$formatted_subtotal .= $html->get_modifiable_text();
}
}
}
wp_interactivity_state(
$this->get_full_block_name(),
array(
'formattedSubtotal' => $formatted_subtotal,
)
);
?>
<div <?php echo $wrapper_attributes; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
<div class="wc-block-components-totals-item wc-block-mini-cart__footer-subtotal">
<span class="wc-block-components-totals-item__label">
<?php echo esc_html( $subtotal_label ); ?>
</span>
<span data-wp-text="woocommerce/mini-cart::state.formattedSubtotal" class="wc-block-formatted-money-amount wc-block-components-formatted-money-amount wc-block-components-totals-item__value">
</span>
<div class="wc-block-components-totals-item__description">
<?php echo esc_html( $other_costs_label ); ?>
</div>
</div>
<div class="wc-block-mini-cart__footer-actions">
<?php
if ( empty( $content ) ) {
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo do_blocks( '<!-- wp:woocommerce/mini-cart-cart-button-block /--><!-- wp:woocommerce/mini-cart-checkout-button-block /-->' );
} else {
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo $content;
}
?>
</div>
</div>
<?php
return ob_get_clean();
}