Home Forums WoodMart support forum Remove price from out of stock products

Remove price from out of stock products

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #515819

    av_admin_1984
    Participant

    Hi

    1-Is it possible to remove the price from products that have the status “out of stock”?

    2-what is this option?
    https://prnt.sc/XfA9jeBLvMBl

    #515989

    Hello,

    01. Try to add the following php code in function.php of the child theme.

    add_filter( 'woocommerce_get_price_html', 'pk_hide_price_if_out_stock_frontend', 9999, 2 );
     
    function pk_hide_price_if_out_stock_frontend( $price, $product ) {
       if ( is_admin() ) return $price; // BAIL IF BACKEND
       if ( ! $product->is_in_stock() ) {
          $price = apply_filters( 'woocommerce_empty_price_html', '', $product );
       }
       return $price;
    }

    02 Can you please tell me the exact path or send the complete url

    Best Regards.

    #516004

    av_admin_1984
    Participant

    Hi

    1-Thanks for the code, I have it already, it has problem with another code for changing the order of sale_price and promotion_price

    2-Theme settings > Shop > Product labels > Out of stock

    #516182

    Hello,

    1. I have tested this code on our test site and it is working fine. Can you please remove the previous code and check how it works?

    2. Can you please share the WP login details i will check and give you a possible solution.

    Best Regards.

    #516227

    av_admin_1984
    Participant

    Hello
    These are login details, But I don’t know why you asking,
    my question is: what is this option?
    https://prnt.sc/XfA9jeBLvMBl

    also in other tickets, I sent these login info to your colleges

    #516378

    Hello,

    This is a sold counter element:
    https://woodmart.xtemos.com/theme-settings-tooltips/sold_counter_enabled.mp4

    If you enable the option :Hide for out of stock products” it will hide the sold counter on out of stock products.

    Best Regards.

    #534745

    av_admin_1984
    Participant

    Hello

    I used this code

    add_filter( 'woocommerce_get_price_html', 'pk_hide_price_if_out_stock_frontend', 9999, 2 );
     
    function pk_hide_price_if_out_stock_frontend( $price, $product ) {
       if ( is_admin() ) return $price; // BAIL IF BACKEND
       if ( ! $product->is_in_stock() ) {
          $price = apply_filters( 'woocommerce_empty_price_html', '', $product );
       }
       return $price;
    }

    1- and now I realize that if our product has 2 prices, Regular price and Sale price, this does not work
    see the image I attached

    2- In the search bar of woodmart it shows the price of that product was out of stock with zero, instead of showing out of stock
    and if that product contains 2 prices (Regular price and Sale price), it shows all the prices of the product and it affects bad experiences for every customer

    When a product is out of stock, why should has a price and show it in front-end?

    Attachments:
    You must be logged in to view attached files.
    #535020

    Hello,

    Please refer to the Woocommerce community on this issue as our support does not cover the Woocommerce customization.

    Best Regards

    #535904

    av_admin_1984
    Participant

    Hi
    I asked in woo community and they give me this code

    
    add_filter( 'woocommerce_get_price_html', 'woodmart_hide_price_if_out_stock_frontend', 9999, 2 );
     
    function woodmart_hide_price_if_out_stock_frontend( $price, $product ) {
       if ( is_admin() ) return $price; // BAIL IF BACKEND
       if ( ! $product->is_in_stock() ) {
          $price = apply_filters( 'woocommerce_empty_price_html', '', $product );
       }
       return $price;
    }
    
    add_filter( 'woocommerce_sale_flash', 'woodmart_no_sale_badge_if_out_of_stock', 9999, 3 );
    function woodmart_no_sale_badge_if_out_of_stock( $html, $post, $product ) {
       if ( ! $product->is_in_stock()) return;
       return $html;
    }

    these code removed the percent in storefront theme but wont work in your theme

    #536157

    Hello,

    Are you talking about sales labels in percentage? If yes, Navigate to Theme Settings > Shop > Products labels > disable the option “Sale” label in percentage.

    Best Regards.

    #536181

    av_admin_1984
    Participant

    Hello

    Yes I’m talking about that.

    1- with that code, I could remove sales badge if product is out of stock
    2- I need the Percentage badge to show, and if I disabled like what you told me, It will remove for all products
    3-with disabling that from theme settings, still show the seal badge in product that was out of stock!

    • This reply was modified 4 months, 3 weeks ago by av_admin_1984.
    Attachments:
    You must be logged in to view attached files.
    #536397

    Hello,

    Unfortunately, it is not possible. Such modification requires complicated Woocommerce code customization which is not covered by our support.

    Best Regards.

    #536623

    av_admin_1984
    Participant

    Please close this, I start a new topic

    #536686

    Most Welcome!!!.

    I’m so happy to hear you are pleased with the Theme and Support. XTEMOS strives to deliver the best customer experience, and it makes our day to hear we have accomplished that.

    We count ourselves lucky to have you as a customer. You can always reach us at any time. We are always here to help you.

    Thanks for contacting us.
    Have a great day.

    Topic Closed.
    Best Regards.

Viewing 14 posts - 1 through 14 (of 14 total)

The topic ‘Remove price from out of stock products’ is closed to new replies.