How to display regular price strike out in woocommerce shop page?

The strike out regular price wordpress woocommerce website display in WooCommerce shop, category and archive page , if You need to display price strikethrough or struck-out price for WooCommerce at the WooCommerce store website's each product in the shop, category and archive pages.
Always use child theme any wordpress website and copy below code and add this code in your functions.php and strike original price over the discount price woocommerce shop page.

Display strikethrough price for WooCommerce products page

Use this below display strikethrough price shortcode for woocommerce product shop, category and archive pages-

add_filter( 'woocommerce_variable_sale_price_html', 'wc_wc20_variation_price_format', 10, 2 ); add_filter( 'woocommerce_variable_price_html', 'wc_wc20_variation_price_format', 10, 2 ); function wc_wc20_variation_price_format( $price, $product ) { // Main Price $prices = array( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) ); $price = $prices[0] !== $prices[1] ? sprintf( __( ' %1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] ); // Sale Price $prices = array( $product->get_variation_regular_price( 'min', true ), $product->get_variation_regular_price( 'max', true ) ); sort( $prices ); $saleprice = $prices[0] !== $prices[1] ? sprintf( __( '%1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] ); if ( $price !== $saleprice ) { $price = '' . $price . ' ' . $saleprice . ''; } return $price; }

Post a Comment

0 Comments