php - Hiding price in whole Woocommerce store (including cart and checkout pages) - Stack Overflow

I need to hide prices throughout a whole woocommerce store but keep the 'add to cart' button

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 badges
Add a comment  | 

1 Answer 1

Reset to default 2

To 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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744678775a4587487.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信