woocommerce_format_sale_price

FILTER woocommerce\includes\wc-formatting-functions.php (ligne 1373) github
Format a sale price for display.
traduction française
Formatage d'un prix de vente pour l'affichage.

Paramètres

Entrée :
$price, $regular_price, $sale_price
Sortie :
@param  string $regular_price Regular price.
@param  string $sale_price    Sale price.
@return string

Utilisation

Formater l'affichage du prix soldé

Personnaliser comment sont affichés prix régulier et prix promo

products pricing ui
// Formater le prix soldé
add_filter('woocommerce_format_sale_price', 'format_prix_solde', 10, 3);

function format_prix_solde($price, $regular_price, $sale_price) {
    // Format personnalisé: prix barré + nouveau prix + économie
    $saving = $regular_price - $sale_price;
    $saving_percent = round(($saving / $regular_price) * 100);
    
    $price = '' . wc_price($regular_price) . ' ';
    $price .= '' . wc_price($sale_price) . ' ';
    $price .= 'Économisez ' . $saving_percent . '%';
    
    return $price;
}

Actualités

Chargement des actualités...