Repeat triggering of ‘woocommerce_payment_complete’ hook for dev

‘woocommerce_payment_complete’ is the hook that is triggered when payment is flagged as accepted by your payment gateway in WooCommerce.

It’s a really useful hook because you can make things happen as soon as payment passes.

Read More

The problem I’m having it testing custom functions I attach to the hook – it is extremely laborious.

Basically, every time I want to test one of my functions attached to this hook I have to fill up my card, go through check out, submit payment then analyse what happens. If there’s a bug or error then I have to fill up my card, go through check out, submit payment then analyse what happens all over again.

I’m losing hours doing this, so I was wondering, does anyone have a dev tip to make this less time consuming?

Related posts

Leave a Reply

1 comment

  1. This hook is fired after the steps which (may) include financial transactions. Testing its contents does not actually require a financial transaction, but your wordpress does have to step through shopping cart events, in order to get you to the later point where the hook is fired.

    What I did was to create a 100% discount coupon, so that I do not need to bother with
    financial transactions when I modify/test code involved in this hook. That way I can quickly buy something from my shopping cart and then watch my logs output messages telling me about the code that is called when this hook is called, after the shop code has done its thing.