• Resolved kikib

    (@kikib)


    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)
  • Plugin Support Gabriel – a11n

    (@gabrielfuentes)

    Hi there ??

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Cheers.

    Thread Starter kikib

    (@kikib)

    Hi I have a question.

    Normally, it display just the price, no text, correct?

    I’m working in Woocommerce that’s already set up in Elementor by someone. However, I don’t see it in the functions.php that they added the text before the price. And I can see that when I drag the Product Price box and dropped it in the page in the elementor editor, that the text was already added. However, I don’t see any text to edit in the Product Price settings. Are there any woocommerce settings or plugins I’m not aware of.

    Thread Starter kikib

    (@kikib)

    I got my code working. Thanks!

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.