我第一次使用人工智能
但是你告诉我的密码不起作用
将静脉从治疗自动转换为30秒后完成
仅限虚拟产品
具体支付方式有两种
但它不起作用
// Add a 30 second delay for virtual products
add_filter( 'woocommerce_payment_complete_order_status', 'wc_delay_virtual_order', 10, 2 );
function wc_delay_virtual_order( $order_status, $order ) {
if ( $order->has_downloadable_item() && ! $order->has_status( 'completed' ) ) {
return 'on-hold'; // change to any other status you wish to use.
}
return $order_status;
}
add_action( 'woocommerce_thankyou', 'wc_delay_virtual', 30 );
function wc_delay_virtual( $orderid ) {
// Get the order object and check for downloadable items.
$order = new WCOrder($orderid);
if ( $order->hasDownloadableItem() ) {
// Set a 30 second delay for virtual products.
sleep(30);
// Update the order status to complete.
$order->updateStatus('completed');
}
}
// Add a custom payment gateway for MobileWallet and Reference Code payments.
add-filter('woocommerce-payment-gateways','wc-add-mobilewallet-referencecode');
function wc-add-mobilewallet-referencecode($methods){
$methods[] = 'WCMobileWallet'; // MobileWallet payment gateway class name.
$methods[] = 'WCReferenceCode'; // Reference Code payment gateway class name.
return $methods;
}
我试着把这个代码添加到插件和function.php里面我正在等待你的回复来解决我的问题,谢谢
1条答案
按热度按时间hsvhsicv1#
下面发布的代码部分有一个问题。您不能在函数名之间使用
-
,如wc-add-mobilewallet-referencecode
,而应该使用wc_add_mobilewallet_referencecode
和下划线“_”正确的代码应该如下所示:
由于您只需要更改订单状态以完成可下载的产品,只需下面的代码: