I want to redirect to page with URL slug ‘join’ or post-id 471, what should I put behind wc_get_page_id?
add_action("template_redirect", 'redirection_function');
function redirection_function(){
global $woocommerce;
if( is_cart() && WC()->cart->cart_contents_count == 0){
wp_safe_redirect( get_permalink( wc_get_page_id( 'join' ) ) );
exit;
}
}
add_action( 'template_redirect', 'cart_empty_redirect_to_join' );
Thanks!
2
Answers
This should work. Let me know.
I had the same problem and I solved it in the following way.