0

I am using woocommerce 3.0 and I want to redirect all guest users to my account page when they click on add to cart. I am able to do this with woocommerce filter:-

add_filter( 'woocommerce_add_to_cart_redirect', 'my_redirect' ); 

but the product gets added to the cart.

Actually i do not want anyone to be able to add to cart without login.

Any solution out there?

Thanks

Sharique Anwer
  • 129
  • 2
  • 13
  • You can look at this answer, [WooCommerce require registration to buy](https://stackoverflow.com/questions/24747095/woocommerce-require-registration-to-buy) – Noman Nov 23 '17 at 06:03
  • @Noman Hi Noman, Thanks for comment, but it is not what i need. – Sharique Anwer Nov 23 '17 at 06:40
  • You can't redirect on add to cart action, as you will get an error and customer will be frustrated without understanding what happen… So check this answer, It might be the right track for you: [WooCommerce Avoid add to cart for non logged user](https://stackoverflow.com/questions/47246951/woocommerce-avoid-add-to-cart-for-non-logged-user/47250817#47250817) – LoicTheAztec Nov 23 '17 at 06:44
  • you should look for hook before add to cart, however my account page only works for registered users, you should make registration before add to cart which can be done from 1st comment's link. you can also see this link for hook into before add to cart https://stackoverflow.com/questions/14428248/wordpress-woocommerce-action-hook-before-adding-to-cart – Noman Nov 23 '17 at 06:44

0 Answers0