Need add custom message after "Thank you. Your order has been received.". A variable has been added to my message. It contains the percentage of the total amount of the order.
The following code works but I am not sure about it:
add_filter('woocommerce_thankyou_order_received_text', 'woo_change_order_received_text', 10, 2 );
function woo_change_order_received_text( $str, $order ) {
// Get order total
$order_total = $order->get_total();
$percent = get_option( 'wc-custom-percent' ); // Percentage
$order_saving = (float)($percent * $order_total / 100); // Bonus amount
$new_str = $str . ' You participate in the bonus program, your bonus interest from this order is' . $order_saving . ' euros. <a href="#">Learn more about the bonus program.</a>';
return $new_str;
}
Is it a better way to do it? How can I enhance my code?