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
}
}
Related Posts:
- Remember page before login page, redirect to that page after login
- WooCommerce lost password reset flow not working with SendGrid (redirect loop)
- Custom Redirect after registration in WooCommerce
- Import products to WooCommerce by CSV page won’t open [closed]
- Woocommerce Login Redirect not working [closed]
- Redirect user after login through woocommerce login page to page with his/her username?
- Redirect customer to login page (with other signup plugin) if user not logged in when proceeding to checkout
- Woocommerce – Want to block a user agent from accessing specific product pages
- How to – proper WordPress 301 redirects?
- Woocommerce, prevent login after registration and redirect to custom URL
- Redirect no product url’s to static url
- WooCommerce Registration redirect based on page ID
- WooCommerce get_author_posts_url() – Author URL redirecting to shop base
- Is it ok to 301 redirect product-category pages to custom pages?
- WooCommerce and ACF: How to Redirect Upon Add to Cart – Partially Working Example
- wordpress site auto redirect to another site when I enable woocommerce
- mydomain.com/wp-login redirects to wordpress.com/wp-login
- WooCommerce shop, my account, cart every page redirect to home page [closed]
- Order by rating not works in wp_query
- How to turn off WooCommerce user registration and manually create accounts?
- WooCommerce Change Product Global Attribute Value via CRUD for Simple Product [closed]
- Change WooCommerce Image Size in One Product CAtegory
- Is there a way to get customers logged out without calling wp-login.php?
- WooCommerce checkout: How can I change $field_container of a checkout field?
- Woocommerce Shop Price Position
- How to disable users from editing billing address in WooCommerce checkout?
- Move WooCommerce product tabs out of the tabs [closed]
- Importing Woocommerce products with variations
- Woocommerce login not working on the first try
- Show add to cart button on shop woocommerce
- How do I hide the purchase note in the WooCommerce ‘order completed’ email?
- Woocommerce – Override the default templates location under the theme directory
- How to hide out of stock products in Related Products via custom query in WooCommerce
- Changing Woocommerce language without changing the language in Dashboard admin WordPress
- WooCommerce Country Drop Down colours CSS [closed]
- Fatal error: Call to undefined method WooCommerce::nonce_field()
- Where do I find where woocommerce stores product data in cpanel file manager?
- Woocommerce wp-admin search products through custom meta value too
- WOO-Commerce translation | Tried it all [closed]
- Function to recalculate shipping costs on subscriptions after renewal with Automatewoo
- Creating a multisite registration form that also creates a woocommerce post
- How to show tag count for individual product post in wordpress woocommerce
- Checkout is blocked with blockUI when using action woocommerce_cart_calculate_fees
- API returns blank response after installing & uninstalling WP-rest-api plugin
- Tried to create a user role that can only edit user information, but my test account cannot view the dashboard. What am I missing?
- Filtering variable WooCommerce products by stock level using meta_query
- How can I run a multi language WordPress site in two folders in one install? [closed]
- Dropdown menu not displaying WordPress
- Adding a custom Shipping methods field to an order
- WooCommerce – Create multiple product tags via rest api endpoint
- WooCommerce which roles and capabilities control user login re-direct to Woo Account Page?
- Conditional action hook
- Sending Email upon registration
- Migrating data from Woocommerce to another webapp
- Options to develop a non-ecommerce catalog?
- wp_set_object_terms setting only first id from array
- I need to export all products and images but I don’t know which table the images are in
- Add only sku to product url woocoomerce
- How to check if woocommerce_order_item_name is use in email?
- Purchase/order statistics plugin for viewing per payment menthod?
- Displaying Woocommerce Product Attributes on single product page
- Categories on attribute archive pages
- How to solve `Error getting remote image` in woocommerce rest api script?
- Woocommerce Multisite global search how to mod ajax function?
- How to let users create lists of woocommerce products?
- How to force Woocommerce to deliver the product to the paypal adress which was used?
- Add username and password section in WooCommerce’s my account page
- How to save one API response to WooCommerce order meta data
- Woocommerce: Search by custom attribute
- How to change user role after login?
- WooCommerce free shipping twice a week
- Product overlapping header
- remove add to cart for free (0 $) product woocommerce
- merge tabs in woocommerce
- How to import products to Woo Commerce given that WP All Import keeps timing out
- Awesome Support Custom Field for show Woocommerce orders
- How to make a custom redirect in WooCommerce?
- Firstname and lastname greyout or hidden Billing details at next checkout like username is hidden [closed]
- How to use woo commerce login to authenticate code php pages?
- Site with WooCommerce section moved to HTTPS – all pages except home and main store are 404s
- Multiple quantities with options
- how to add custom reviews button in woocommerce order complete generated mail
- Click Count on Download a File
- How to add coupon expiry date into the followup emails?
- Not all strings are translated
- Custom Woocommerce checkout filed yields a Json error when validating [closed]
- access Woo commerce | WordPress methods externally
- How to display Woocommerce catagories
- Woocommerce set single city to sell to
- eCommerce solution doesn’t want to display its shortcodes or any content where it’s set to [closed]
- Woocommerce hidden fields with meta keys and values. how?
- How do I make a diagonal strikethrough on wordpress? [closed]
- Woocommerce – Remove ‘Buy Product’ Button from shop page [closed]
- registration_errors not working
- Translate Woocommerce tab
- Woocommerce -> gallery images per variation without a plugin? [closed]
- Why is my WordPress admin not working
- Create bookings after subscription renewal
- Change variants URL
- Use a woocommerce hook to create a table and populate it with a query