iCartIcon'] ) { $icon = ''; } } $button_html = $this->get_cart_price_markup( $attributes ) . ' ' . $icon . ' '; if ( is_cart() || is_checkout() ) { if ( $this->should_not_render_mini_cart( $attributes ) ) { return ''; } // It is not necessary to load the Mini-Cart Block on Cart and Checkout page. return '
'; } $template_part_contents = ''; // Determine if we need to load the template part from the DB, the theme or WooCommerce in that order. $templates_from_db = BlockTemplateUtils::get_block_templates_from_db( array( 'mini-cart' ), 'wp_template_part' ); if ( is_countable( $templates_from_db ) && count( $templates_from_db ) > 0 ) { $template_slug_to_load = $templates_from_db[0]->theme; } else { $theme_has_mini_cart = BlockTemplateUtils::theme_has_template_part( 'mini-cart' ); $template_slug_to_load = $theme_has_mini_cart ? get_stylesheet() : BlockTemplateUtils::PLUGIN_SLUG; } $template_part = get_block_template( $template_slug_to_load . '//mini-cart', 'wp_template_part' ); if ( $template_part && ! empty( $template_part->content ) ) { $template_part_contents = do_blocks( $template_part->content ); } if ( '' === $template_part_contents ) { $template_part_contents = do_blocks( // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents file_get_contents( Package::get_path() . 'templates/' . BlockTemplateUtils::DIRECTORY_NAMES['TEMPLATE_PARTS'] . '/mini-cart.html' ) ); } return '' . __( 'Your cart is currently empty!', 'woocommerce' ) . '
', ) ); } /** * Returns whether the Mini-Cart should be rendered or not. * * @param array $attributes Block attributes. * * @return bool */ public function should_not_render_mini_cart( array $attributes ) { return isset( $attributes['cartAndCheckoutRenderStyle'] ) && 'hidden' !== $attributes['cartAndCheckoutRenderStyle']; } }