add_filter( 'woocommerce_sale_flash', 'navarro_change_badge_to_percentage', 99, 3 ); function navarro_change_badge_to_percentage( $html, $post, $product ) { $price = intval( ( $product instanceof WC_Product_Variable ) ? $product->get_variation_regular_price() : $product->get_regular_price() ); $sale = intval( ( $product instanceof WC_Product_Variable ) ? $product->get_variation_sale_price() : $product->get_sale_price() ); $discunt = $price - $sale; return sprintf( '<div class="onsale-wrapper"><span class="onsale"> %s₪ %s</span></div>', $discunt, __( 'הנחה', 'woocommerce' ) ); }
Preview:
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