[英]Order status processing issue on successful payment from Paypal in Woocommerce
I am having strange issue and this happens sometimes, when user pay for a course via paypal the order status changed from pending to processing instead of completed. 我有一个奇怪的问题,有时会发生这种情况,当用户通过paypal支付课程时,订单状态从待处理更改为处理而不是已完成。
In this image IPIN notification received but still order is in processing stage, what could causing this issue. 在此图像中收到IPIN通知但仍处于订单处理阶段,可能导致此问题。 I tried to replicate this issue but it does not replicated at my end, It happens sometimes.
我试图复制这个问题,但它没有复制到我的结尾,它有时会发生。
Here is product info: 这是产品信息:
If you are selling only virtual products, you can force order status to "completed" for Paypal on payment complete function, this way: 如果您只销售虚拟产品,您可以强制订单状态为Paypal付款完成功能“完成”,这样:
add_filter('woocommerce_payment_complete_order_status', 'paypal_payment_complete_order_status', 10, 2 );
function paypal_payment_complete_order_status( $status, $order_id, $order ){
if( $order->get_payment_method() === 'paypal' )
$status = 'completed';
return $status;
}
Code goes in function.php file of your active child theme (or active theme). 代码位于活动子主题(或活动主题)的function.php文件中。 Tested and work.
经过测试和工作。
This hook is only triggered on successful payment and has originally 2 possible order status values "processing" or "completed" (depending if "processing" is required) .
此挂钩仅在成功付款时触发,并且最初有2个可能的订单状态值“处理”或“已完成” (取决于是否需要“处理”) 。 So this answer code just force the order status to "completed" targeting Paypal payment gateway (for virtual products) .
所以这个答案代码只是迫使订单状态“完成”定位Paypal支付网关(用于虚拟产品) 。 This hook is located on
WC_Order
payment_complete()
method.此挂钩位于
WC_Order
payment_complete()
方法上。
All payment gateways usepayment_complete()
method on a successful payment and Paypal use it onWC_Gateway_Paypal_Response
Class.所有支付网关都使用
payment_complete()
方法成功付款,Paypal在WC_Gateway_Paypal_Response
Class上使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.