所以我想在检查它是否是他的第二个订单之后将用户重定向到一个自定义的感谢页面。所以如果是第二个订单-->thankyou,否则-->thankyou-2。
我有这个代码:
add_action('template_redirect', 'mbm_redirect_depending_on_product_id');
function mbm_redirect_depending_on_product_id()
{
if (!is_wc_endpoint_url('order-received') || empty($_GET['key']))
{
return;
}
$order_id = wc_get_order_id_by_order_key($_GET['key']);
$order = wc_get_order($order_id);
foreach ($order->get_items() as $item)
{
if {
wp_redirect('/thankyou');
exit;
} else {
wp_redirect('/thankyou-2');
exit;
}
}
}
}
我必须做出什么样的 if 语句才能完成这项工作?
森林海