Home Wordpress plugin does not redirect
Reply: 1

Wordpress plugin does not redirect

João Santana
João Santana Published in 2018-01-11 17:40:04Z

I am creating a plugin for woocommerce which sends a POST to a service then with response should redirect to another url

            $response = json_decode($result, true);

            if ($response != null || $response != "") {

                // TODO Check when we use other cryptocurrency
               // header("HTTP/1.1 304 Not Modified");
                header('Location: ' . $response['data']['url']."?cryptoCurrency=BTC", true, 301);

Locally this redirect works, but in production the request does not redirect. I receive a generic error syntaxerror: unexpected token < in Json at position 0 and a response with OPTIONS 204 as response, another with 301 and other with 200 (image link below).


I suppose there's something related to the server, but I really don't know what could it be.

Edit: the result has a valid url. It just doesn't redirect. In a response I am able to get the url and access via browser

João Santana
João Santana Reply to 2018-01-15 15:42:27Z

Khushboo, I fixed.

The problem was there's code above this redirect. So I put what was after code before it, then redirect like this:

            if($response != null || $response != "") {

               $checkout_url = $response['data']['url'] . "?cryptoCurrency=BTC";

               return array(
                 'result' => 'success',
                 'redirect' => $checkout_url
            return false;

The it solved. Just like magic =((((

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.327372 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO