Home Forums WoodMart support forum Remove price and sale label from “out of stock” products

Remove price and sale label from “out of stock” products

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #536621

    av_admin_1984
    Participant

    Hello

    I asked my question here https://xtemos.com/forums/topic/remove-price-from-out-of-stock-products/
    and got some answers but there are other questions that remain and need you to update the theme or give me the snippet to solve this.

    1- How to remove the “out-of-stock” product price? and you give me this code and it works correctly

    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;
    }

    2- See this video
    https://drive.google.com/file/d/1wWkXroM2g_4RKdCYIIS3_G5-UUxyco-E/view?usp=sharing

    In this video I captured, comparing woodmart vs storefront theme,
    some basic code works fine in storefront but it won’t in woodmart, and Aizaz Imtiaz Awan told me :

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

    *For products that have 2 prices (Regular price and Sale price) I could remove the sale label in the storefront theme but that code does not work in woodmart

    add_filter( 'woocommerce_sale_flash', 'bbloomer_no_sale_badge_if_out_of_stock', 9999, 3 );
    function bbloomer_no_sale_badge_if_out_of_stock( $html, $post, $product ) {
       if ( ! $product->is_in_stock()) return;
       return $html;
    }

    * Why out-of-stock product that was removed the prices with that snippet, it shows the price in front-end search bar?

    If you did not customize the woocommerce files in your theme, tell me why that code runs in a default woocommerce /wordpress theme but won’t work in your theme?

    • This topic was modified 4 months, 2 weeks ago by av_admin_1984.
    #537290

    av_admin_1984
    Participant

    Hello

    Can you here me?
    Is there any body here?

    #537550

    Hello,

    In our theme product labels are made differently than in default themes and located in different places, so the same code may not work the same in both themes.

    To hide the price in out-of-stock products he needs to use the following 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() && ! is_ajax() ) return $price; // BAIL IF BACKEND
    		if ( ! $product->is_in_stock() ) {
    			$price = apply_filters( 'woocommerce_empty_price_html', '', $product );
    		}
    		return $price;
    	}

    To hide sale label in out of stock products he need to add following css to global custom css area in theme settings

    .main-page-wrapper .product-labels:has(.out-of-stock) .onsale {
    	display: none;
    }

    Best Regards.

    #537569

    av_admin_1984
    Participant

    Hello
    It solved the search items, product labels in grid and single product labels
    Thanks, this is working now

    #537633

    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 5 posts - 1 through 5 (of 5 total)

The topic ‘Remove price and sale label from “out of stock” products’ is closed to new replies.