Reputation: 2735
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.
Upvotes: 0
Views: 600
Reputation: 473
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;
}
Upvotes: 0
Reputation: 26309
Two big points here.
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.
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' );
Upvotes: 1