For my checkout page I would like to have more than 1 "place order" button. Is there a script that generates this button? I haven't been able to find it so far.
I only found one where you can change the text of the button. But I need one where I can just generate a new one within the checkout page.
The place order button is located in WooCommerce checkout/payment.php
template file (line 51
):
<?php echo apply_filters( 'woocommerce_order_button_html', '<button type="submit" class="button alt" name="woocommerce_checkout_place_order" id="place_order" value="' . esc_attr( $order_button_text ) . '" data-value="' . esc_attr( $order_button_text ) . '">' . esc_html( $order_button_text ) . '</button>' ); ?>
Where $order_button_text = __("Place order", "woocommerce");
Now as this button is located inside the checkout
<form>
and if you duplicate it and you want it to work, it requires to be inside the checkout<form>
.
So you can include it in any checkout template or using available hooks like for example:
add_action( 'woocommerce_checkout_after_order_review', 'second_place_order_button', 5 );
function second_place_order_button() {
$order_button_text = apply_filters( 'woocommerce_order_button_text', __( "Place order", "woocommerce" ) );
echo '<button type="submit" class="button alt" name="woocommerce_checkout_place_order" id="place_order" value="' . esc_attr( $order_button_text ) . '" data-value="' . esc_attr( $order_button_text ) . '">' . esc_html( $order_button_text ) . '</button>';
}
Code goes in function.php file of your active child theme (or active theme).
The hook that you will use need to be located inside the checkout <form>
.