Prestashop REST API Integartion
API Details:
PrestaShop provides a powerful CRUD-based Web Service API that allows third-party tools and applications to securely access and manage store data. Built on REST architecture, the API is designed for maximum compatibility across platforms by utilizing standard HTTP methods along with XML or JSON data formats. This ensures seamless integration with a wide range of systems, enabling developers to perform operations such as creating, reading, updating, and deleting resources within the PrestaShop database efficiently.
Get Prestashop order details:
In this step, we’ll use cURL requests with PrestaShop API endpoints to fetch order-related data, including order details, customer information, and customer addresses. This allows us to collect all necessary order data for exporting to a WooCommerce store. With this integration, real-time synchronization can be achieved—ensuring that as soon as an order is received in PrestaShop, it’s automatically exported and created in the connected WooCommerce store.
API Endpoints:
- Get Orders
- Get Customer Details
- Get Customer addresses
1- Get Orders:
Curl request-1: Get Prestashop Order ID’s
In order to get prestashop api orders id’s we will use api endpoint “/api/orders” with some additional paramTo retrieve the list of order IDs from the PrestaShop API, we’ll use the /api/orders endpoint along with optional parameters such as date ranges and output format (XML or JSON). These filters help us fetch only the relevant orders—for example, orders placed within a specific timeframe—making the data extraction more efficient and suitable for syncing with external platforms like WooCommerce.
// PrestaShop API endpoint (replace with your store's domain)
$prestashop_url = 'https://www.examplesite.com';
// Your PrestaShop API key
$api_key = 'api key here';
// Get today's date in the format PrestaShop uses
$start_date = "starting from date"; //2025-01-14
$end_date = "ending date"; //2025-02-20
// Prepare the URL for fetching orders created today
$order_url = $prestashop_url . '/api/orders?filter[date_add]=[' .
urlencode($start_date . ' 00:00:00') . ',' . urlencode($end_date . ' 23:59:59')
.']&date=1&output_format=JSON';
// cURL setup for fetching order IDs
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $order_url); // URL to the orders endpoint
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Return the response as a string
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Basic ' . base64_encode($api_key . ':')
));
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Execute the cURL request
$response = curl_exec($ch);
// Check for errors
if (curl_errno($ch)) {
echo 'Curl error: ' . curl_error($ch);
exit;
}
// Close the cURL session
curl_close($ch);
Curl request-2: Get Prestashop Order Details
To fetch detailed order information from the PrestaShop API, we’ll use the /api/orders endpoint with additional parameters, such as the desired output format (e.g., JSON or XML). This request returns complete order data including product details, quantities, payment status, and more—essential for exporting or syncing with platforms like WooCommerce.
// PrestaShop API endpoint (replace with your store's domain)
$prestashop_url = 'https://www.examplesite.com';
// Your PrestaShop API key
$api_key = 'api key here';
$order_detail_url = $prestashop_url . "/api/orders/$order_id?output_format=JSON";
// Fetch detailed order information
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $order_detail_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Basic ' . base64_encode($api_key . ':')
));
$order_response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Curl error: ' . curl_error($ch);
exit;
}
curl_close($ch);
2- Get Customer Details: Get Prestashop Customers
To retrieve customer details from PrestaShop, we use the /api/customers/ endpoint along with the specific customer ID obtained from the previous order details request. This allows us to access customer-related information such as name, email, and registration date—data that’s essential for accurately syncing orders and customer records with the WooCommerce store.
// PrestaShop API endpoint (replace with your store's domain)
$prestashop_url = 'https://www.examplesite.com';
// Your PrestaShop API key
$api_key = 'api key here';
$order_detail_url = $prestashop_url . "/api/customers/$cust_id?
output_format=JSON";
// Fetch detailed order information
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $order_detail_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Basic ' . base64_encode($api_key . ':')
));
$order_response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Curl error: ' . curl_error($ch);
exit;
}
curl_close($ch);
3- Get Prestashop Customer addresses
To obtain the customer’s billing and shipping addresses, we’ll use the /api/addresses endpoint. By passing the customer ID or address ID (retrieved from the order or customer data), we can fetch complete address details including street, city, postcode, country, and more. This information is crucial for creating accurate order exports and ensuring proper fulfillment when syncing orders to the WooCommerce store.
//PrestaShop API endpoint (replace with your store's domain)
$prestashop_url = 'https://www.examplesite.com';
//Your PrestaShop API key
$api_key = 'api key here';
$order_detail_url = $prestashop_url . "/api/addresses
filter[id_customer]=$cust_id&display=full&output_format=JSON";
//Fetch detailed order information
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $order_detail_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Basic ' . base64_encode($api_key . ':')
));
$order_response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Curl error: ' . curl_error($ch);
exit;
}
curl_close($ch);
Create Woocommerce order:
After retrieving all necessary data from PrestaShop using the API endpoints, we proceed to create orders in WooCommerce using the native wc_create_order() function. This function returns a new WooCommerce order ID, which we then use to add order items, assign the customer using their ID, set billing and shipping addresses, apply order totals, and include any additional metadata required.
If you’re looking for a complete solution, we’ve developed a custom plugin that automates the import and synchronization of PrestaShop orders with your WooCommerce store. Feel free to contact us if you’d like to get the plugin or need help with a tailored integration setup.