18.1846C19.1385 19.1872 18.3257 20 17.3231 20C16.3205 20 15.5077 19.1872 15.5077 18.1846Z" fill="currentColor"/> '; $button_html = '' . esc_html( wp_strip_all_tags( wc_price( $cart_contents_total ) ) ) . ' ' . $this->get_include_tax_label_markup() . ' ' . $icon . ' ' . $cart_contents_count . ' '; if ( is_cart() || is_checkout() ) { // 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 theme, or WooCommerce in that order. $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 = BlockTemplateUtils::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 '
'; } /** * Return an instace of the CartController class. * * @return CartController CartController class instance. */ protected function get_cart_controller() { return new CartController(); } /** * Get array with data for handle the tax label. * the entire logic of this function is was taken from: * https://github.com/woocommerce/woocommerce/blob/e730f7463c25b50258e97bf56e31e9d7d3bc7ae7/includes/class-wc-cart.php#L1582 * * @return array; */ protected function get_tax_label() { $cart = WC()->cart; if ( $cart->display_prices_including_tax() ) { if ( ! wc_prices_include_tax() ) { $tax_label = WC()->countries->inc_tax_or_vat(); $display_cart_prices_including_tax = true; return array( 'tax_label' => $tax_label, 'display_cart_prices_including_tax' => $display_cart_prices_including_tax, ); } return array( 'label_including_tax' => '', 'display_cart_prices_including_tax' => true, ); } if ( wc_prices_include_tax() ) { $tax_label = WC()->countries->ex_tax_or_vat(); return array( 'tax_label' => $tax_label, 'display_cart_prices_including_tax' => false, ); }; return array( 'tax_label' => '', 'display_cart_prices_including_tax' => false, ); } /** * Get Cart Payload. * * @return object; */ protected function get_cart_payload() { return WC()->api->get_endpoint_data( '/wc/store/cart' ); } /** * Prepare translations for inner blocks and dependencies. */ protected function get_inner_blocks_translations() { $wp_scripts = wp_scripts(); $translations = array(); $blocks = [ 'mini-cart-contents-block/filled-cart', 'mini-cart-contents-block/empty-cart', 'mini-cart-contents-block/title', 'mini-cart-contents-block/items', 'mini-cart-contents-block/products-table', 'mini-cart-contents-block/footer', 'mini-cart-contents-block/shopping-button', ]; $chunks = preg_filter( '/$/', '-frontend', $blocks ); foreach ( $chunks as $chunk ) { $handle = 'wc-blocks-' . $chunk . '-chunk'; $this->asset_api->register_script( $handle, $this->asset_api->get_block_asset_build_path( $chunk ), [], true ); $translations[] = $wp_scripts->print_translations( $handle, false ); wp_deregister_script( $handle ); } $translations = array_filter( $translations ); return implode( '', $translations ); } /** * Register block pattern for Empty Cart Message to make it translatable. */ public function register_empty_cart_message_block_pattern() { register_block_pattern( 'woocommerce/mini-cart-empty-cart-message', array( 'title' => __( 'Mini Cart Empty Cart Message', 'woocommerce' ), 'inserter' => false, 'content' => '

' . __( 'Your cart is currently empty!', 'woocommerce' ) . '

', ) ); } }