php - 在 n 秒后自动从 Woocommerce 感谢您重定向到内部页面(主页)
问题描述
我尝试了几天来解决这个问题。我找到了接近但不完全是我需要的解决方案。主要基于这两个例子:
- 从 Woocommerce 自动重定向到外部链接传递变量
- https://www.businessbloomer.com/resolved-woocommerce-redirect-custom-thank-page/ 我把这段代码放在我的woocommerce自定义functions.php中
`
// Redirect from thank you page to home after 3 seconds
add_action( 'woocommerce_thankyou', 'ckde_redirect_after_checkout');
function ckde_redirect_after_checkout( $order_id ){
$order = wc_get_order( $order_id );
$url = get_site_url();
if ( ! $order->has_status( 'failed' ) ) {
header("Refresh: 3; $url" );
}
}
有最佳实践或更清晰的方法来做到这一点?无论如何,它有效!
解决方案
推荐阅读
- c# - Swagger UI 输出“不支持的媒体类型”
- xamarin - MVVM Xamarin Forms,最适合在等待来自服务调用的几分钟响应时将函数保留在内存中
- amazon-web-services - 在foreach循环中执行powershell命令
- java - Spring ExceptionalHandler 的 Java 测试
- typescript - 在默认导出和命名导出中导出一个值(循环)
- sql - 使用 sql 脚本将文本文件从一个文件夹移动到另一个文件夹
- python - 如何在 Django 管理模板中检查当前查看的模型的权限
- java - @user_script:1: WRONGTYPE 对持有错误值的键的操作
- azure - Azure API 管理 - 如何通过 PowerShell 命令启用 HTTP/2?
- python - 如何在 matplotlib 中为水平条形图添加标签?