Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move payment methods in Woocommerce checkout page

I have to move the payment methods in the checkout page of a Woocommerce website above the order review, but I don't know how. The problem is, that I tried using the following code:

remove_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_payment', 20 ); 
add_action( 'woocommerce_after_order_notes', 'woocommerce_checkout_payment', 20 );

But also the "Terms and Conditions" text and the "Place order" button are moving with that. I need to have the payment options, then the order review, and in the end the "Terms and Conditions" text and the "Place order" button.

How can I do that?

like image 297
Dino9 Avatar asked Mar 09 '23 12:03

Dino9


1 Answers

Original WC Hook

// includes/wc-template-hooks.php:214
add_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_payment', 20 );

Your Hook

This will be in your theme or plugin.

// make sure the priority value is correct, running after the default priority.
remove_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_payment', 20 );
add_action( 'woocommerce_after_order_notes', 'woocommerce_checkout_payment', 20 );

Your hook should run after WC has loaded; so that you can remove it.

function theme_wc_setup() {
  remove_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_payment', 20 );
  add_action( 'woocommerce_after_order_notes', 'woocommerce_checkout_payment', 20 );
}
add_action( 'after_setup_theme', 'theme_wc_setup' );

EDIT: Thanks all, didn't know this is still actively searched. Vote up to help other devs!

like image 161
Khairul Avatar answered Mar 19 '23 04:03

Khairul