Untitled
webwizards
plain_text
7 days ago
1.1 kB
5
Indexable
add_action( 'woocommerce_before_cart_table', 'custom_cart_discount_message' );
add_action( 'woocommerce_before_checkout_form', 'custom_cart_discount_message' );
function custom_cart_discount_message() {
if ( ! function_exists( 'b2bking' ) || ! b2bking()->is_b2b_user() ) {
return;
}
$threshold = 1000; // € HT
$cart_total_ex_tax = WC()->cart->get_subtotal();
if ( $cart_total_ex_tax >= $threshold ) {
$message = '🎉 Félicitations ! Vous bénéficiez d\'une <strong>remise supplémentaire de 10 %</strong> sur votre commande !';
echo '<div class="woocommerce-info">' . $message . '</div>';
} else {
$remaining = $threshold - $cart_total_ex_tax;
$remaining_formatted = number_format( $remaining, 2, ',', ' ' );
$message = sprintf(
'💡 <strong>-10 %% supplémentaires</strong> dès 1 000 € HT — plus que <strong>%s €</strong> pour en profiter !',
$remaining_formatted
);
echo '<div class="woocommerce-info">' . $message . '</div>';
}
}Editor is loading...
Leave a Comment