Shipping by Km (Google API)



From March 1, 2025, the Distance Matrix API and Places API can no longer be enabled for new usage. You need to use Google’s new APIs: Routes API and Places API (New).

Please follow this guide to apply the new changes:

  1. If you upgrade WooCommerce Food from a version earlier than 3.4, you can continue using the old Google APIs which you have created, as they still support APIs created before March 1, 2025. However, it is strongly recommended to update your APIs.
  2. If you use WooCommerce Food version 3.4 or later, you can follow this guide to create the necessary APIs.

Step 1: Switch to New APIs: Routes & Place

  • Food Settings page > Shipping > Routes & Geocoding API > Switch to New APIs: Routes & Place > Yes > Save Changes

Step 2: Set Up a Google Cloud Project

  • Go to the Google Cloud Console.
  • Click on the Project Selector dropdown and select New Project.
  • Enter a name for your project (e.g., “My Maps Project”) and click Create.

Step 3: Enable Billing

  • In the Google Cloud Console, navigate to Billing.
  • Link your project to an existing billing account or create a new billing account.

Step 4: Enable Required APIs

  • Go to APIs & Services > Library in the Google Cloud Console.
  • Search for and enable the following APIs:
    • Maps JavaScript API
    • Routes API
    • Places API (New)
    • Geocoding API

Step 5: Generate an API Key for Maps JavaScript requests

  • Navigate to APIs & Services > Credentials.
  • Click on Create Credentials and select API Key.
  • Click on Edit API API key link
    • UnderApplication restrictions select Websites, then add your website URLs to restrict access.
    • UnderAPI restrictions select Restrict key Choose Maps JavaScript API and Places API (New) and Geocoding API.
    • Make sure your API setup like this: API 1
  • Save API
  • Copy the API and add it into Food Settings page > Shipping > Google API for JavaScript.

Step 6: Generate an API Key for Server Requests

  • Navigate to APIs & Services > Credentials.
  • Click on Create Credentials and select API Key.
  • Click on Edit API API key link
    • UnderApplication restrictions select IP addresses, then add your website IP addresses to restrict access.
    • UnderAPI restrictions select Restrict key Choose Routes API and Geocoding API and Places API (New).
    • Make sure your API setup like this: API 2
  • Save API
  • Copy the API and add it into Food Settings page > Shipping > Google API for Server Requests.
Was this page helpful?