admin管理员组文章数量:1122832
I want to get the form-fields
on checkout
page when the user clicks on place-order
button.
For this I tried different hooks
, but the control does not even enter into mine block of code
I'm using the following.
add_action('woocommerce_checkout_process', 'custom_process_order');
function custom_process_order(){
//do some your magic here
print_r( WC()->checkout()->get_posted_data() );
exit();
}
With this code, I got nothing.
I have checked this and this, but no success.
How can I get all the form fields
when place-order
buttons is clicked.
Note:
I don't want to get them via js
or JQuery
to get the fields data, I want to use proper hook
for this.
I want to get the form-fields
on checkout
page when the user clicks on place-order
button.
For this I tried different hooks
, but the control does not even enter into mine block of code
I'm using the following.
add_action('woocommerce_checkout_process', 'custom_process_order');
function custom_process_order(){
//do some your magic here
print_r( WC()->checkout()->get_posted_data() );
exit();
}
With this code, I got nothing.
I have checked this and this, but no success.
How can I get all the form fields
when place-order
buttons is clicked.
Note:
I don't want to get them via js
or JQuery
to get the fields data, I want to use proper hook
for this.
1 Answer
Reset to default 0The place-order form button is actually called woocommerce_checkout_place_order, and the code in WC_Form_Handler passes this on to WC_Checkout process_checkout().
Here's the relevant code. You probably want to hook:
- woocommerce_before_checkout_process or woocommerce_checkout_process, which happen before this code reads the items from posted data itself (although you could call WC()->checkout()->get_posted_data() yourself I think)
- woocommerce_after_checkout_validation, which is passed the posted data as its first argument along with an errors array
- woocommerce_checkout_order_processed if you want the data after the checkout is complete.
本文标签: pluginsHow to get the checkout form data from checkout page when placeorder button is clicked
版权声明:本文标题:plugins - How to get the checkout form data from checkout page when place-order button is clicked 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736290646a1928558.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论