How to check if is in cart page? [closed]

I’m not sure where are you hooking your function to, but you might be doing it too early.

Hook to template_redirect, and then redirect the user:

add_action('template_redirect','redirect_visitor');
function redirect_visitor(){
    if ( is_page( 'cart' ) || is_cart() ) {
        wp_safe_redirect(site_url());
        exit(); // Don't forget this one
    }
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)