0
votes

I am using the Wordpress plugin for Stripe, which has a hook action called:

do_action( 'wc_stripe_checkout_receipt_page_before_form' ); 

This action is located above the Stripe payment form & I would like to display some text here, so how I tap into this hook?

This action can be found in the source below on line 541

https://github.com/woocommerce/woocommerce-gateway-stripe/blob/master/includes/class-wc-gateway-stripe.php

This is what I have tried

remove_action('wc_stripe_checkout_receipt_page_before_form');
add_action('foobar', 'wc_stripe_checkout_receipt_page_before_form');

function foobar(){
    echo 'foo';
}

which produces the following warning, but does not display my echo 'foo'

Missing argument 2 for remove_action(),
1

1 Answers

4
votes

Your error tells you everything you need to know.
remove_action takes 2 arguments at least - action name and function name which was hooked to it.
In your case, you shouldn't remove it, but instead hook to it. Which you've done wrong. First argument for add_action is an action which you're trying to hook to (wc_stripe_checkout_receipt_page_before_form in your case), second is function which should execute on that action (foobar in your case). The correct call:

add_action('wc_stripe_checkout_receipt_page_before_form', 'foobar');

This way, your 'foo' will be displayed before the form, since that's where the action is called.