WooCommerce Code Reference

WC_WCCOM_Site_Installer
in package

WC_WCCOM_Site_Installer Class

Contains functionalities to install products via WooCommerce.com helper connection.

Table of Contents

$default_state  : array
Default state.
$default_step_state  : array
Represents product step state.
$folder_exists  : string
Error message returned install_package if the folder already exists.
$install_steps  : array
Product install steps. Each step is a method name in this class that will be passed with product ID arg \WP_Upgrader instance.
get_state()  : array
Get the product install state.
install()  : mixed
Install a given product IDs.
reset_state()  : mixed
Reset product install state.
schedule_install()  : array
Schedule installing given list of products.
update_state()  : mixed
Update the product install state.
activate_plugin()  : WP_Error|null
Activate plugin given its product ID.
activate_product()  : WP_Error|null
Activate product given its product ID.
activate_theme()  : WP_Error|null
Activate theme given its product ID.
do_install_step()  : mixed
Perform product installation step.
download_product()  : WP_Error|string
Download product by its ID and returns the path of the zip package.
finish_installation()  : mixed
Finish installation by updating the state.
get_plugin_info()  : bool|array
Get plugin info
get_product_info()  : array|WP_Error
Get product info from its ID.
get_wporg_plugin_main_file()  : bool|string
Get WP.org plugin's main file.
get_wporg_product_dir_name()  : bool|string
Get installed directory of WP.org product.
install_product()  : mixed
Install a single product given its ID.
move_product()  : array|WP_Error
Move product to plugins directory.
unpack_product()  : WP_Error|string
Unpack downloaded product.

Properties

$default_step_state

Represents product step state.

private static array $default_step_state = array('download_url' => '', 'product_type' => '', 'last_step' => '', 'last_error' => '', 'download_path' => '', 'unpacked_path' => '', 'installed_path' => '', 'activate' => alse)

$install_steps

Product install steps. Each step is a method name in this class that will be passed with product ID arg \WP_Upgrader instance.

private static array $install_steps = array('get_product_info', 'download_product', 'unpack_product', 'move_product', 'activate_product')

Methods

get_state()

Get the product install state.

public static get_state([string $key = '' ]) : array
Parameters
$key : string = ''

Key in state data. If empty key is passed array of state will be returned.

Tags
since
3.7.0
Return values
arrayProduct install state.

install()

Install a given product IDs.

public static install(array $products) : mixed

Run via woocommerce_wccom_install_products hook.

Parameters
$products : array

Array of products where key is product ID and element is install args.

Tags
since
3.7.0
Return values
mixed

reset_state()

Reset product install state.

public static reset_state([array $products = array() ]) : mixed
Parameters
$products : array = array()

List of product IDs.

Tags
since
3.7.0
Return values
mixed

schedule_install()

Schedule installing given list of products.

public static schedule_install(array $products) : array
Parameters
$products : array

Array of products where key is product ID and element is install args.

Tags
since
3.7.0
Return values
arrayState.

update_state()

Update the product install state.

public static update_state(string $key, mixed $value) : mixed
Parameters
$key : string

Key in state data.

$value : mixed

Value.

Tags
since
3.7.0
Return values
mixed

activate_plugin()

Activate plugin given its product ID.

private static activate_plugin(int $product_id) : WP_Error|null
Parameters
$product_id : int

Product ID.

Tags
since
3.7.0
Return values
WP_Error|null

activate_product()

Activate product given its product ID.

private static activate_product(int $product_id) : WP_Error|null
Parameters
$product_id : int

Product ID.

Tags
since
3.7.0
Return values
WP_Error|null

activate_theme()

Activate theme given its product ID.

private static activate_theme(int $product_id) : WP_Error|null
Parameters
$product_id : int

Product ID.

Tags
since
3.7.0
Return values
WP_Error|null

do_install_step()

Perform product installation step.

private static do_install_step(int $product_id, array $install_args, string $step, WP_Upgrader $upgrader) : mixed
Parameters
$product_id : int

Product ID.

$install_args : array

Install args.

$step : string

Installation step.

$upgrader : WP_Upgrader

Core class to handle installation.

Tags
since
3.7.0
Return values
mixed

download_product()

Download product by its ID and returns the path of the zip package.

private static download_product(int $product_id, WP_Upgrader $upgrader) : WP_Error|string
Parameters
$product_id : int

Product ID.

$upgrader : WP_Upgrader

Core class to handle installation.

Tags
since
3.7.0
Return values
WP_Error|string

get_wporg_plugin_main_file()

Get WP.org plugin's main file.

private static get_wporg_plugin_main_file(string $dir) : bool|string
Parameters
$dir : string

Directory name of the plugin.

Tags
since
3.7.0
Return values
bool|string

get_wporg_product_dir_name()

Get installed directory of WP.org product.

private static get_wporg_product_dir_name(int $product_id) : bool|string
Parameters
$product_id : int

Product ID.

Tags
since
3.7.0
Return values
bool|string

install_product()

Install a single product given its ID.

private static install_product(int $product_id, array $install_args, WP_Upgrader $upgrader) : mixed
Parameters
$product_id : int

Product ID.

$install_args : array

Install args.

$upgrader : WP_Upgrader

Core class to handle installation.

Tags
since
3.7.0
Return values
mixed

move_product()

Move product to plugins directory.

private static move_product(int $product_id, WP_Upgrader $upgrader) : array|WP_Error
Parameters
$product_id : int

Product ID.

$upgrader : WP_Upgrader

Core class to handle installation.

Tags
since
3.7.0
Return values
array|WP_Error

unpack_product()

Unpack downloaded product.

private static unpack_product(int $product_id, WP_Upgrader $upgrader) : WP_Error|string
Parameters
$product_id : int

Product ID.

$upgrader : WP_Upgrader

Core class to handle installation.

Tags
since
3.7.0
Return values
WP_Error|string