You can use wordpress referrer function.
For example set referrer URL in session by clicking on add to cart button or any button to store previous URL. Once login or register success add Woocommerce success login redirect to that URL.
For more information read WordPress referrer URL read here;
https://codex.wordpress.org/Function_Reference/wp_get_referer
For Woocommerce login redirect read here;
https://stackoverflow.com/questions/29342186/woocommerce-after-login-redirect
Related Posts:
- Woocommerce Login Redirect not working [closed]
- Redirect user after login through woocommerce login page to page with his/her username?
- How to check if is in cart page? [closed]
- 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 not working on the first try
- 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 – Redirect to a product after login
- Woocommerce, prevent login after registration and redirect to custom URL
- Woocommerce Login Redirect to old domain
- Redirect no product url’s to static url
- WooCommerce Registration redirect based on page ID
- wordpress/woocommerce login url not redirecting correctly
- WooCommerce get_author_posts_url() – Author URL redirecting to shop base
- Anonymous users can not access website
- 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
- How to use woo commerce login to authenticate code php pages?
- mydomain.com/wp-login redirects to wordpress.com/wp-login
- Woocommerce login to specific page or referrer
- WooCommerce shop, my account, cart every page redirect to home page [closed]
- How to change redirect code? [duplicate]
- Login page so wide [closed]
- Remove login fields from /customer-account page [closed]
- Account Status/Login on Main Menu with Avatar Pictures
- get woocommerce My account page link
- Where do the cart details are stored in database?
- wordpress custom login successful redirect hook
- Hide income in Woocomercer [closed]
- How do you add custom metadata to WooCommerce orders? Specifically a second external order ID
- Hide tabs on woocommerce product editor for user role
- Woocommerce add_to_cart non-register visitor not working
- WooCommerce: The model of e-mail is displaying only the html, not css [closed]
- How to show loading spinner after click on add to cart button [closed]
- Woocommerce redirect thankyou page based on product ID doesn’t empty Cart
- Authenticate user into wordpress via 3rd party system, both with the same domain
- Arranging Product Details on Shop Page
- How to get woocommerce subscription next payment date or date when subscription expires in woocommerce_subscription_renewal_payment_complete hook?
- Display Message if woocommerce coupon is not applicable to some items in the cart
- (Woocommerce) How to add a custom page between cart and checkout with a file upload field per product item in the cart?
- Force uppercase on some WooCommerce checkout fields input
- Display custom field without plugin in woocommerce
- How to output php between header and woocommerce container
- WooCommerce – How can I make single product gallery show two images on the slider at once?
- How can I force the user to log in, even if they’re already authenticated?
- How to delete all customer user account that haven’t placed a single order?
- How do I hide ‘out of stock’ products in the admin ‘product’ page?
- Hide the prefix before the price of the product [closed]
- Show add to cart button and quantity field when no price is entered [closed]
- How to get woocommerce product collection in template file
- Custom form redirect after login
- Results not being printed
- Remove ‘product’ & ‘product-cateogory’ from url – woocommerce [closed]
- Is there a hook in woocommerce for when a payment fails to display a custom error message?
- How to show notice alert only on product dashboard page?
- Retrieving Tag Name in Template Part from Filtered URL
- ajax request in wordpress
- Woocommerce product rewrite rules not working
- How to display a table below each product in product list/loop
- Extra items added to cart on refresh, woocommerce
- How disable some product features on woocomerce?
- WooCommerce – Split Multiple Items into Individual Line Items
- Change “Select Options” label in button to “Buy Now!” in store page
- Woocommerce: Any way to list all products *without* a specific attribute?
- porto theme pagination on woocommerce not working
- Adding preference buttons to main nav that persist via user sessions. (Woocommerce)
- Woocommerce custom log in and register
- CallBack URL for payment gateway redirecting to homepage instead of executing callback function
- Display when items are in Woocommerce cart but hide when empty
- Printing product variation return array to string conversion error
- woocommerce deposit Form with AJAX and shortcode won’t update but add to previous output
- How to get cookie value?
- Woocommerce Disabling Auto Restocking for Cancelled Orders
- Custom pagination permalink structure Product page
- Woocommerce modifying the html on the checkout page?
- Pseudo class :before don’t working in a specific button
- How to speed up “My Account > Orders Page” on Site with More than 200,000 orders?
- Editing product categories suddenly crashes website and goes back to wordpress installation
- WooCommerce product id as permalink
- Merge “description” and “additional informations” product tab
- I need to refresh the checkout page if someone changes the zip code
- Get user active posts randomly
- Website Tablet Check Out Field Issue
- WooCommerce order created via REST – sending the date_created along
- Get Third Level Categories WooCommerce
- Change wp-login.php? Problem with .htaccess password protection and multi user shop
- Show pop up message for specific categoryies
- How to remove content from hacked pages? [closed]
- Disable WooCommerce Address State Dropdown
- How to show detailed order history on woocommerce product page [closed]
- Can I remove WooCommerce specific product categories from shop managers?
- Fetch products with filter by similar categories at same time
- Trying query woocommerce product order by menu order and stock status
- editing product page template – getting template for related products not working
- Disable Woocommerce Block Editor
- Woocommerce backend sorting product drag drop by menu_order to date