如何更改店面woocommerce中的柜台购物车?
问题描述:
我想改变计数器手推车,使其显示0为空并删除单词“item”。我在插件woocommerce 3.2.0中使用店面2.2.5模板。哪些文件负责此代码?它可能需要改变jQuery的东西如何更改店面woocommerce中的柜台购物车?
答
这是这样做的功能。文件storefront/inc/woocommerce/storefront-woocommerce-template-functions.php
if (! function_exists('storefront_cart_link')) {
/**
* Cart Link
* Displayed a link to the cart including the number of items present and the cart total
*
* @return void
* @since 1.0.0
*/
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'); ?>">
<span class="amount"><?php echo wp_kses_data(WC()->cart->get_cart_subtotal()); ?></span> <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
}
}
你需要在你的子主题的functions.php
文件来定义功能,或在plugin
。
希望这会有所帮助。
这不是我的问题的解决方案。我想改变现有的购物车,但我用jQuery不够好。我找不到负责显示计数和“项目”的部分代码。 –
你也可以破解翻译条目。但这不是一个真正的解决方案。 我认为如果你在你的'functions.php'中定义了'storefront_cart_link'来满足你的需要,这将使得它作为woocommerce做ajax调用并插入返回的html。 这是PHP写的,我认为它是在PHP应该做的。 请分享更多的信息,所以我可以建议更好。 – JBoulhous
我认为我让自己变得聪明。如果购物车是空的。我希望显示“0”而不用单词“item”。如果有一个项目,例如,一个项目。我希望显示“1”而不用“item” –