vippsas/vipps-woocommerce

Express checkout page can’t be found

rafal-sokolowski opened this issue · 8 comments

WordPress 5.8.1
WooCommerce 5.7.1
Vipps for WooCommerce 1.7.13
no other plugins activated
Storefront 3.9.0

After updating Vipps for WooCommerce plugin from 1.7.9 to 1.7.10+, I get 404 when clicking on Vipps Hurtigkasse link.

The link is correct and it leads to /vipps-express-checkout/?sec=0263e62f55 but when clicked, it's being redirected to /vipps-express-checkout?sec=0263e62f55 (no slash before question mark) and this is what causes the problem.

The plugin itself does not do any redirects based on the trailing slash; could it be you have some other plugin or setting or .htaccess that does this?

As for the /-at-the-end-less URL, it could be supported for this case by changing line 2342 of Vipps.class.php from

if (preg_match("!/$special/([^/]*)!", $_SERVER['REQUEST_URI'], $matches)) {

to

if (preg_match("!/$special/?([^/]*)!", $_SERVER['REQUEST_URI'], $matches)) {

  • Are you able to check if this fixes the problem for your install?

There are no plugins activated except WooCommerce and Vipps for WooCommerce.

Here's my .htaccess file:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

When I change the line 2342 in Vipps.class.php to
if (preg_match("!/$special/?([^/]*)!", $_SERVER['REQUEST_URI'], $matches)) {
I no longer get 404 but it still redirects 301 and the page says Vipps er midlertidig utilgjengelig.

When I switch to Vipps for WooCommerce 1.7.9, everything works fine, no redirection.

The only change between 1.7.9 and 1.7.10 was a new cron event running every five minutes. Could you try to run with WP-cron disabled, with this in your wp-config

define('DISABLE_WP_CRON', true);

and see if the redirect still happens? Also if you have any other wp-cron related settings it'd be great if you could list them.

I have as yet not been able to replicate this.

This is the change that causes the issue:
d48db5d

However, I have no idea how it's possible that I didn't have it updated before, since it was modified in 1.7.5. I assume there should be no differences between Github and WordPress SVN repositories. I wasn't able to confirm that because the older versions are no longer available.

Anyway, when I remove the priority, it works fine.

It's also worth mentioning that I use a custom structure in permalinks:
https://playground.test/%postname%

Changing it to https://playground.test/%postname%/fixes the problem.

Ok, yes that explains the redirect. The priority in template-redirect is like that to come in before redirects caused by WPML and similar multilang type plugins; there is however a different redirect that happens when WP tries to pass the user to the 'canoncial' URL, which would try to strip the backslash. I'll have to dig a bit to fix this; thank you for your debugging here.

That's great! When do you think the fix could be released?

Should be fixed in next version, to arrive the coming monday.

If you need to test right now, modify Vipps.class.php in the template_redirect method:

   if ($special) {
            remove_filter('template_redirect', 'redirect_canonical', 10);
            do_action('woo_vipps_before_handling_special_page', $special);
            $this->$special();
        }
  • the main thing is that as this is a special page which we are handlng, the 'redirect canonical' filter should be disabled. You can also get the latest head from github, but be aware that it also contains some extra code for supporting some third-party plugins. It shouldn't break anything though.