Closed. This question is off-topic. It is not currently accepting answers.admin管理员组文章数量:1122832
Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 6 months ago.
Improve this questionCurrently I am using woocommerce_thankyou action to run a function that creates an order at a third party service.
However, sometimes customers don't return to the Thank You page after visiting our Payment Service Provider, resulting in no order being created at the third party.
Would it be better to use the woocommerce_order_status_completed action? Any other hooks I could use? Is there a scheme/rundown available somewhere of all the actions that follow eachother? Any other ideas to solve this problem?
Closed. This question is off-topic. It is not currently accepting answers.Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 6 months ago.
Improve this questionCurrently I am using woocommerce_thankyou action to run a function that creates an order at a third party service.
However, sometimes customers don't return to the Thank You page after visiting our Payment Service Provider, resulting in no order being created at the third party.
Would it be better to use the woocommerce_order_status_completed action? Any other hooks I could use? Is there a scheme/rundown available somewhere of all the actions that follow eachother? Any other ideas to solve this problem?
Share Improve this question asked Feb 19, 2019 at 10:37 KevsterinoKevsterino 111 silver badge2 bronze badges2 Answers
Reset to default 0If you want to send data to third party service, then you want to trust this connection.
So using Thank You page isn't the best idea.
There are some hooks that you may want to check and which of them will be the best for you depends on what exactly are you trying to achieve...
You can use:
woocommerce_new_order
- it takes$order_id
as first param and it's called whenever a new order is placed in WC.woocommerce_order_status_<status>
- it also takes$order_id
as first param and it will be called when the order changes status to (you can useprocessing
,completed
and so on as ).
Using the woocommerce_order_status_completed
action might indeed be a better approach compared to relying solely on the woocommerce_thankyou
action. The reason is that the woocommerce_order_status_completed
action is triggered when an orders status changes to completed
, which typically happens after a successful payment.
add_action( 'woocommerce_order_status_completed', 'my_custom_function_to_create_order', 10, 1 );
function my_custom_function_to_create_order( $order_id ) {
// Get the order object
$order = wc_get_order( $order_id );
// Check if the order exists and is valid
if ( ! $order ) {
return;
}
// Proceed to create order at third-party service
// Your code to create order at the third-party service
}
本文标签: woocommerce offtopicHook to use when customer placing order
版权声明:本文标题:woocommerce offtopic - Hook to use when customer placing order 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736300525a1930847.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论