admin管理员组文章数量:1391964
I need to hide prices throughout a whole woocommerce store but keep the 'add to cart' button and checkout functionality operational (the store is set to complete the order without an online payment, to request a quote for the items in the order). I'm using two lines of code to hide the prices in all shop and category pages as well as the single product pages but I can't manage to hide it in the cart and checkout pages.
Here's my code:
add_filter( 'woocommerce_is_purchasable', '__return_true' );
add_filter( 'woocommerce_get_price_html', '__return_empty_string' );
What can I add to hide the prices in the checkout and cart pages?
I need to hide prices throughout a whole woocommerce store but keep the 'add to cart' button and checkout functionality operational (the store is set to complete the order without an online payment, to request a quote for the items in the order). I'm using two lines of code to hide the prices in all shop and category pages as well as the single product pages but I can't manage to hide it in the cart and checkout pages.
Here's my code:
add_filter( 'woocommerce_is_purchasable', '__return_true' );
add_filter( 'woocommerce_get_price_html', '__return_empty_string' );
What can I add to hide the prices in the checkout and cart pages?
Share Improve this question asked Mar 14 at 0:20 ÑakoÑako 774 bronze badges1 Answer
Reset to default 2To hide the prices in Cart and Checkout page, you will need to add multiple filters, as prices are displayed in various parts of the store, each having its own filter or hook.
Here is a list of all WooCommerce Action & Filter Hooks.
So by using your apprach, you can effectivly hide these elements, by returning an empty string/array:
/* Hooks to hide prices in cart and checkout pages */
/* Hides the prices by returning an emtpy string/array */
// Hide the price of individual items in the cart
add_filter( 'woocommerce_cart_item_price', '__return_empty_string' );
// Hide the subtotal of individual items in the cart
add_filter( 'woocommerce_cart_item_subtotal', '__return_empty_string' );
// Hide the subtotal of all items in the cart
add_filter( 'woocommerce_cart_subtotal', '__return_empty_string' );
// Hide the total price of all items in the cart
add_filter( 'woocommerce_cart_total', '__return_empty_string' );
// Hide tax in the cart and checkout pages
add_filter( 'woocommerce_cart_tax_totals', '__return_empty_array' );
However, you should be aware of that this will not hide the prices from the customer order emails.
本文标签: phpHiding price in whole Woocommerce store (including cart and checkout pages)Stack Overflow
版权声明:本文标题:php - Hiding price in whole Woocommerce store (including cart and checkout pages) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744678775a2619270.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论