LogoLogo
Homepage
  • Documentations for PrestaShop 1.4
  • English documentation 1.4
    • Getting Started
    • Updating PrestaShop
    • User Guide
      • Training
      • Customizing your shop
      • Browsing the front-office
      • Connecting to the PrestaShop back-office
      • Adding Products and Product Categories
      • A Look inside the Catalog
      • Managing Customers
      • Managing Orders
      • Managing Payment Methods
      • Managing Shipping
      • Understanding Statistics
      • Managing Modules
      • Managing Employees
      • Understanding the Preferences
      • Exploring PrestaShop's Tools
      • PrestaShop Support
    • System Administrator Guide
    • Developer Guide
      • Developer tutorials
        • Using the REST webservice
          • Chapter 1 - Creating Access to Back Office
          • Chapter 2 - Discovery - Testing access to the web service with the browser
          • Chapter 3 - First steps - Access the Web service and list client
            • 3.1 - Access the web service
            • 3.2 - Handling errors
            • 3.3 - List clients
          • Chapter 4 - Retrieve Data - Retrieving a Client
          • Chapter 5 - Modification - Update client
          • Chapter 6 - Creation - Remote Online Form
          • Chapter 7 - Removal - Remove customer accounts from the database
          • Chapter 8 - Advanced Use
          • Cheat-sheet - Concepts outlined in this tutorial
        • Understanding and using hooks
        • Synchronization via Hooks
        • Modules, Classes and Controller Override
        • Modules, Override, Web Service
        • Db class good practices for Prestashop 1.4
        • Carrier modules - functions, creation and configuration
        • Creating your own payment module
        • Accelerated Security Course - Episode 1 - Never Trust Foreign Data
        • Accelerated Security Course - Episode 2 - SQL Injections
        • Accelerated Security Course - Episode 3 - XSS
        • Accelerated Security Course - Episode 4 - CSRF
      • Fundamentals
      • Creating a PrestaShop module
      • Development standard
      • Public and overloadable methods
      • Web-service reference
      • How to use the forge to contribute to PrestaShop
      • Rocky's guides
        • PrestaShop 1.4.3 Development Guide
          • Architecture
          • Overriding Files
          • Creating Modules
          • Cookie Structure
          • Database Structure
        • PrestaShop 1.4.3 Performance Guide
    • Designer Guide
      • Coding a theme
      • Design tips
      • Implementing layered navigation in a theme
    • Troubleshooting
    • FAQ
    • User contributions
    • Documentation PDFs
  • Documentation franƧaise 1.4
    • Guide de dĆ©marrage
    • Mettre Ć  jour PrestaShop
    • Guide de l'utilisateur
      • Formation
      • Personnaliser votre boutique
      • Se connecter au back-office de Prestashop
      • Ajouter des produits et des catĆ©gories de produits
      • Un aperƧu du catalogue
      • GĆ©rer les clients
      • GĆ©rer les commandes
      • GĆ©rer les mĆ©thodes de paiement
      • GĆ©rer le transport
      • Comprendre les statistiques
      • GĆ©rer les modules
      • GĆ©rer les employĆ©s
      • Comprendre les prĆ©fĆ©rences
      • Explorer les outils de PrestaShop
      • Obtenir de l'aide
    • Guide de l'administrateur systĆØme
    • Guide du dĆ©veloppeur
      • Fondamentaux
      • CrĆ©er un module PrestaShop
      • Tutoriels pour dĆ©veloppeurs
        • Tutoriel Webservice REST
          • Chapitre 1 - Mise en place - CrĆ©ation des accĆØs dans le Back Office
          • Chapitre 2 - DĆ©couverte - Tester l'accĆØs au service web avec le navigateur
          • Chapitre 3 - Premiers pas - AccĆ©der au service web et lister les clients
            • 3.1 AccĆ©der au service web
            • 3.2 Gestion des erreurs
            • 3.3 Lister les clients
          • Chapitre 4 - RĆ©cuperer des donnĆ©es : RĆ©cupĆ©rer un client
          • Chapitre 5 - Modification : Mettre Ć  jour un client
          • Chapitre 6 - CrĆ©ation : Formulaire d'ajout Ć  distance
          • Chapitre 7 - Suppression : Retirer des comptes client de la base
          • Chapitre 8 – Utilisation avancĆ©e
          • Chapitre 9 - Gestion des images
          • Chapitre 10 - Gestion des prix
          • MĆ©mento : Notions Ć©noncĆ©es dans ce tutoriel
        • Mieux comprendre et utiliser les hooks
        • La synchronisation via les Hooks
        • Surcharge et override
        • Modules, surcharge, web service
        • Les bonnes pratiques de la classe Db sur Prestashop 1.4
        • Les modules transporteurs - fonctionnement, crĆ©ation, configuration
        • Cours de sĆ©curitĆ© accĆ©lĆ©rĆ© no. 1 - Never trust foreign data
        • Cours de sĆ©curitĆ© accĆ©lĆ©rĆ© no. 2 - Injections SQL
        • Cours de sĆ©curitĆ© accĆ©lĆ©rĆ© no. 3 - XSS
        • Cours de SĆ©curitĆ© accĆ©lĆ©rĆ© no. 4 - CSRF
    • Guide du designer
      • Conseils en design
      • CrĆ©er un thĆØme
    • Guide du Vendeur
    • Import Wiki FR
      • DĆ©pannage
        • Changer la taille maximum de tĆ©lĆ©chargement de fichiers
        • Comment ajouter une page Ć  PrestaShop
        • GĆ©nĆ©rer le fichier .htaccess par Prestashop pour avoir des URLs simplifiĆ©es
        • GĆ©nĆ©rer un nouveau mot de passe manuellement
        • Import CSV
        • Personnalisation des mails clients
        • ProblĆØme d'allocation mĆ©moire chez 1&1
        • ProblĆØme pour se connecter aprĆØs avoir effacĆ© une langue
        • Votre site ne rĆ©pond plus, une page blanche s’affiche
      • FidĆ©liser les Clients
      • Gestion des Taxes
      • Installer Un Module
      • Sauvegarder votre Base de DonnĆ©es
    • PDF de la documentation
    • Contributions des utilisateurs
    • Questions frĆ©quentes
  • Documentación espaƱola 1.4
    • Introducción
    • Actualización de PrestaShop
    • GuĆ­a de Usuario
      • Entrenamiento
      • Personalización de su tienda
      • Exploración del front-office
      • Conexión al back-office PrestaShop
      • AƱadir Productos y CategorĆ­as de Productos
      • Una Mirada Dentro del CatĆ”logo
      • Gestión de Clientes
      • Gestión de Pedidos
      • Gestión de MĆ©todos de Pago
      • Gestión de EnvĆ­o
      • Comprensión de las EstadĆ­sticas
      • Gestión de Módulos
      • Gestión de Empleados
      • Comprensión de Preferencias
      • Exploración de las herramientas de PrestaShop
      • Soporte PrestaShop
    • GuĆ­a del Administrador del Sistema
    • GuĆ­a del Desarrollador
      • Aspectos Fundamentales
      • Creación de un módulo de PrestaShop
      • EstĆ”ndares de desarrollo
      • Manuales de desarrollador
        • Utilización del servicio web REST
          • CapĆ­tulo 1 - Creación de Acceso al Back Office
          • CapĆ­tulo 2 - Descubrimiento - Pruebas de acceso al servicio web con el navegador
          • CapĆ­tulo 3 - Primeros pasos - Acceso al servicio Web y lista de clientes
            • 3.1 - Acceso al servicio web
            • 3.2 - Manejo de errores
            • 3.3 - Enumeración de clientes
          • CapĆ­tulo 4 - Recuperación de datos - Recuperación de un cliente
          • CapĆ­tulo 5 - Modificación - Actualización de cliente
          • CapĆ­tulo 6 - Creación - Formulario En LĆ­nea Remoto
          • CapĆ­tulo 7 - Eliminación - Eliminar cuentas de clientes de la base de datos
          • CapĆ­tulo 8 - Uso avanzado
        • Comprensión y uso de hooks
        • Sincronización a travĆ©s de Hooks
        • Módulos, Reemplazo, Servicio Web
        • Módulos, Clases y Reemplazo del Controlador
        • Buenas prĆ”cticas de Clase DB para Prestashop 1.4
        • Módulos de transportistas - funciones, creación y configuración
        • Curso Acelerado de Seguridad - Episodio 1 - Nunca ConfĆ­e en Datos Exteriores
        • Curso Acelerado de Seguridad - Episodio 2 - Inyecciones SQL
        • Curso Acelerado de Seguridad - Episodio 3 - XSS
        • Curso Acelerado de Seguridad - Episodio 4 - CSRF
      • Referencia del servicio web
    • GuĆ­a de DiseƱador
      • Codificación de un tema
      • Consejos de DiseƱo
    • Solución de problemas
    • Preguntas Frecuentes
