admin管理员组文章数量:1122832
I am using Woocommerce plugin for my custom product .and I am stuck with a situation .
Does Woo commerce provide any hook or filter when refund is done through admin panel and refund will be manually.
I am using Woocommerce plugin for my custom product .and I am stuck with a situation .
Does Woo commerce provide any hook or filter when refund is done through admin panel and refund will be manually.
Share Improve this question asked Jul 28, 2017 at 10:59 user1263829user1263829 1111 silver badge3 bronze badges 1- 2 When that button is clicked, javascript is called to update the UI to show refund options. It will not trigger any hook. Do you mean to ask if any hooks are triggered when such a refund is confirmed? – Joshua Goossen Commented Aug 30, 2017 at 16:41
3 Answers
Reset to default 14Although this answer is little late but anyone else may get benefit from it. The woocommerce_order_refunded
hook is called when an order is refunded. Use the following example:
// add the action
add_action( 'woocommerce_order_refunded', 'action_woocommerce_order_refunded', 10, 2 );
// Do the magic
function action_woocommerce_order_refunded( $order_id, $refund_id )
{
// Your code here
}
My answer is for emails or when refunds are done through the payment gateway but it might help someone coming across this. So in addition to Tech Dog's answer You can use a few other hooks specifically for partial refunds: woocommerce_order_partially_refunded
and for full refunds: woocommerce_order_fully_refunded
These hooks can be seen here (I copied the lines at version 5.9 of WooCommerce, so depending on when someone is reading this the hooks might be on different lines in the latest version)
In the latest version of WooCommerce the following hooks are fired when an order is refunded:
- Either
woocommerce_order_fully_refunded
orwoocommerce_order_partially_refunded
hook - A bunch of hooks which are always fired when an order status is changed, you can find them here https://rudrastyh.com/woocommerce/order-lifecycle-hooks.html#order-status-changed
- and the last one
woocommerce_order_refunded
p.s. I mentioned the hooks in the same order they are going to be fired.
Example 1:
add_action( 'woocommerce_order_fully_refunded', function( $order_id, $refund_id ) {
// enter your code here
}, 20, 2 );
Example 2:
add_action( 'woocommerce_order_partially_refunded', function( $order_id, $refund_id ) {
// enter your code here
}, 20, 2 );
Example 3:
add_action( 'woocommerce_order_refunded', function( $order_id, $refund_id ) {
// enter your code here
}, 20, 2 );
As you can see all of them have the same arguments
本文标签: Are there any hook or filter when refund is done through admin woocommerce
版权声明:本文标题:Are there any hook or filter when refund is done through admin -woocommerce 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736308909a1933824.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论