הצגת הנחה במספר (גודל ההנחה)

PHOTO EMBED

Thu Nov 18 2021 07:23:46 GMT+0000 (Coordinated Universal Time)

Saved by @Shesek

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' ) );
}
content_copyCOPY

קרדיט: עידו נברו