Home › Forums › WoodMart support forum › Remove price from out of stock products
Remove price from out of stock products
- This topic has 13 replies, 2 voices, and was last updated 1 year ago by
Aizaz Imtiaz Awan.
-
AuthorPosts
-
November 27, 2023 at 12:07 pm #515819
av_admin_1984ParticipantHi
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/XfA9jeBLvMBlNovember 27, 2023 at 5:09 pm #515989
Aizaz Imtiaz AwanKeymasterHello,
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.
November 27, 2023 at 5:21 pm #516004
av_admin_1984ParticipantHi
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
November 28, 2023 at 10:18 am #516182
Aizaz Imtiaz AwanKeymasterHello,
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.
November 28, 2023 at 11:07 am #516227
av_admin_1984ParticipantHello
These are login details, But I don’t know why you asking,
my question is: what is this option?
https://prnt.sc/XfA9jeBLvMBlalso in other tickets, I sent these login info to your colleges
November 28, 2023 at 3:49 pm #516378
Aizaz Imtiaz AwanKeymasterHello,
This is a sold counter element:
https://woodmart.xtemos.com/theme-settings-tooltips/sold_counter_enabled.mp4If you enable the option :Hide for out of stock products” it will hide the sold counter on out of stock products.
Best Regards.
January 29, 2024 at 11:46 pm #534745
av_admin_1984ParticipantHello
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 attached2- 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 customerWhen 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.January 30, 2024 at 2:57 pm #535020
Aizaz Imtiaz AwanKeymasterHello,
Please refer to the Woocommerce community on this issue as our support does not cover the Woocommerce customization.
Best Regards
February 1, 2024 at 5:03 pm #535904
av_admin_1984ParticipantHi
I asked in woo community and they give me this codeadd_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
February 2, 2024 at 12:34 pm #536157
Aizaz Imtiaz AwanKeymasterHello,
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.
February 2, 2024 at 1:06 pm #536181
av_admin_1984ParticipantHello
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 1 year, 1 month ago by
av_admin_1984.
Attachments:
You must be logged in to view attached files.February 3, 2024 at 9:52 am #536397
Aizaz Imtiaz AwanKeymasterHello,
Unfortunately, it is not possible. Such modification requires complicated Woocommerce code customization which is not covered by our support.
Best Regards.
February 4, 2024 at 7:52 pm #536623
av_admin_1984ParticipantPlease close this, I start a new topic
February 5, 2024 at 9:44 am #536686
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. -
This reply was modified 1 year, 1 month ago by
-
AuthorPosts
- You must be logged in to create new topics. Login / Register