WooCommerce: Display default Variation Regular and Sale Price

Display default variation price for variable products in Woocommerce shop pages

To display the default selected variation regular price and sale price on the WooCommerce archive Shop or Category pages, you’ll need to modify the code to identify and display the prices of the default selected variation.

Suppose you are a WordPress/ WooCommerce developer or business owner and looking for a WooCommerce function to display the default selected variation’s regular price and sale price on the shop/category page. Then this article is important for you to resolve your problem.

WooCommerce: Display Regular & Sale Price for variable products on shop page

Display Default Variation Regular and Sale Price on Archive Page (shop, category, etc.)

Place the below code in your child theme functions.php file or a custom plugin dedicated to custom WooCommerce functionalities.

Also Read: Create WooCommerce custom product type programmatically

WooCommerce: Display variable products Regular & Sale Price in loop

Let’s see how this code works:

  • It hooks into the woocommerce_get_price_html filter, which allows us to modify the price HTML displayed on product archive pages.
  • Check if the product is of type “variable”.
  • Retrieves available variations and their regular and sale prices.
  • Constructs the HTML markup to display the regular price and sale price (if applicable) for variable products.

Are you want to get implementation help, or modify or extend the functionality of this script?

A Tutorialswebsite Expert can do it for you.

Display Variation Minimum Sale Price and Maximum Regular Price on Archive Page

This code snippet filters the display of the variable product price HTML. It gathers all visible variations’ regular and sale prices and finds the minimum sale and maximum regular price.

This code will display the regular price and sale price range for variable products on archive pages (shop, category, etc.). You can place this code snippet in your theme’s functions.php file or a custom plugin created for this purpose. As always, ensure you test this code in a staging environment or make a backup before implementing it on a live site.

Wrapping Words

Thanks for reading 🙏, I hope you found the How to Display Default Variation Regular and Sale Price in WooCommerce tutorial helpful for your project. Keep learning! If you face any problems – I am here to solve your problems.

FAQs

WooCommerce to display Variation Sale and Regular Price on Archive Page

If you want to display the sale and regular prices for the default selected variation of variable products on the WooCommerce archive pages (shop, category, etc.), you can utilize the above code snippets.

How to display variable product’s Regular and sale Prices in the loop?

woocommerce_get_price_html filter allows us to modify the price HTML displayed on product archive pages. display variable product’s Regular & Sale Prices in the loop you can use “Display Default Variation Regular and Sale Price on Archive Page (shop, category, etc.)” code Snippets.

Is it possible to display only the maximum regular and sale price on Archive Page or Shop Page?

Yes, It is possible to display only the maximum regular and sale prices using $product->get_variation_regular_price(‘max’); and $product->get_variation_sale_price(‘max’);

Suggested Articles

Related posts