Frequently Asked Questions

⌘K
  1. Home
  2. Docs
  3. Frequently Asked Question...
  4. Errors
  5. Why do I get a network error when submitting an order?

Why do I get a network error when submitting an order?

If you are able to connect to your store, but receive a network error when submitting an order, there might be a server configuration preventing the request from being sent or possibly some other error that occurred in your WordPress back-end.

To check whether there was a WordPress error causing the connection to fail, you can open your WordPress admin dashboard and navigate to WooCommerce -> Status -> Logs and view the latest fatal error log by selecting it from the dropdown. Here you should be able to see if there are any errors related to FooSales or possibly a conflict with another plugin. If there are no errors or nothing that seems related to FooSales, then there might be a server configuration preventing the request from being sent.

FooSales connects to your store from a domain that is different from your domain (https://web.foosales.com). Requests between different domains are known as cross-origin resource sharing requests (CORS). Your server will need to specifically allow these types of requests. Normally servers are already setup to accept these requests and return the response with the appropriate headers, but some servers might be configured to block them. Your browser will prevent the request from completing if the response does not have the required headers.

Your server needs to return an Access-Control-Allow-Origin header that allows FooSales to post data to your store. You can try adding the following code to your WordPress theme’s functions.php file to see if it makes a difference:

function add_foosales_cors_http_header(){
    header("Access-Control-Allow-Origin: https://web.foosales.com");
}
add_action('init','add_foosales_cors_http_header');

You can try using either https://web.foosales.com or simply * (an asterisk which allows any origin) as the origin value.

If the above code doesn’t work, you should be able to see whether or not this header is enabled and what its value is if you have access to your server configuration. You can also contact your server admin or web host to ask about allowing cross-domain REST API requests for FooSales. Some browsers also have settings that you can tweak to allow these requests for FooSales. Alternatively, you can use a proxy server that ensures that all the correct headers are set and returned between your website and FooSales.

Tags , , , , , , , , , , , ,