I'm using this hook woocommerce_order_status_processing
to check if an order is payed and update the user with a memberplan. The problem is that manual update, acessing woocommerce menu > orders > change status from any to processing works, but when the online payment returns and change the status programatically appears that the hook woocommerce_order_status_processing
is not being used and my client's status is not being changed. How I can find which hook I need to use? Someone have a tip?
I'm using this hook woocommerce_order_status_processing
to check if an order is payed and update the user with a memberplan. The problem is that manual update, acessing woocommerce menu > orders > change status from any to processing works, but when the online payment returns and change the status programatically appears that the hook woocommerce_order_status_processing
is not being used and my client's status is not being changed. How I can find which hook I need to use? Someone have a tip?
- What did you mean with "when the online payment returns"? – user141080 Commented Jul 11, 2018 at 19:01
- Think paypal. If paypal is processing the order they return a value and woocommerce update the order. When this is ocurring my function is not being called. But if I access my wp-admin, go to the order and manually change the status my function is called. I think is something with the hook I'm using. – Rafael Figueiredo Commented Jul 11, 2018 at 19:09
- Have you looked in the code of your payment plugin? Which one do you use? – user141080 Commented Jul 12, 2018 at 12:18
- Yes. I looked before but somehow looking again now I discovered the correct hook. Thanks! – Rafael Figueiredo Commented Jul 13, 2018 at 18:23
1 Answer
Reset to default 2Like I said before change manually the data through admin works well with the woocommerce_order_status_processing
hook. But the gateway I'm using was using other method and consequently other hook. The right hook is woocommerce_update_order
.
Inside this hook was needed to use a conditional check if the status
change to processing.
public function create_memberplan_after_update_order($order){
$order = wc_get_order($order);
if ($order->data['status'] == 'processing') {
//update user when status is changed to processing
}
}