woocommerce-paypal-payments/modules/ppcp-settings/resources/js/data/_example
2025-02-14 17:55:45 +01:00
..
action-types.js ♻️ Convert sample store to thunks 2025-02-05 16:26:52 +01:00
actions.js Create refresh actions for all stores 2025-02-14 17:55:45 +01:00
constants.js 🚚 Rename Redux template folder to _example 2025-01-13 16:27:53 +01:00
hooks.js ♻️ Provide cleaner sample for the store’s hooks 2025-02-05 16:27:19 +01:00
index.js ♻️ Convert sample store to thunks 2025-02-05 16:26:52 +01:00
README.md 🚚 Rename Redux template folder to _example 2025-01-13 16:27:53 +01:00
reducer.js ♻️ Rename reducer methods for better clarity 2025-01-21 15:33:03 +01:00
resolvers.js ♻️ Convert sample store to thunks 2025-02-05 16:26:52 +01:00
selectors.js 🚚 Rename Redux template folder to _example 2025-01-13 16:27:53 +01:00

Store template

This template contains all files for a Redux store.

New Store: Redux integration

  1. Copy this folder, give it a correct name.
  2. Check each file for <UNKNOWN> placeholders and TODO remarks.
  3. Edit the main store-index file and add the relevant store integration there.
  4. Check the debug-module, and add relevant debug code.
    • Register the store in the reset() method.

Main store-index: modules/ppcp-settings/resources/js/data/index.js

Sample store integration:

import * as YourStore from './yourStore';
// ...
YourStore.initStore();
// ...
export const YourStoreHooks = YourStore.hooks;
// ...
export const YourStoreName = YourStore.STORE_NAME;
// ...
addDebugTools( window.ppcpSettings, [ ..., YourStoreName ] );

New Store: PHP integration

  1. Create the REST endpoint for hydrating and persisting data.
    • modules/ppcp-settings/src/Endpoint/YourStoreRestEndpoint.php
    • Extend from base class RestEndpoint
  2. Create the data model class to manage the DB interaction.
    • modules/ppcp-settings/src/Data/YourStoreSettings.php
    • Extend from base class AbstractDataModel
  3. Create relevant DI services for both files.
    • modules/ppcp-settings/services.php
  4. Register the REST endpoint in the service module.
    • modules/ppcp-settings/src/SettingsModule.php
    • Find the action rest_api_init