Я пытаюсь урезать несколько вещей для пользовательской темы WooCommerce как дочерний элемент Storefront.Я начал с замены функции storefront_header_cart
, чтобы удалить полный список корзины, который работал как ожидалось:
if ( ! function_exists( 'storefront_header_cart' ) ) {
function storefront_header_cart() {
if ( storefront_is_woocommerce_activated() ) {
if ( is_cart() ) {
$class = 'current-menu-item';
} else {
$class = '';
}
?>
<ul id="site-header-cart" class="site-header-cart menu">
<li class="<?php echo esc_attr( $class ); ?>">
<?php storefront_cart_link(); ?>
</li>
</ul>
<?php
}
}
}
Затем я захотел изменить текст в самой ссылке на содержимое.Я сделал то же самое, чтобы переопределить поведение витрины по умолчанию ...
if ( ! function_exists( 'storefront_cart_link' ) ) {
function storefront_cart_link() {
?>
<a class="cart-contents" href="<?php echo esc_url( wc_get_cart_url() ); ?>" title="<?php esc_attr_e( 'View your shopping cart', 'storefront' ); ?>">
<?php /* translators: %d: number of items in cart */ ?>
<span class="count"><?php echo wp_kses_data( sprintf( _n( '%d item', '%d items', WC()->cart->get_cart_contents_count(), 'storefront' ), WC()->cart->get_cart_contents_count() ) ); ?></span>
</a>
<?php
}
}
... но это ничего не делает.Отображается полная оригинальная ссылка:
<a class="cart-contents" href="http://localhost/cart/" title="View your shopping cart">
<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">$</span>0.00</span> <span class="count">0 items</span>
</a>
Почему неконгруэнтное поведение?
- WordPress: 5.1.1
- WooCommerce: 3.5.6
- Витрина магазина: 2.4.5