This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101
Related content
WooCommerce: Disable Variable Product Price Range $$$-$$$ You may want to disable the WooCommerce variable product price range which usually looks like $100-$999 when variations have different prices (min $100 and max $999 in this case). With this snippet you will be able to hide the highest price, and add a “From: ” prefix in front of the minimum price. At the […]
WooCommerce: Hide Price & Add to Cart for Logged Out Users You may want to force users to login in order to see prices and add products to cart. That means you must hide add to cart buttons and prices on the Shop and Single Product pages when a user is logged out. All you need is pasting the following code in your functions.php (please note: […]
WooCommerce: How to Fix the “Cart is Empty” Issue For some reason, sometimes you add products to cart but the cart page stays empty (even if you can clearly see the cart widget has products in it for example). But don’t worry – it may just be a simple cache issue (and if you don’t know what cache is that’s no problem either) or […]
WooCommerce: Remaining $$$ to Get Free Shipping Notification @ Cart This is a very cool snippet that many of you should use to increase your average order value. Ecommerce customers who are near the “free shipping” threshold will try to add more products to the cart in order to qualify for free shipping. It’s pure psychology. So, here’s how we show a simple message on […]
WooCommerce: Cart and Checkout on the Same Page This is your ultimate guide – complete with shortcodes, snippets and workarounds – to completely skip the Cart page and have both cart table and checkout form on the same (Checkout) page. But first… why’d you want to do this? Well, if you sell high ticket products (i.e. on average, you sell no more than […]
Rodolfo Melogli
Business Bloomer Founder
Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli
46 thoughts on “WooCommerce: Display Regular & Sale Price @ Cart Table”
Hey Farshad, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Hi Fredrik, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
First of all, I really appreciate what you do! This really seems like something that should be built into Woocommerce. I’ve been using this snippet and it works great, but today I was sent an error about it from WordPress. Everything still looks fine but this is the error in case you have any idea what, if anything, I should do about it:
=============
An error of type E_ERROR was caused in line 20 of the file /home/treechic/httpdocs/wp-content/themes/storefront-treechic/functions.php. Error message: Uncaught Error: Call to a member function get_price_html() on null in /home/treechic/httpdocs/wp-content/themes/storefront-treechic/functions.php:20
Stack trace:
#0 /home/treechic/httpdocs/wp-includes/class-wp-hook.php(287): change_cart_table_price_display(‘
It works great, but I wonder how this can be done in the mini-cart? As far as I can see, the hook there is exactly the same as this one, but somehow it does not work.
Hi Santiago, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Thanks for this great blog post. I tried your code and it worked.
however, in the dropdown box of the cart from the head menu, the client now see two prices. ‘
The original and discount.
Maybe yes this snippet might need a tweak to make it compatible with the cart widget. I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
This snippet works only partially for me. While the initial price is now visible as intended it is displayed without being slashed. My only CSS affects color & weight. Do you have any idea of what could be wrong ?
Hey Thibault, thanks for your comment! Somewhere in your CSS there is probably a call that targets “del” (a slashed part) and hides the slash. Maybe 🙂 Unfortunately this is custom to your theme so I can’t help here. Thanks!
Hey Sitranet, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R
Hello Mathias, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R
Hey Allan, thanks for your comment! This snippet is only compatible with default WooCommerce – in your case you will need custom coding and I can’t help here via the comments 🙂
I’d like to display the sale price of a product before the regular (discount) price. I know this has something to do with get_price_html. By default, this outputs something like:
regular price
sale price
I want to change the output so it looks like this (basically, the two prices are shown in a different order):
Oh – I see 🙂 Yes, this is possible but unfortunately it is custom work and cannot give a complementary solution here on the blog. Hopefully I will have time to create a snippet soon 🙂 Thank you for your understanding!
Hey Andy, thanks so much for your comment and this is definitely not a stupid question! You can place this in your child theme’s functions.php file – if you need more guidance, please take a look at this video tutorial: https://businessbloomer.com/woocommerce-customization-hangout/
Hey Andrew – yes you can add it anywhere but I recommend to put it at the very bottom, before the closing line “?>” if it’s there. You don’t need to remove anything 🙂
If it’s the first time for you, make sure you have a backup of your functions.php and FTP access so you can fix things immediately if anything goes wrong.
Hello, how can you do this in the backend and in the emails that go out? Currently if the email goes out to our warehouse, they dont know if it has been discounted and only see £7.99 when the regular price is £9.99
Hey Daniel, thanks for your comment! Yes, I took a look at the WooCommerce files and indeed Emails and Thank you page have different filters than the Cart page. I’m afraid I cannot provide a complementary fix here on the blog but I recommend you take a look at the order-details-item.php file in the templates folder 🙂 Hope this helps!
Thanks for the support, do you find it strange that it reports the discounts across emails, 3rd party invoice software and the like when using the coupon system as standard, but doesn’t report this using the ‘sale discount’ system when selling one item?
Hey Drake, thanks for your feedback! So, to add a style to the price you’d need to “inspect element” or use “firebug” depending on what browser you need. Those prices should have a CSS class and you can then use that in your custom.CSS. If you don’t know the basics of CSS I strongly recommend to take a look at https://www.w3schools.com/css/ because CSS is a LOT of fun! Let me know 🙂
Questions? Feedback? Customization? Leave your comment now! _____
If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!
Hello , its work for me , thx bro.
how to display it in woocommerce/orders/customer order details page (in wp admin) ?
Hey Farshad, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
For checkout check this page, it helped me: https://wordpressdeveloperonline.com/showing-sale-prices-in-the-woocommerce-checkout
Cool
Is there a way to show regular price and sale price in the product/category pages also? Have been googling all day for that.
Hi Fredrik, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
First of all, I really appreciate what you do! This really seems like something that should be built into Woocommerce. I’ve been using this snippet and it works great, but today I was sent an error about it from WordPress. Everything still looks fine but this is the error in case you have any idea what, if anything, I should do about it:
=============
An error of type E_ERROR was caused in line 20 of the file /home/treechic/httpdocs/wp-content/themes/storefront-treechic/functions.php. Error message: Uncaught Error: Call to a member function get_price_html() on null in /home/treechic/httpdocs/wp-content/themes/storefront-treechic/functions.php:20
Stack trace:
#0 /home/treechic/httpdocs/wp-includes/class-wp-hook.php(287): change_cart_table_price_display(‘
Thanks Emily. Just tested and got no error. Maybe you could simply put a check (untested):
Hi Rodolfo,
It works great, but I wonder how this can be done in the mini-cart? As far as I can see, the hook there is exactly the same as this one, but somehow it does not work.
Any idea on why this might be? Thanks!
Hi Santiago, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Hi,
Old post … but this did not work for me at all. No change to the order review area. Perhaps newer version of WC is the issue.
Works perfectly for me Ryan – sorry 😐
Hi Rodolfo,
Thanks for this great blog post. I tried your code and it worked.
however, in the dropdown box of the cart from the head menu, the client now see two prices. ‘
The original and discount.
Shouldnt this dropdown box show the end price?
Maybe yes this snippet might need a tweak to make it compatible with the cart widget. I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Hi Rodolfo,
This snippet works only partially for me. While the initial price is now visible as intended it is displayed without being slashed. My only CSS affects color & weight. Do you have any idea of what could be wrong ?
Hey Thibault, thanks for your comment! Somewhere in your CSS there is probably a call that targets “del” (a slashed part) and hides the slash. Maybe 🙂 Unfortunately this is custom to your theme so I can’t help here. Thanks!
hi sir, i want to Underline the original price and lead price in woocommerce, can you help me?
Hey Sitranet, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R
Thanks you so much!
🙂
How do I add this to the checkout page also?
Hello Mathias, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R
How can I remove it from checkout page?
Hey Bulent, thanks for your comment! I suggest you take a look at “conditional logic”: https://businessbloomer.com/conditional-logic-woocommerce-tutorial/ and https://businessbloomer.com/woocommerce-conditional-logic-ultimate-php-guide/. Let me know 🙂
Awesome, just what I needed :), works perfectly.
Thanks Josh 🙂
This worked perfectly! Even on Woocommerce 3.0 Thanks Rodolfo!
Awesome, thank you Kodi!
Hi,
The code do not work on my site
It might due to dynamic pricing which discounted price on quantity discount.
Possible to show on 1 quantity product?
Thanks
Allan
Hey Allan, thanks for your comment! This snippet is only compatible with default WooCommerce – in your case you will need custom coding and I can’t help here via the comments 🙂
Hi Rodolfo,
I’d like to display the sale price of a product before the regular (discount) price. I know this has something to do with get_price_html. By default, this outputs something like:
regular pricesale price
I want to change the output so it looks like this (basically, the two prices are shown in a different order):
sale price
regular priceHow can I do this?
Thank you!
Hey Toggy thanks for your comment! Is this on the Cart page or on every page of the website?
Thanks for your quick response. I want on every page of the website.
Oh – I see 🙂 Yes, this is possible but unfortunately it is custom work and cannot give a complementary solution here on the blog. Hopefully I will have time to create a snippet soon 🙂 Thank you for your understanding!
Stupid question… but what file do I copy and paste these 10 lines into? Where in the file? Do I remove anything else out?
Hey Andy, thanks so much for your comment and this is definitely not a stupid question! You can place this in your child theme’s functions.php file – if you need more guidance, please take a look at this video tutorial: https://businessbloomer.com/woocommerce-customization-hangout/
Thanks for your quick response. Can I add it ANYWHERE in the file, and do I need to remove anything?
Hey Andrew – yes you can add it anywhere but I recommend to put it at the very bottom, before the closing line “?>” if it’s there. You don’t need to remove anything 🙂
If it’s the first time for you, make sure you have a backup of your functions.php and FTP access so you can fix things immediately if anything goes wrong.
Hope this helps!
how to display regular price and sale price both in cart-totals.php and order page
Hey Randheer, thanks for your comment! Please take a look here: https://businessbloomer.com/woocommerce-display-regularsale-price-cart-table/#comment-16449
Hello, how can you do this in the backend and in the emails that go out? Currently if the email goes out to our warehouse, they dont know if it has been discounted and only see £7.99 when the regular price is £9.99
Hey Daniel, thanks for your comment! Yes, I took a look at the WooCommerce files and indeed Emails and Thank you page have different filters than the Cart page. I’m afraid I cannot provide a complementary fix here on the blog but I recommend you take a look at the order-details-item.php file in the templates folder 🙂 Hope this helps!
Thanks for the support, do you find it strange that it reports the discounts across emails, 3rd party invoice software and the like when using the coupon system as standard, but doesn’t report this using the ‘sale discount’ system when selling one item?
Yes! I agree with you 🙂
Hi Rodolfo,
How do I style these value (price sale, slashed price) , like make it bold and smaller for example.
I tried to put the “strong” tag on your code but somehow it didnt work.
Thank you
Hey Drake, thanks for your feedback! So, to add a style to the price you’d need to “inspect element” or use “firebug” depending on what browser you need. Those prices should have a CSS class and you can then use that in your custom.CSS. If you don’t know the basics of CSS I strongly recommend to take a look at https://www.w3schools.com/css/ because CSS is a LOT of fun! Let me know 🙂