WooCommerce
in package
Uses
AccessiblePrivateMethods
Main WooCommerce Class.
Tags
Table of Contents
- $api : WC_API
- API instance
- $cart : WC_Cart
- Cart instance.
- $countries : WC_Countries
- Countries instance.
- $customer : WC_Customer
- Customer instance.
- $db_version : string
- WooCommerce Schema version.
- $deprecated_hook_handlers : array<string|int, mixed>
- Array of deprecated hook handlers.
- $integrations : WC_Integrations
- Integrations instance.
- $order_factory : WC_Order_Factory
- Order factory instance.
- $product_factory : WC_Product_Factory
- Product factory instance.
- $query : WC_Query
- Query instance.
- $session : WC_Session|WC_Session_Handler
- Session instance.
- $structured_data : WC_Structured_Data
- Structured data instance.
- $version : string
- WooCommerce version.
- $_instance : WooCommerce
- The single instance of the class.
- __clone() : mixed
- Cloning is forbidden.
- __construct() : mixed
- WooCommerce Constructor.
- __get() : mixed
- Auto-load in-accessible properties on demand.
- __wakeup() : mixed
- Unserializing instances of this class is forbidden.
- activated_plugin() : mixed
- Ran when any plugin is activated.
- add_image_sizes() : mixed
- Add WC Image sizes to WP.
- add_woocommerce_inbox_variant() : mixed
- Add woocommerce_inbox_variant for the Remote Inbox Notification.
- add_woocommerce_remote_variant() : mixed
- Add woocommerce_remote_variant_assignment used to determine cohort or group assignment for Remote Spec Engines.
- ajax_url() : string
- Get Ajax URL.
- api_request_url() : string
- Return the WC API URL for a given request.
- build_dependencies_notice() : void
- Output a admin notice when build dependencies not met.
- build_dependencies_satisfied() : bool
- Check if plugin assets are built and minified
- call_function() : mixed
- Call a user function. This should be used to execute any non-idempotent function, especially those in the `includes` directory or provided by WordPress.
- call_static() : mixed
- Call a static method in a class. This should be used to execute any non-idempotent method in classes from the `includes` directory.
- checkout() : WC_Checkout
- Get Checkout Class.
- convert_woocommerce_slug() : string
- Converts the WooCommerce slug to the correct slug for the current version.
- deactivated_plugin() : mixed
- Ran when any plugin is deactivated.
- frontend_includes() : mixed
- Include required frontend files.
- get_global() : mixed
- Gets the value of a global.
- get_instance_of() : object
- Gets an instance of a given legacy class.
- include_template_functions() : mixed
- Function used to Init WooCommerce Template Functions - This makes them pluggable by plugins and themes.
- includes() : mixed
- Include required core files used in admin and on the frontend.
- init() : mixed
- Init WooCommerce when WordPress Initialises.
- init_jetpack_connection_config() : void
- Initiali Jetpack Connection Config.
- initialize_cart() : void
- Initialize the customer and cart objects and setup customer saving on shutdown.
- initialize_session() : void
- Initialize the session class.
- instance() : WooCommerce
- Main WooCommerce Instance.
- is_rest_api_request() : bool
- Returns true if the request is a non-legacy REST API request.
- is_store_api_request() : bool
- Returns true if the request is a store REST API request.
- is_wc_admin_active() : bool
- Is the WooCommerce Admin actively included in the WooCommerce core? Based on presence of a basic WC Admin function.
- load_plugin_textdomain() : mixed
- Load Localisation files.
- load_rest_api() : mixed
- Load REST API.
- log_errors() : mixed
- Ensures fatal errors are logged so they can be picked up in the status report.
- mailer() : WC_Emails
- Email Class.
- on_plugins_loaded() : mixed
- When WP has loaded all plugins, trigger the `woocommerce_loaded` hook.
- payment_gateways() : WC_Payment_Gateways
- Get gateways class.
- plugin_path() : string
- Get the plugin path.
- plugin_url() : string
- Get the plugin url.
- queue() : WC_Queue_Interface
- Get queue instance.
- setup_environment() : mixed
- Ensure theme and server variable compatibility and setup image sizes.
- shipping() : WC_Shipping
- Get shipping class.
- template_path() : string
- Get the template path.
- wpdb_table_fix() : mixed
- Set tablenames inside WPDB object.
- add_thumbnail_support() : mixed
- Ensure post thumbnail support is turned on.
- define() : mixed
- Define constant if not already set.
- define_constants() : mixed
- Define WC Constants.
- define_tables() : mixed
- Register custom tables within $wpdb object.
- init_hooks() : mixed
- Hook into actions and filters.
- is_request() : bool
- What type of request is this?
- load_webhooks() : mixed
- Load & enqueue active webhooks.
- register_wp_admin_settings() : mixed
- Register WC settings from WP-API to the REST API.
- theme_support_includes() : mixed
- Include classes for theme support.
Properties
$api
API instance
public
WC_API
$api
Tags
$cart
Cart instance.
public
WC_Cart
$cart
=
ull
$countries
Countries instance.
public
WC_Countries
$countries
=
ull
$customer
Customer instance.
public
WC_Customer
$customer
=
ull
$db_version
WooCommerce Schema version.
public
string
$db_version
= '430'
Tags
$deprecated_hook_handlers
Array of deprecated hook handlers.
public
array<string|int, mixed>
$deprecated_hook_handlers
= array()
$integrations
Integrations instance.
public
WC_Integrations
$integrations
=
ull
$order_factory
Order factory instance.
public
WC_Order_Factory
$order_factory
=
ull
$product_factory
Product factory instance.
public
WC_Product_Factory
$product_factory
=
ull
$query
Query instance.
public
WC_Query
$query
=
ull
$session
Session instance.
public
WC_Session|WC_Session_Handler
$session
=
ull
$structured_data
Structured data instance.
public
WC_Structured_Data
$structured_data
=
ull
$version
WooCommerce version.
public
string
$version
= '9.1.2'
$_instance
The single instance of the class.
protected
static WooCommerce
$_instance
=
ull
Tags
Methods
__clone()
Cloning is forbidden.
public
__clone() : mixed
Tags
Return values
mixed —__construct()
WooCommerce Constructor.
public
__construct() : mixed
Return values
mixed —__get()
Auto-load in-accessible properties on demand.
public
__get(mixed $key) : mixed
Parameters
- $key : mixed
-
Key name.
Return values
mixed —__wakeup()
Unserializing instances of this class is forbidden.
public
__wakeup() : mixed
Tags
Return values
mixed —activated_plugin()
Ran when any plugin is activated.
public
activated_plugin(string $filename) : mixed
Parameters
- $filename : string
-
The filename of the activated plugin.
Tags
Return values
mixed —add_image_sizes()
Add WC Image sizes to WP.
public
add_image_sizes() : mixed
As of 3.3, image sizes can be registered via themes using add_theme_support for woocommerce and defining an array of args. If these are not defined, we will use defaults. This is handled in wc_get_image_size function.
3.3 sizes:
woocommerce_thumbnail - Used in product listings. We assume these work for a 3 column grid layout. woocommerce_single - Used on single product pages for the main image.
Tags
Return values
mixed —add_woocommerce_inbox_variant()
Add woocommerce_inbox_variant for the Remote Inbox Notification.
public
add_woocommerce_inbox_variant() : mixed
P2 post can be found at https://wp.me/paJDYF-1uJ.
This will no longer be used. The more flexible add_woocommerce_remote_variant below will be used instead.
Return values
mixed —add_woocommerce_remote_variant()
Add woocommerce_remote_variant_assignment used to determine cohort or group assignment for Remote Spec Engines.
public
add_woocommerce_remote_variant() : mixed
Return values
mixed —ajax_url()
Get Ajax URL.
public
ajax_url() : string
Return values
string —api_request_url()
Return the WC API URL for a given request.
public
api_request_url(string $request[, bool|null $ssl = null ]) : string
Parameters
- $request : string
-
Requested endpoint.
- $ssl : bool|null = null
-
If should use SSL, null if should auto detect. Default: null.
Return values
string —build_dependencies_notice()
Output a admin notice when build dependencies not met.
public
build_dependencies_notice() : void
Return values
void —build_dependencies_satisfied()
Check if plugin assets are built and minified
public
build_dependencies_satisfied() : bool
Return values
bool —call_function()
Call a user function. This should be used to execute any non-idempotent function, especially those in the `includes` directory or provided by WordPress.
public
call_function(string $function_name, mixed ...$parameters) : mixed
This method can be useful for unit tests, since functions called using this method can be easily mocked by using WC_Unit_Test_Case::register_legacy_proxy_function_mocks.
Parameters
- $function_name : string
-
The function to execute.
- $parameters : mixed
-
The parameters to pass to the function.
Tags
Return values
mixed — The result from the function.call_static()
Call a static method in a class. This should be used to execute any non-idempotent method in classes from the `includes` directory.
public
call_static(string $class_name, string $method_name, mixed ...$parameters) : mixed
This method can be useful for unit tests, since methods called using this method can be easily mocked by using WC_Unit_Test_Case::register_legacy_proxy_static_mocks.
Parameters
- $class_name : string
-
The name of the class containing the method.
- $method_name : string
-
The name of the method.
- $parameters : mixed
-
The parameters to pass to the method.
Tags
Return values
mixed — The result from the method.checkout()
Get Checkout Class.
public
checkout() : WC_Checkout
Return values
WC_Checkout —convert_woocommerce_slug()
Converts the WooCommerce slug to the correct slug for the current version.
public
convert_woocommerce_slug(string $slug) : string
This ensures that when the plugin is installed in a different folder name, the correct slug is used so that dependent plugins can be installed/activated.
Parameters
- $slug : string
-
The plugin slug to convert.
Tags
Return values
string —deactivated_plugin()
Ran when any plugin is deactivated.
public
deactivated_plugin(string $filename) : mixed
Parameters
- $filename : string
-
The filename of the deactivated plugin.
Tags
Return values
mixed —frontend_includes()
Include required frontend files.
public
frontend_includes() : mixed
Return values
mixed —get_global()
Gets the value of a global.
public
get_global(string $global_name) : mixed
Parameters
- $global_name : string
-
The name of the global to get the value for.
Return values
mixed — The value of the global.get_instance_of()
Gets an instance of a given legacy class.
public
get_instance_of(string $class_name, mixed ...$args) : object
This must not be used to get instances of classes in the src
directory.
This method can be useful for unit tests, since objects obtained using this method can be easily mocked by using WC_Unit_Test_Case::register_legacy_proxy_class_mocks.
Parameters
- $class_name : string
-
The name of the class to get an instance for.
- $args : mixed
-
Parameters to be passed to the class constructor or to the appropriate internal 'get_instance_of_' method.
Tags
Return values
object — The instance of the class.include_template_functions()
Function used to Init WooCommerce Template Functions - This makes them pluggable by plugins and themes.
public
include_template_functions() : mixed
Return values
mixed —includes()
Include required core files used in admin and on the frontend.
public
includes() : mixed
Return values
mixed —init()
Init WooCommerce when WordPress Initialises.
public
init() : mixed
Return values
mixed —init_jetpack_connection_config()
Initiali Jetpack Connection Config.
public
init_jetpack_connection_config() : void
Return values
void —initialize_cart()
Initialize the customer and cart objects and setup customer saving on shutdown.
public
initialize_cart() : void
Note, wc()->customer is session based. Changes to customer data via this property are not persisted to the database automatically.
Tags
Return values
void —initialize_session()
Initialize the session class.
public
initialize_session() : void
Tags
Return values
void —instance()
Main WooCommerce Instance.
public
static instance() : WooCommerce
Ensures only one instance of WooCommerce is loaded or can be loaded.
Tags
Return values
WooCommerce — - Main instance.is_rest_api_request()
Returns true if the request is a non-legacy REST API request.
public
is_rest_api_request() : bool
Legacy REST requests should still run some extra code for backwards compatibility.
Tags
Return values
bool —is_store_api_request()
Returns true if the request is a store REST API request.
public
is_store_api_request() : bool
Return values
bool —is_wc_admin_active()
Is the WooCommerce Admin actively included in the WooCommerce core? Based on presence of a basic WC Admin function.
public
is_wc_admin_active() : bool
Return values
bool —load_plugin_textdomain()
Load Localisation files.
public
load_plugin_textdomain() : mixed
Note: the first-loaded translation file overrides any following ones if the same translation is present.
Locales found in: - WP_LANG_DIR/woocommerce/woocommerce-LOCALE.mo - WP_LANG_DIR/plugins/woocommerce-LOCALE.mo
Return values
mixed —load_rest_api()
Load REST API.
public
load_rest_api() : mixed
Return values
mixed —log_errors()
Ensures fatal errors are logged so they can be picked up in the status report.
public
log_errors() : mixed
Tags
Return values
mixed —mailer()
Email Class.
public
mailer() : WC_Emails
Return values
WC_Emails —on_plugins_loaded()
When WP has loaded all plugins, trigger the `woocommerce_loaded` hook.
public
on_plugins_loaded() : mixed
This ensures woocommerce_loaded
is called only after all other plugins
are loaded, to avoid issues caused by plugin directory naming changing
the load order. See #21524 for details.
Tags
Return values
mixed —payment_gateways()
Get gateways class.
public
payment_gateways() : WC_Payment_Gateways
Return values
WC_Payment_Gateways —plugin_path()
Get the plugin path.
public
plugin_path() : string
Return values
string —plugin_url()
Get the plugin url.
public
plugin_url() : string
Return values
string —queue()
Get queue instance.
public
queue() : WC_Queue_Interface
Return values
WC_Queue_Interface —setup_environment()
Ensure theme and server variable compatibility and setup image sizes.
public
setup_environment() : mixed
Return values
mixed —shipping()
Get shipping class.
public
shipping() : WC_Shipping
Return values
WC_Shipping —template_path()
Get the template path.
public
template_path() : string
Return values
string —wpdb_table_fix()
Set tablenames inside WPDB object.
public
wpdb_table_fix() : mixed
Return values
mixed —add_thumbnail_support()
Ensure post thumbnail support is turned on.
private
add_thumbnail_support() : mixed
Return values
mixed —define()
Define constant if not already set.
private
define(string $name, string|bool $value) : mixed
Parameters
- $name : string
-
Constant name.
- $value : string|bool
-
Constant value.
Return values
mixed —define_constants()
Define WC Constants.
private
define_constants() : mixed
Return values
mixed —define_tables()
Register custom tables within $wpdb object.
private
define_tables() : mixed
Return values
mixed —init_hooks()
Hook into actions and filters.
private
init_hooks() : mixed
Tags
Return values
mixed —is_request()
What type of request is this?
private
is_request(string $type) : bool
Parameters
- $type : string
-
admin, ajax, cron or frontend.
Return values
bool —load_webhooks()
Load & enqueue active webhooks.
private
load_webhooks() : mixed
Tags
Return values
mixed —register_wp_admin_settings()
Register WC settings from WP-API to the REST API.
private
register_wp_admin_settings() : mixed
This method used to be part of the now removed Legacy REST API.
Tags
Return values
mixed —theme_support_includes()
Include classes for theme support.
private
theme_support_includes() : mixed