Ecommerce Shopify WordPress Discussion

What is the reason for the back button not working from the login page and the interference in the performance with this scenario?

I'm using this function for my WooCommerce shop checkout page... if the user goes to checkout. redirect to the login page and after login, redirect to checkout to place the order. add_action('template_redirect', 'check_if_logged_in'); function check_if_logged_in() { if ( ! is_user_logged_in() && is_checkout() ) { $url = site_url('/checkout/?login=true&page=1&redirect_to=https://mysitedomain.com/checkout/'); wp_redirect( $url ); exit; } } This code works well but my problem is if the user is in the login form He will regret it and will not log in. If he clicks on the back button. It stays on the same page! And it is not transferred to the settlement page! In fact, it is transmitted first. But because there is a condition on the payment page that if there is no login, it will be directed to the login page, that's why the back button doesn't work. And it seems that it stays on the same page and there is no request to enter the previous page. This button works everywhere because other previous pages (any page of the site) do not have such a condition and only the payment page has this condition. Therefore, the payment button does not work if the user enters the login page from the payment page, does not log in there, and clicks back. I think there is a need for another function and another condition. The back button is the same everywhere unless it has come from the checkout page to the login page. In that case, the back button must have a different condition, for example, the link of the back page should be to the shopping cart page instead of the previous page that has been accessed, and the link of the back button can be set to the shopping cart link (the step before entering the payment page) Maybe this will help (this is for the back button) receive from inspecting <div class="digits-cancel dig_login_cancel" title="Go Back" data-back="//mysitedomain.com/cart/?page=1&redirect_to=https%3A%2F%2Fmysitedomain.com%2Fcart%2F"></div> I want to change the back button link to {mysitedomain.com/cart} in the login page (if only from the checkout and up function I send for you to the login page) I tried this for it but don't work and don't know if this is the correct way or not? And whether there is a better way or not. add_action('template_redirect', 'check_if_logged_in'); function check_if_logged_in() { if ( ! is_user_logged_in() && is_checkout() ) { $url = site_url('/checkout/?login=true&page=1&redirect_to=https://mysitedomain.com/checkout/'); wp_redirect( $url ); exit; } } // Modify the back button link in your HTML $back_button_link = is_checkout() ? esc_url(site_url('/cart')) : '//mysitedomain.com/cart/?page=1&redirect_to=https%3A%2F%2Fmysitedomain.com%2Fcart%2F'; ?> <div class="digits-cancel dig_login_cancel" title="Go Back" data-back="<?php echo $back_button_link; ?>"></div>
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.