0
我想改變計數器手推車,使其顯示0爲空並刪除單詞「item」。我在插件woocommerce 3.2.0中使用店面2.2.5模板。哪些文件負責此代碼?它可能需要改變jQuery的東西如何更改店面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」 –