在店面中更改标题购物车文本 [英] Changing header cart text in Storefront

查看:184
本文介绍了在店面中更改标题购物车文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I would like to edit the text in the header mini cart in Storefront theme: 'X items' to just : 'X' http://demo.woothemes.com/storefront/

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

Where can I access this? Can't find it anywhere in storefront or woocommerce files. I can see hook in header.php: storefront_header_cart but can't find any function for this in other files?

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

I would like to remove the dropdown when you hover over it too. Where can I change this?

推荐答案

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

that functionality is handled by storefront_cart_link function...

您可以覆盖该功能...打开functions.php ...查找require get_template_directory() . '/inc/init.php';

you can override the function... open functions.php... look for require get_template_directory() . '/inc/init.php';

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

right above it, paste this code...

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';的调用来创建该函数.

storefront_cart_link is loaded with this call require get_template_directory() . '/inc/init.php';. So above will load first, making it not create that function anymore with the call of require get_template_directory() . '/inc/init.php';.

这可以解决问题..但是更好地使用子主题...您可以直接将上面的函数粘贴到子主题的functions.php上.子主题上的functions.php将比父主题首先加载,因此使您的函数首先存在.

This will do the trick.. but better use child theme... you can just paste directly the function above on the child theme's functions.php. functions.php on a child theme will load first than that of the parent, so making your function exist first.

这篇关于在店面中更改标题购物车文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