This handy snippet modifies the text of the main checkout button in your e-shop. Instead of the standard „Order with payment required“ or „Submit order“, it also adds to the text the final amount, to be paid by the customer.
From a psychological point of view, this is an excellent element - the customer has the exact amount in front of his eyes at the last step, which increases the transparency and credibility of the purchasing process.
What does the code do?
- He's checking the basket: First, it verifies that the customer actually has something in the basket.
- He takes over the finished amount: The code does not recalculate the amount, but takes the already calculated value directly from WooCommerce, which saves server performance.
- Cleans formatting: Removes redundant HTML tags and correctly handles currency symbols (e.g. €) so that the text on the button displays correctly and cleanly.
- Connects the text: The original text of the button „Order with payment required“ and adds after it „for the AMOUNT €“ The result is a format of type: „Order with payment obligation for 22,00 €“.

Use
Put the snippet into a file functions.php your active theme (ideally Child Theme) or use a snippet management plugin (e.g. Code Snippets).
PHP
add_filter( 'woocommerce_order_button_text', 'custom_checkout_button_text_optimized' );
function custom_checkout_button_text_optimized( $button_text ) {
if ( WC()->cart && ! WC()->cart->is_empty() ) {
$total_string = WC()->cart->get_total();
$clean_total = html_entity_decode( strip_tags( $total_string ) );
return $button_text . ' for ' . $clean_total;
}
return $button_text;
}

