更改店面中的 header 购物车文本

Changing header cart text in Storefront

我想在 Storefront 主题中编辑 header 迷你购物车中的文本: 'X items' 只是: 'X' http://demo.woothemes.com/storefront/

我在哪里可以访问它?在店面或 woocommerce 文件中的任何地方都找不到它。我可以在 header.php 中看到挂钩: storefront_header_cart 但在其他文件中找不到任何功能?

当您将鼠标悬停在下拉菜单上时,我也想删除它。我在哪里可以更改它?

该功能由 storefront_cart_link 函数处理...

你可以覆盖函数...打开functions.php...寻找require get_template_directory() . '/inc/init.php';

在其上方,粘贴此代码...

if ( ! function_exists( 'storefront_cart_link' ) ) {
    function storefront_cart_link() {
        ?>
            <a class="cart-contents" href="<?php echo esc_url( WC()->cart->get_cart_url() ); ?>" title="<?php _e( 'View your shopping cart', 'storefront' ); ?>">
                <?php echo wp_kses_data( WC()->cart->get_cart_subtotal() ); ?> <span class="count"><?php echo wp_kses_data( sprintf( '%d', WC()->cart->get_cart_contents_count() ) );?></span>
            </a>
        <?php
    }
}

storefront_cart_link 已加载此调用 require get_template_directory() . '/inc/init.php';。所以上面将首先加载,使其不再通过调用 require get_template_directory() . '/inc/init.php';.

创建该函数

这样就可以了。但是最好使用子主题...您可以直接将上面的函数粘贴到子主题的 functions.php 上。 functions.php 子主题将比父主题先加载,因此请先使您的功能存在。