Preview:
function custom_variation_price_discount( $variations ) {
    if( isset( $variations['price_html'] ) && $variations['price_html'] != '' ) {
		$discount_message = '';
		$variation = wc_get_product( $variations['variation_id'] );
		
		if ( $variation->is_on_sale() ) {
			if($variations['save_percent'] && $variations['save_percent'] == ''){
				$regular_price = $variation->get_regular_price();
				$sale_price = $variation->get_sale_price();
				if ( $regular_price > 0 && $sale_price > 0 ) {
					$percentage = round( ( ( $regular_price - $sale_price ) / $regular_price ) * 100 );
					$discount_message = '<span class="discount-percentage">Save ' . $percentage . '%</span>';
				}
			}else{
				$discount_message = $variations['save_percent'];
			}
		}
		
        $variations['price_html'] = '<div class="price-wrap">'. $variations['price_html'] . $discount_message  . '</div>';
    }
    return $variations;
}

add_filter( 'woocommerce_available_variation', 'custom_variation_price_discount' );
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter