Wordpress_intergration

1. Prerequisites

WooCommerce 3.5+.

WordPress 4.4+.

Dokan 2.8+

2. Wordpress Components (New)

├── pages
   ├── ...
   ├── account
   ├── blog
   ├── shop
   ├── index.jsx
├── wp-components
   ├── account
   ├── blog
   ├── elements
      ├── posts
      ├── products
         ├── ...
         ├── WPProduct.jsx
   ├── homepage
   ├── ...
├── utilities
   ├── WPhelpers.js
├── repositories
   ├── WP
      ├── WPPostRepository.js
      ├── WPProductRepository.js
      ├── WPRespository.js
      ├── WPVendorRepository.js
├── store
   ├── wp
      ├── action.js
      ├── reducer.js
      ├── saga.js

For wordpress, we used elements in wp-components

3. Data feching

3.1 Get data

NOTED: From now, we used React Hook instead. Please refer: React Hooks documentarrow-up-right

For example, if you want to get data for a section, do the following:

WPProductRepository.getProducts(queries) will send a request to Wordpress server, then receive the data.

In WPProductRepository, It used some enpoint, like this: 'wp-json/wc/v3/products'

It's Woocomerce parameters. You can refer it in Woocomerce API Documentarrow-up-right

3.2 Change API URL:

To change your server information, you need to edit it in the file: repositories/WPRespository.js, then change:

export const WPDomain = 'https://yourdomain.com';

Currently, we use basicAuth, it need usename/password. For generate it, please refer: Woocomerce API Authenticationarrow-up-right

4. Vendor with Dokan

Similar as Wordpress, please Dokan API document:

Dokan API Authenticationarrow-up-right

Last updated