You can place PHP snippets at the bottom of your child theme functions.php file (delete "?>" if you have it there). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my free video tutorial "Where to Place WooCommerce Customization?"
Does this snippet (still) work?
Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7.3.
Check out these free video tutorials. You can learn how to customize WooCommerce without unnecessary plugins, how to properly configure the WooCommerce plugin settings and even how to master WooCommerce troubleshooting in case of a bug!
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.
6 thoughts on “WooCommerce: Slashed Cart Subtotal if Coupon @ Cart”
I just want to say thank you for sharing all these useful snippets for free. I learned a lot on how to access WC objects, etc. from your code and your hooks reference pages. I was coding a big project and kept having to look up how to do X and Y, to which the answer seemed to always be, “just use this plugin!”
No!! No more!!! Plugins just are bloat and want to give me stupid popups I keep dismissing to sell me crap I don’t want. I’ve become more confident in coding things for myself thanks to looking at these snippets so I don’t have to deal with that nonsense every time I need simple functionality. Thank you very much!
Hi Rodolfo, very nice thank you! It doesn’t consider the savings from the bundles. A little update would be great 🙂
Hello Marc, 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!
Thank you for this snippet to display cart sub total at front end, Is there any way to do same at backend. When someone applied a coupon to order. its not displaying sub total. only displaying discount amount, tax and total amount after discount.
Order total: $12.00
Hey Sunny, thanks for your comment! Yes, I’m sure this is possible. The function would be similar but you need to find the “hook” that corresponds to the order total in the admin 🙂