我添加了这个代码
add_action( 'woocommerce_thankyou', 'redirect_product_based', 1 );
function redirect_product_based ( $order_id ){
$order = wc_get_order( $order_id );
foreach( $order->get_items() as $item ) {
// Add whatever product id you want below here
if ( $item['product_id'] == 2749 ) {
// URL
wp_redirect( 'https://landing.mailerlite.com/webforms/landing/q6l9u3' );
} else {
// The other URL
wp_redirect( 'https://landing.mailerlite.com/webforms/landing/q6l9u3' );
}
}
}
但重定向将应用于所有产品 谢谢