It’s easier to understand if you break it down. The code in your question is exactly the the same as this:
$message = sprintf( __( 'This action will let you pay a deposit of <span class="deposit-price">%s</span> for this product', 'yith-woocommerce-deposits-and-down-payments' ), wc_price( $deposit_value ) );
$message = apply_filters( 'yith_wcdp_deposit_only_message', $message, $deposit_value );
echo wp_kses_post( $message );
If you look at it that way, you can see that the yith_wcdp_deposit_only_message
filter is applied after the %s
has been substituted with wc_price( $deposit_value )
.
However, you can also see that the filter receives the $deposit_value
variable as its second argument, meaning that you can use it in your filter:
<?php
add_filter(
'yith_wcdp_deposit_only_message',
function( $message, $deposit_value ) {
$message="This is my new message, and the deposit value is " . wc_price( $deposit_value );
return $message;
},
10,
2 // MUST be 2 to be able to use $deposit_value.
);