我使用的是WordPress 4.3.1、Woocommerce 2.4.7和主题店面1.5.1。
我想更改标题中的“站点标题-购物车”,它显示购物车的当前价格和购物车中物品的数量,只显示商品的数量:
<span class="amount">463,33 €</span>
<span class="count">7 items</span>应:
<span class="count">7</span>每当我对template-tags.php进行更改时,只会在
<a class="cart-contents" ...>
...
</a>正在被展示。每当我试图更改href中的某些内容时,不变的原始内容就会出现:
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' ); ?>">
<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
}
}怎么了,有人能帮我吗?
发布于 2016-10-18 07:36:37
我也有过同样的问题。事实上,您必须在购物车上进行操作,例如添加一个项或空购物车,以使您的更改可见。另一个选项是像Loque描述的那样清除sessionStorage。
1.向自定义functions.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' ); ?>">
<span class="count"><?php echo WC()->cart->get_cart_contents_count();?></span>
</a>
<?php
}
}2.对购物车执行操作或清除控制台中的sessionStorage:
sessionStorage.removeItem('wc_fragments')3.刷新浏览器->非常重要的
在此之前:
<span class="count">1 items</span>之后:
<span class="count">1</span>https://stackoverflow.com/questions/33349417
复制相似问题