Tagged: Product page
-
AuthorPosts
-
June 15, 2017 at 10:01 pm #808715
Quite often products in our industry go obsolete and we can no longer sell them. Rather than delete the products we refer customers to recommended upgrades from obsolete products. On our previous theme we replaced the default Woocommerce FREE! text with “This product is obsolete. Call for recommended alternative.” Woocommerce would automatically replace any item with a blank price to FREE!
For some reason, Enfold puts $0.00 on any items that have a blank price. This has caused our code to stop working. This is the function we used to use:
add_filter('woocommerce_empty_price_html', 'custom_call_for_price'); function custom_call_for_price() { return 'Obsolete. Please Contact Us For Recommended Upgrades'; }
Is there any way to apply this same function to Enfold? The above code would work on both Archive pages and on Product Pages. It appears Enfold overwrote the default Woocommerce behavior for woocommerce_empty_price_html that caused this function to stop working.
Thank you!
June 16, 2017 at 9:04 am #808874Hey pcmichiana,
You can add this custom PHP code at the functions.php using a child theme following this article: kriesi.at/documentation/enfold/using-a-child-theme/
Best regards,
John TorvikJune 16, 2017 at 5:11 pm #809007John
I already added that code (along with many other customizations) to the child theme functions.php file and this specific filter does not work, all the other code customizations in functions.php transferred from our old theme are working great.
I’m not sure what Enfold does differently for displaying blank pricing but it seems to overwrite the woocommerce_empty_price_html function so this filter does not work.
Why does Enfold display $0.00 when the price field is blank? The default woocommerce behavior for this is to display the text “FREE!”
Any other suggestions would be extremely helpful.
- This reply was modified 7 years, 6 months ago by pcmichiana.
June 16, 2017 at 5:17 pm #809011Additional Notes:
Here is the hook reference for woocommerce_empty_price_html: https://docs.woocommerce.com/wc-apidocs/source-class-WC_Product.html#1642/** * Returns the price in html format. * @return string */ public function get_price_html( $deprecated = '' ) { if ( '' === $this->get_price() ) { return apply_filters( 'woocommerce_empty_price_html', '', $this ); } if ( $this->is_on_sale() ) { $price = wc_format_sale_price( wc_get_price_to_display( $this, array( 'price' => $this->get_regular_price() ) ), wc_get_price_to_display( $this ) ) . $this->get_price_suffix(); } else { $price = wc_price( wc_get_price_to_display( $this ) ) . $this->get_price_suffix(); } return apply_filters( 'woocommerce_get_price_html', $price, $this ); }
June 19, 2017 at 3:55 pm #809842No advice on this? It’s important that we redirect our customers to alternative products rather than display a $0.00 price.
Please let me know!
Thank you!
June 19, 2017 at 9:55 pm #809997Hi,
Unfortunately it would require quite some time and customization of the theme to achieve this, so I am sorry to tell you that this is not covered by our support. However if its really important for you to get this done, you can always hire a freelancer to do the job for you :)
Best regards,
BasilisJune 22, 2017 at 3:52 pm #811623Found out the source of the problem… well… kind of.
Apparently when I switched over my theme it didn’t fully register the blank dollar amounts as blank dollar amounts. So setting all of my blank dollar amounts to 1 dollar and then back to blank and saving them fixed the issue. Not sure why it thought they were all zero dollars when they were blank but this must’ve been a database issue.
Thank you for your feedback on this.
June 22, 2017 at 7:27 pm #811777Hi pcmichiana,
Glad you got it working for you! :)
If you need further assistance please let us know.
Best regards,
Victoria -
AuthorPosts
- You must be logged in to reply to this topic.