woocommerce offtopic - How can I locate where the actions are defined?

admin2025-06-06  8

This question already has answers here: Get a list of all registered actions (2 answers) Closed 6 years ago.

Given the following code:

<form>
    <h1> My form <h1>
    <input type="text" />
    <?php do_action( 'woocommerce_checkout_after_customer_details' ); ?>
</form>

How can I locate the "woocomerce_checkout_after_customer_details" defined?

It prints a button where I have to add functionality, maybe can I just use add_action() to add new features? in that case: how can I use remove_action() to stop rendering the old button?

Thanks in advance

This question already has answers here: Get a list of all registered actions (2 answers) Closed 6 years ago.

Given the following code:

<form>
    <h1> My form <h1>
    <input type="text" />
    <?php do_action( 'woocommerce_checkout_after_customer_details' ); ?>
</form>

How can I locate the "woocomerce_checkout_after_customer_details" defined?

It prints a button where I have to add functionality, maybe can I just use add_action() to add new features? in that case: how can I use remove_action() to stop rendering the old button?

Thanks in advance

Share Improve this question edited Nov 23, 2018 at 9:49 Krzysiek Dróżdż 25.6k9 gold badges53 silver badges74 bronze badges asked Nov 23, 2018 at 9:31 JnewbieJnewbie 132 bronze badges 0
Add a comment  | 

1 Answer 1

Reset to default 0

You can find out what actions are assigned to given hook with this code:

function print_filters_for( $hook = '' ) {
    global $wp_filter;
    if( empty( $hook ) || ! array_key_exists( $hook, $wp_filter ) ) {
        return;
    }

    print '<pre>';
    print_r( $wp_filter[$hook] );
    print '</pre>';
}

Call it where you need it. In your case:

<form>
    <h1> My form <h1>
    <input type="text" />
    <?php do_action( 'woocommerce_checkout_after_customer_details' ); ?>
    print_filters_for( 'woocommerce_checkout_after_customer_details' );
</form>
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749157541a316853.html

最新回复(0)