How To Show the Regular Price on Your WooCommerce Cart Page

Connect With Us In Our Social Media

Table of Contents

Post Intro

By default, the WooCommerce cart page displays the total price of all the items in the cart, but it doesn’t show the regular price of each item. This can be a problem for online store owners who offer discounts or have special pricing for their products. However, with a simple customization, you can easily display the regular price of each item on your WooCommerce cart page. In this post, we’ll show you how to do it step by step, so you can give your customers a better shopping experience and increase your sales in your WooCommerce store

Youtube Tutorial

Login To Access Code Snippet:

Post More Detail

The add_filter() function registers the woo_show_regular_price_on_cart function to be called whenever the woocommerce_cart_item_price filter is applied.

The woo_show_regular_price_on_cart function takes three parameters: $price, $values, and $cart_item_key.

The $price parameter is the current price of the product in the cart.

The $values parameter contains the cart item data including the product ID, quantity, and other details.

The $cart_item_key parameter is the unique identifier for the cart item.

The function checks if the product is on sale by calling the is_on_sale() method on the product object.

If the product is on sale, the function retrieves the regular price of the product using the get_regular_price() method and formats it using the wc_price() function.
The function then adds the formatted regular price to the cart item’s price using HTML and CSS to strike through the regular price and reduce its opacity.
Finally, the function returns the updated price with the regular price included.

Conclusion In summary

Features Added:
How to show regular price in cart page.

Stay UpTo Date with Latest Post And news:

Would love your thoughts, please comment.x

Login To Access Code Snippet:

Stay UpTo Date with Latest Post And news: