Search code examples
phpwordpresswoocommercehook-woocommerce

Checkout payment hook in WooCommerce


I want to add a markup, <h3>payment</h3>, above the payment methods section in the checkout page.

I tried inserting in files woocommerce/checkout/payment.php, woocommerce/checkout/payment-method.php and woocommerce/checkout/checkout.php.

Regardless where I insert the markup, it will replicate.

Enter image description here

Where should I add the markup?


Solution

  • This is the hook for that area. Place it in your functions.php file:

    function woocommerce_before_payment_area( ) { 
        echo '<h3>payment</h3>';
    };
    add_action( 'woocommerce_review_order_before_payment', 'woocommerce_before_payment_area', 50, 0 );
    

    If it is still doubling up then the hook might already be in your theme. Search your code base for woocommerce_review_order_before_payment and change it there.