WooCommerce Code Reference

Package
in package

Main package class.

Returns information about the package and handles init.

In the context of this plugin, it handles init and is called from the main plugin file (woocommerce-gutenberg-products-block.php).

In the context of WooCommerce core, it handles init and is called from WooCommerce's package loader. The main plugin file is not loaded.

Tags
since
2.5.0

Table of Contents

container()  : mixed
Loads the dependency injection container for woocommerce blocks.
feature()  : FeatureGating
Returns an instance of the FeatureGating class.
get_path()  : string
Return the path to the package.
get_version()  : string
Return the version of the package.
init()  : mixed
Init the package - load the blocks library and define constants.
get_package()  : Package
For back compat this is provided. Ideally, you should register your class with Automattic\Woocommerce\Blocks\Container and make Package a dependency.

Methods

container()

Loads the dependency injection container for woocommerce blocks.

public static container([bool $reset = false ]) : mixed
Parameters
$reset : bool = false

Used to reset the container to a fresh instance. Note: this means all dependencies will be reconstructed.

Return values
mixed

feature()

Returns an instance of the FeatureGating class.

public static feature() : FeatureGating
Return values
FeatureGating

get_path()

Return the path to the package.

public static get_path() : string
Return values
string

get_version()

Return the version of the package.

public static get_version() : string
Return values
string

init()

Init the package - load the blocks library and define constants.

public static init() : mixed
Tags
since
2.5.0

Handled by new NewPackage.

Return values
mixed

get_package()

For back compat this is provided. Ideally, you should register your class with Automattic\Woocommerce\Blocks\Container and make Package a dependency.

protected static get_package() : Package
Tags
since
2.5.0
Return values
PackageThe Package instance class