LogoLogo
Connectors
WooCommerce Extension 1.0
WooCommerce Extension 1.0
  • WooCommerce Extension 1.0
  • Introduction
    • Features and requirements
  • Install the extension
  • User guide
    • Mandatory WooCommerce settings
    • Tax
      • Display prices in the cart and checkout
    • Enable extension settings
    • Product Meta Fields module
      • Sync products to Digital River
    • Order checkout
    • Cancel an order
    • Refund the order
    • Tax and payments
  • Configure the extension
    • Configure general settings
    • Configure shipping zones
  • Support
  • Developer documentation
    • Modules
      • Logger module
      • Order Management module
      • Product Checkout module
      • Product Meta Fields module
      • Product Sync module
      • Settings module
      • Tax Calculation module
    • Translate the extension
Powered by GitBook
On this page
  • Core modules
  • Module interface
  • Method description
  • Register the custom module
  1. Developer documentation

Modules

Learn how to use modules.

PreviousDeveloper documentationNextLogger module

Last updated 3 years ago

Core modules

A module is a piece of program in a plugin that performs a particular task, or it can function with other modules. The WooCommerce plugin has seven core modules:

  • module

  • module

  • module

  • module

  • module

  • module

  • module

A module is a piece of program in a plugin that performs a particular task, or it can function with other modules.

Module interface

The module interface is for any module that needs to be registered with the plugin. Custom modules need to implement this interface for registration.

interface Module {
    /**
     * Initialization of module.
     *
     * @return void
     */
    public function init(): void;

    /**
     * Return module name.
     *
     * @return string
     */
    public function name(): string;
}

Method description

  • $module->name(): This method needs to return module name.

    The module name can be alphanumeric without spaces. Dashes and underscores are allowed.

  • $module->init(): Any actual work or initialization activity related to the module should go inside this method.

    Example: You can add any hooks or call necessary functions/methods inside init to run the module.

Do not explicitly call the init method. The plugin calls theinit method during module activation (under the hood).

Register the custom module

To register the custom module:

  1. Create the main module class that either implements the Module interface or extends the BaseModule abstract class. Since most of the modules will only be functioning when you enable the Digital River payment gateway, it makes sense to extend the BaseModule class.

  2. Add the module name by returning the name method to the Plugin::$active_modules list.

Logger
OrderManagement
ProductCheckout
ProductMetaFields
ProductSync
Settings
TaxCalculation