WooCommerce 订阅:是否有手动付款重试的挂钩?

时间:2021-03-12 09:02:54

标签: php wordpress woocommerce hook-woocommerce woocommerce-subscriptions

我有待付款的 Woocommerce 订单。当订单达到自动重试付款计划时,它会从订阅中提取付款信息​​,这非常有效,因为届时客户可能已经更正了错误的详细信息。

但在某些情况下,我们需要手动重试付款。完成此操作后,它不会从订阅中提取付款信息​​(因为客户可能已更正其详细信息以供浏览)。

是否有可以用来触发以下代码的钩子/动作? woocommerce_subscriptions_before_payment_retry 似乎不起作用。

add_action('woocommerce_subscriptions_before_payment_retry', 'remove_payment_details', 10, 2 );
function remove_payment_details( $order_id ){

  $order         = wc_get_order( $order_id ); // Order Object
  $subscriptions = wcs_get_subscriptions_for_order( $order_id, array( 'order_type' => 'any' ) ); // Array of subscriptions Objects

  foreach( $subscriptions as $subscription_id => $subscription ){
       $stripe_cust_id = $subscription->get_meta( '_stripe_customer_id');
       $stripe_src_id  = $subscription->get_meta( '_stripe_source_id' );

       $order->update_meta_data( '_stripe_customer_id', $stripe_cust_id );
       $order->update_meta_data( '_stripe_source_id', $stripe_src_id );
       $order->save();
  }

}

enter image description here

1 个答案:

答案 0 :(得分:0)

请检查 add_action( 'woocommerce_order_action_wcs_retry_renewal_payment', 'custom_process_retry_renewal_payment_action_request', 20, 1 ); function custom_process_retry_renewal_payment_action_request( $order ) { // your code is here } 钩子。 该钩子用于“重试续订付款”处理,您可以使用它。

subdomain.example.com