List Square Locations

This standalone script connects to Square Locations API via cURL and returns existing locations on your account. This is helpful when the WooCommerce Square extension does not retrieve the locations, and web hosts claim that cURL is working as expected


$ch = curl_init();

curl_setopt( $ch, CURLOPT_URL, '' );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array( 'Authorization: Bearer PRODUCTION_ACCESS_TOKEN', 'Accept: application/json', 'Square-Version: 2021-04-21' ) );
curl_setopt( $ch, CURLOPT_TIMEOUT, 30 );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );

if ( curl_exec( $ch ) === false ) {
	echo 'Curl error: ' . curl_error( $ch );
} else {
	$data = json_decode( curl_exec( $ch ) );
	echo '<pre>';
	print_r( $data );
	echo '</pre>';

curl_close( $ch );


This is not a WordPress plugin, so please upload this script to the root directory of the site and access it directly:

For Production environment:

  • Replace PRODUCTION_ACCESS_TOKEN with the ACCESS token from your app at
  • You need to access the site > Open App > Toggle to production creds > Find the token here
The square production access token

For Sandbox environment:

  • If you’re testing with Sandbox, you’ll want to replace with
  • And also replace PRODUCTION_ACCESS_TOKEN in the script, with the Sandbox Access token instead
  • You can use the sandbox access token from Square settings page: WooCommerce > Settings > Square > Settings
  • Or, you can also use the creds from and grab the sandbox access token from there


If things work fine, you’ll see a list of Square locations and their details. If not, you’ll see the cURL error.

All cURL errors start with Curl error:. If you don’t see that, it means the error you’re seeing is returned by Square.


Leave a Reply

Your email address will not be published. Required fields are marked *