How to add a class to price p tag woocommerce?
-
Before I added the filter in the function to hide the price if a product is out of stock, the code looks like this:
<p class="price">Price: <span class="woocommerce-Price-amount amount"><bdi>...</bdi></span></p>
After the filter was added, the code now looks like this:
<p class="price">Price:</p>
What do I need to do to remove the p tag or add another class so I can set it to display: none?
Here’s my filter code to hide the price
/** Hide Price When Out of Stock */ add_filter( 'woocommerce_variable_sale_price_html', 'mb_remove_prices', 10, 2 ); add_filter( 'woocommerce_variable_price_html', 'mb_remove_prices', 10, 2 ); add_filter( 'woocommerce_get_price_html', 'mb_remove_prices', 10, 2 ); function mb_remove_prices( $price, $product ) { if ( ! $product->is_in_stock()) { $price = ''; } return $price; }
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘How to add a class to price p tag woocommerce?’ is closed to new replies.