最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin1浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论