Powered by GitBook
On this page

Was this helpful?

  1. English documentation 1.4
  2. Developer Guide
  3. Developer tutorials
  4. Using the REST webservice

Chapter 7 - Removal - Remove customer accounts from the database

Objective: A Web application for listing and deleting customers. Difficulty: *

Preparation

Duplicate file list_the_clients.php from Section 3.3 to a file named D-CRUD.php at the root of your Web server.

For this last part, we will learn how to delete a resource.

Here is the complete, detailed call you need to remove a client:

try {
  $webService = new PrestaShopWebservice( '[http://mystore.com/|http://mystore.com/]' , 'ZR92FNY5UFRERNI3O9Z5QDHWKTP3YIIT' , false ); // Create an instance{color}
  $opt[ 'resource' ] = 'customers';          // Resource to use{color}
  $opt[ 'id' ] = 3;                          // ID to use{color}
  $webService->delete( $opt );               // Delete{color}
  echo 'Client '.3.' successfully deleted!'; // If we can see this message then that means that we have not left the try block
}
catch (PrestaShopWebserviceException $ex) {
  $trace = $ex->getTrace();                // Recuperate all info on this error
  $errorCode = $trace[ 0 ][ 'args' ][ 0 ]; // Recuperate error code 
  if ( $errorCode == 401 ) 
    echo 'Bad auth key';   
  else 
    echo 'Other error : <br />'.$ex->getMessage(); 
  // Display error message{color}
}

This code allows you to remove a customer whose ID is "3". As you can see, deleting the customer differs only slightly from retrieving a resource. In fact the only thing different in the code lies in the method called: We will no longer call this method "get" but instead simply "delete"!

You must now replace the customer ID by a dynamically-defined ID.

Now create all the script that will display a list of customer IDs and delete a customer of your choice.

Again, if you have trouble, look at the code for 4-delete.php.

PreviousChapter 6 - Creation - Remote Online FormNextChapter 8 - Advanced Use

Last updated 4 years ago

Was this helpful?