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
- This topic has 4 replies, 2 voices, and was last updated 7 months, 3 weeks ago by Aizaz Imtiaz Awan.
-
AuthorPosts
-
February 4, 2024 at 7:50 pm #536621
av_admin_1984ParticipantHello
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=sharingIn 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 7 months, 3 weeks ago by av_admin_1984.
February 6, 2024 at 4:29 pm #537290
av_admin_1984ParticipantHello
Can you here me?
Is there any body here?February 7, 2024 at 11:55 am #537550
Aizaz Imtiaz AwanKeymasterHello,
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.
February 7, 2024 at 12:30 pm #537569
av_admin_1984ParticipantHello
It solved the search items, product labels in grid and single product labels
Thanks, this is working nowFebruary 7, 2024 at 1:52 pm #537633
Aizaz Imtiaz AwanKeymasterMost 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. -
AuthorPosts
- You must be logged in to create new topics. Login / Register