'How do I remove the price and price range from a single product page but allow it to show on /product-category pages?
First thing first, thanks for looking at this and I appreciate your time. I have some experience in this but not a lot, but I have been looking for answers online with no luck.
I am working on a WooCommerce store and I am using the Ultimate Products Add-Ons plugin which displays a total price just above the "Add to Cart" button that will show all optional product add-ons giving a total price (before taxes). So with this being the only way to show a price before adding it to the cart, I need to remove a couple of things off of the Single Product Page, those being the price range and the standard price that typically shows on a single product page. I need to do this without removing the price from the Shop or /product-category pages. I played around with some of the settings in Theme Options > WooCommerce and I can get them removed from the Single Product page but it also removes it from the /product-category pages too.
Looking into this, it appears that the price range is the bit of info that shows up on both the /product-category page and single product page, so I need to find a way to target the single product page specifically. I have found the following:
add_filter('woocommerce_get_price_html', 'lw_hide_variation_price', 10, 2);
function lw_hide_variation_price( $v_price, $v_product ) {
$v_product_types = array( 'variable');
if ( in_array ( $v_product->product_type, $v_product_types ) && !(is_shop()) ) {
return '';
}
// return regular price
return $v_price;
}
This will remove the product range from the single product page and the /product-category page. I don't quite understand what I am looking at, but I have messed around with it and didn't really help.
Does anyone have any idea how I can achieve what I am looking to do? Thanks in advance!!!
EDIT: I tried to use the code found on WooCommerce: cannot remove the price from a single product page through functions.php and it did help in removing the top price point that was immediately below the product name, although I am still looking to remove the middle price point that remains (see picture).
Code Used on above page:
add_action('woocommerce_single_product_summary', 'customizing_single_product_summary_hooks', 2 );
function customizing_single_product_summary_hooks(){
remove_action('woocommerce_single_product_summary','woocommerce_template_single_price',10 );
}
So for now I am looking for either a single section of code to replace what I referenced above OR a second line of code that would allow me to just remove the price on the single product page only.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
