Closed Jon007 closed 6 years ago
In this case, I recommend the removal of the woo-poly Login.php, there is no need for this plugin to attempt to modify the login behaviour.
removal can be done quickly in various ways:
@hyyan what's the use case for this?
this will be broken again in 1.0.3 as the login code has been restored: this means when the client is logging in from an email to pay for an order for example, the login redirects to my account home page, instead of the order or payment page.
This is because the code is only looking up the link for the page (which is un-necessary) and does not know about the endpoint requested.
(There was also a related change in WooCommerce to fix the login direct to endpoint, this is now done.)
Ok, I got it, there's no translation for the endpoints in URLs so the login is maybe deliberately stripping the endpoint.
To solve, there's a missing filter which can be implemented like this in endpoints.php:
add_filter(
'woocommerce_get_endpoint_url', array($this, 'translateEndpoints'), 10, 4
);
/**
* Filter endpoint links in emails and menus to get correctly translated endpoint link
*
* @param string $endpoint
* @param string $value
* @param string $permalink
*
* @return string
*/
public function translateEndpoints($url, $endpoint, $value, $permalink)
{
$correctEndpoint = $this->getEndpointTranslation($endpoint);
if ($correctEndpoint!=$endpoint){
$url = str_replace($endpoint, $correctEndpoint, $url);
}
return $url;
}
Then for example if you want to add order links to emails, this code works whatever the order language:
echo($order->get_view_order_url()); ?>"><?php printf( __( 'Order #%s', 'woocommerce' ), $order->get_order_number() );
(as long as you also disable the login filter so it is possible to link through to the order after login)
It doesn't quite solve the @todo comment on links in menus, since the menu editor isn't aware of the language of the menu being edited....
quick note:
Hmmm , @Jon007 As far as I can remember this part exists since version 0.1
to allow login page translation, it was just as a workaround. But as the plugin has evolved a lot has been changed.
So you are right this part is not really required anymore.
Closing no need to invest time in this part
Steps to Reproduce
What I Expected
What Happened Instead
Actually the same problem exists in WooCommerce #15911, however woo-poly also filters woocommerce_login_redirect and getLoginRedirectPermalink() page look up causes redirects to the root page (eg the my-account page) instead of the requested endpoint.