简体   繁体   中英

How can i hide basic price in product details page - woocommerce plugin?

i have tried many way but can not figure out. I want to hide basic price (top price) of product details page and want to replace with bottom price (total price). Something like THIS . Could anyone tell me how i do that? is there any hook in woocommerce for do this?

I have tried with this hook:

remove_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price',10);

But it does't work. Thanks me advance.

Two big points here.

  1. Your code is referencing the shop loop, while your screen shot is the single product page. Since your code is targeting the wrong page, you aren't likely to see any change.

  2. remove_action() always needs to be called from inside a function and not directly from your theme's functions.php . See the codex .

So, taking those points into consideration, something like the following ought to remove the price from the single product page.

function so_46304892_remove_price() {
    remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
}
add_action( 'woocommerce_before_single_product', 'so_46304892_remove_price' );

You can use this hook woocommerce_get_price_html and check whether it is a single product page or not For eg.

add_filter('woocommerce_get_price_html','your_func_name',10,2);
function your_func_name($price, $product_data) {
  if(is_product()) {

       $price = '';
  }
  return $price;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM