Format a sale price for display.
Formatage d'un prix de vente pour l'affichage.
$price, $regular_price, $sale_price
Sortie :
@param string $regular_price Regular price. @param string $sale_price Sale price. @return string
// 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;
}
Chargement des actualités...