在 woocommerce_thankyou 页面的 API 保存了订单
saved order at API in woocommerce_thankyou page
woocoommerce_thankyou 页面上的发票信息由 Web 服务卷曲。如果用户因为某种原因没有看到这个页面,如何进行存储操作呢?能否以任何其他方式更改发票存储操作?
add_action( 'woocommerce_thankyou', 'club_add_factor', 10, 1 );
function club_add_factor( $order_id ) {
if ( ! $order_id ) {
return;
}
/* Get order info */
$order = new WC_Order( $order_id );
$userID = $order->get_customer_id();
$api = new Club( $userID );
// something ...
}
你说的对,“woocommerce_thankyou”是统一处理下面的钩子。但是当你没有登陆thankyou页面时,你可以使用on-hold或者processing代替。
//add_action('woocommerce_order_status_pending', 'club_add_factor');
//add_action('woocommerce_order_status_on-hold', 'club_add_factor');
//add_action('woocommerce_order_status_processing', 'club_add_factor');
//add_action('woocommerce_order_status_completed', 'club_add_factor');
add_action('woocommerce_thankyou', 'club_add_factor');
谢谢兄弟!
我用 'woocommerce_order_status_processing' 动作解决了它。
我用过它:
add_action('woocommerce_order_status_processing', 'club_add_factor');
woocoommerce_thankyou 页面上的发票信息由 Web 服务卷曲。如果用户因为某种原因没有看到这个页面,如何进行存储操作呢?能否以任何其他方式更改发票存储操作?
add_action( 'woocommerce_thankyou', 'club_add_factor', 10, 1 );
function club_add_factor( $order_id ) {
if ( ! $order_id ) {
return;
}
/* Get order info */
$order = new WC_Order( $order_id );
$userID = $order->get_customer_id();
$api = new Club( $userID );
// something ...
}
你说的对,“woocommerce_thankyou”是统一处理下面的钩子。但是当你没有登陆thankyou页面时,你可以使用on-hold或者processing代替。
//add_action('woocommerce_order_status_pending', 'club_add_factor');
//add_action('woocommerce_order_status_on-hold', 'club_add_factor');
//add_action('woocommerce_order_status_processing', 'club_add_factor');
//add_action('woocommerce_order_status_completed', 'club_add_factor');
add_action('woocommerce_thankyou', 'club_add_factor');
谢谢兄弟! 我用 'woocommerce_order_status_processing' 动作解决了它。 我用过它:
add_action('woocommerce_order_status_processing', 'club_add_factor');