vendidero / woocommerce-germanized

Adapt WooCommerce to the German Market with Germanized for WooCommerce
https://vendidero.de/woocommerce-germanized
Other
51 stars 41 forks source link

Action hook when order is paid #193

Closed strarsis closed 11 months ago

strarsis commented 11 months ago

WooCommerce Germanized adds a confirmation email for when the order is paid. Is there an action hook that can be used for the event when orders are paid?

The woocommerce_order_action_paid_for_order_notification action hook appears to be a fitting candidate, however, it does not seem to be fired when the order is paid.

add_action(
    'woocommerce_order_action_paid_for_order_notification',
    'orderwaspaidfn',
    10,
    1
);
dennisnissle commented 11 months ago

Hi there,

I guess you'll need to check how Woo handles that internally. Germanized does not fire any such hooks - the order paid notification uses status change events. See: https://github.com/vendidero/woocommerce-germanized/blob/master/includes/emails/class-wc-gzd-email-customer-paid-for-order.php#L36

PS: You might have a look at the woocommerce_payment_complete hook.

Best, Dennis

strarsis commented 11 months ago

Thanks for clearing this up. It really looked to me as if that action hook (woocommerce_order_action_paid_for_order_notification) can be used. But woocommerce_payment_complete is so much better.

strarsis commented 11 months ago

@dennisnissle: Let's say an order is to be paid via direct bank transfer (async. payment). When the bank transfer was successful, the shop manager has to mark the order as paid - where can this be done in WooCommerce? Changing the order status from "Pending payment" to "Processing" does not appear to trigger the hook.

dennisnissle commented 11 months ago

@strarsis - in this case you may only rely on status change events.