skip to Main Content

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.

2

Answers


  1. Have you tried to use this hook?

    add_action( '(specify the hook you wish to place it)', 'woocommerce_template_single_add_to_cart', 30 );
    

    for example:

    add_action( 'woocommerce_before_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
    

    I did not tested it, need to check if it does not produce errors because of multiple buttons on the single product page.

    Login or Signup to reply.
  2. 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>.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search