From d88ff4bc89157b3496ea21237936ca42637e28e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Mon, 22 Sep 2025 16:34:30 +0000 Subject: [PATCH 1/3] Generate stubs for WooCommerce 10.2.1 --- source/composer.json | 2 +- woocommerce-stubs.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/composer.json b/source/composer.json index 2f44bb0..d304213 100644 --- a/source/composer.json +++ b/source/composer.json @@ -6,7 +6,7 @@ "ext-json": "*", "ext-mbstring": "*", "ext-openssl": "*", - "woocommerce/woocommerce": "10.2.0" + "woocommerce/woocommerce": "10.2.1" }, "minimum-stability": "stable", "extra": { diff --git a/woocommerce-stubs.php b/woocommerce-stubs.php index b76e639..3faffcc 100644 --- a/woocommerce-stubs.php +++ b/woocommerce-stubs.php @@ -38200,7 +38200,7 @@ final class WooCommerce * * @var string */ - public $version = '10.2.0'; + public $version = '10.2.1'; /** * WooCommerce Schema version. * From 6f4fe6c132bd397c9b002cbd01dbd9cdc56df29e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Mon, 29 Sep 2025 19:33:25 +0000 Subject: [PATCH 2/3] Generate stubs for WooCommerce 10.2.2 --- source/composer.json | 2 +- woocommerce-stubs.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/composer.json b/source/composer.json index d304213..83b7985 100644 --- a/source/composer.json +++ b/source/composer.json @@ -6,7 +6,7 @@ "ext-json": "*", "ext-mbstring": "*", "ext-openssl": "*", - "woocommerce/woocommerce": "10.2.1" + "woocommerce/woocommerce": "10.2.2" }, "minimum-stability": "stable", "extra": { diff --git a/woocommerce-stubs.php b/woocommerce-stubs.php index 3faffcc..e13f2f7 100644 --- a/woocommerce-stubs.php +++ b/woocommerce-stubs.php @@ -38200,7 +38200,7 @@ final class WooCommerce * * @var string */ - public $version = '10.2.1'; + public $version = '10.2.2'; /** * WooCommerce Schema version. * From 8d037215365f64df63ca90e5cdf026b982558405 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Wed, 22 Oct 2025 17:11:01 +0000 Subject: [PATCH 3/3] Generate stubs for WooCommerce 10.3.0 --- source/composer.json | 2 +- woocommerce-stubs.php | 28682 +++++++++++++++++++++++----------------- 2 files changed, 16207 insertions(+), 12477 deletions(-) diff --git a/source/composer.json b/source/composer.json index 83b7985..7f39fdc 100644 --- a/source/composer.json +++ b/source/composer.json @@ -6,7 +6,7 @@ "ext-json": "*", "ext-mbstring": "*", "ext-openssl": "*", - "woocommerce/woocommerce": "10.2.2" + "woocommerce/woocommerce": "10.3.0" }, "minimum-stability": "stable", "extra": { diff --git a/woocommerce-stubs.php b/woocommerce-stubs.php index e13f2f7..0c70478 100644 --- a/woocommerce-stubs.php +++ b/woocommerce-stubs.php @@ -29,6 +29,12 @@ abstract class WC_Address_Provider * @var string */ public $name; + /** + * Optional HTML element to display for branding purposes (e.g. "powered by ..."). + * + * @var string + */ + public $branding_html = ''; } /** * Abstract WC Data Class @@ -2430,14 +2436,14 @@ private function hold_coupon_for_users($coupon, $user_ids_and_emails, $user_alia { } /** - * Helper method to get all aliases for current user and provide billing email. + * Helper method to get all aliases and IDs for current user and provided billing email. * - * @param string $billing_email Billing email provided in form. + * @param string $billing_email Billing email to look up for. * - * @return array Array of all aliases. + * @return array Array of all aliases and IDs. * @throws Exception When validation fails. */ - private function get_billing_and_current_user_aliases($billing_email) + private function get_billing_and_current_user_ids_and_aliases($billing_email): array { } /** @@ -2939,6 +2945,15 @@ public function get_cogs_total_value(): float public function set_cogs_total_value(float $value) { } + /** + * Return the HTML to render the total Cost of Goods Sold for the order. + * + * @param array|null $wc_price_arg Arguments to be passed to wc_price, defaults to an array containing only the currency symbol. + * @return string + */ + public function get_cogs_total_value_html(?array $wc_price_arg = \null): string + { + } } /** * WooCommerce Payment Gateway class. @@ -4102,7 +4117,7 @@ class WC_Product extends \WC_Abstract_Legacy_Product * * @var array */ - protected $data = array('name' => '', 'slug' => '', 'date_created' => \null, 'date_modified' => \null, 'status' => \false, 'featured' => \false, 'catalog_visibility' => \Automattic\WooCommerce\Enums\CatalogVisibility::VISIBLE, 'description' => '', 'short_description' => '', 'sku' => '', 'global_unique_id' => '', 'price' => '', 'regular_price' => '', 'sale_price' => '', 'date_on_sale_from' => \null, 'date_on_sale_to' => \null, 'total_sales' => '0', 'tax_status' => \Automattic\WooCommerce\Enums\ProductTaxStatus::TAXABLE, 'tax_class' => '', 'manage_stock' => \false, 'stock_quantity' => \null, 'stock_status' => \Automattic\WooCommerce\Enums\ProductStockStatus::IN_STOCK, 'backorders' => 'no', 'low_stock_amount' => '', 'sold_individually' => \false, 'weight' => '', 'length' => '', 'width' => '', 'height' => '', 'upsell_ids' => array(), 'cross_sell_ids' => array(), 'parent_id' => 0, 'reviews_allowed' => \true, 'purchase_note' => '', 'attributes' => array(), 'default_attributes' => array(), 'menu_order' => 0, 'post_password' => '', 'virtual' => \false, 'downloadable' => \false, 'category_ids' => array(), 'tag_ids' => array(), 'shipping_class_id' => 0, 'downloads' => array(), 'image_id' => '', 'gallery_image_ids' => array(), 'download_limit' => -1, 'download_expiry' => -1, 'rating_counts' => array(), 'average_rating' => 0, 'review_count' => 0, 'cogs_value' => \null); + protected $data = array('name' => '', 'slug' => '', 'date_created' => \null, 'date_modified' => \null, 'status' => \false, 'featured' => \false, 'catalog_visibility' => \Automattic\WooCommerce\Enums\CatalogVisibility::VISIBLE, 'description' => '', 'short_description' => '', 'sku' => '', 'global_unique_id' => '', 'price' => '', 'regular_price' => '', 'sale_price' => '', 'date_on_sale_from' => \null, 'date_on_sale_to' => \null, 'total_sales' => '0', 'tax_status' => \Automattic\WooCommerce\Enums\ProductTaxStatus::TAXABLE, 'tax_class' => '', 'manage_stock' => \false, 'stock_quantity' => \null, 'stock_status' => \Automattic\WooCommerce\Enums\ProductStockStatus::IN_STOCK, 'backorders' => 'no', 'low_stock_amount' => '', 'sold_individually' => \false, 'weight' => '', 'length' => '', 'width' => '', 'height' => '', 'upsell_ids' => array(), 'cross_sell_ids' => array(), 'parent_id' => 0, 'reviews_allowed' => \true, 'purchase_note' => '', 'attributes' => array(), 'default_attributes' => array(), 'menu_order' => 0, 'post_password' => '', 'virtual' => \false, 'downloadable' => \false, 'category_ids' => array(), 'tag_ids' => array(), 'brand_ids' => array(), 'shipping_class_id' => 0, 'downloads' => array(), 'image_id' => '', 'gallery_image_ids' => array(), 'download_limit' => -1, 'download_expiry' => -1, 'rating_counts' => array(), 'average_rating' => 0, 'review_count' => 0, 'cogs_value' => \null); /** * Supported features such as 'ajax_add_to_cart'. * @@ -4527,6 +4542,16 @@ public function get_category_ids($context = 'view') public function get_tag_ids($context = 'view') { } + /** + * Get brand ids. + * + * @since 10.3.0 + * @param string $context What the value is for. Valid values are view and edit. + * @return array + */ + public function get_brand_ids($context = 'view') + { + } /** * Get virtual. * @@ -5020,6 +5045,15 @@ public function set_category_ids($term_ids) public function set_tag_ids($term_ids) { } + /** + * Set the product brands. + * + * @since 10.3.0 + * @param array $term_ids List of terms IDs. + */ + public function set_brand_ids($term_ids) + { + } /** * Set if the product is virtual. * @@ -7154,12 +7188,35 @@ class WC_Admin_Assets public function __construct() { } + /** + * Add warnings for deprecated script handles. + */ + public function add_legacy_script_warnings() + { + } /** * Enqueue styles. */ public function admin_styles() { } + /** + * Get the scripts used for registration. + * + * @return array + */ + private function get_scripts(): array + { + } + /** + * Register the scripts. + * + * These scripts are registered early to allow other + * plugins to take advantage of them by handle. + */ + public function register_scripts() + { + } /** * Enqueue scripts. */ @@ -7487,6 +7544,16 @@ public function add_column_to_importer_exporter($options) public function add_default_column_mapping($mappings) { } + /** + * Add formatting callback for brand_ids during CSV import. + * + * @param array $callbacks Formatting callbacks. + * @param WC_Product_Importer $importer Importer instance. + * @return array $callbacks + */ + public function add_formatting_callback($callbacks, $importer) + { + } /** * Add brands to newly imported product. * @@ -10901,12 +10968,6 @@ public function prevent_admin_access() public function preview_emails() { } - /** - * Preview email editor placeholder dummy content. - */ - public function preview_email_editor_dummy_content() - { - } /** * Change the admin footer text on WooCommerce admin pages. * @@ -14458,9 +14519,15 @@ class WC_Notes_Run_Db_Update { const NOTE_NAME = 'wc-update-db-reminder'; /** - * Attach hooks. + * Checks whether the note needs an update based on the current db update status. + * Hooked onto the 'woocommerce_get_note_from_db' filter. See {@see \WC_Install}. + * + * @since 10.3.0 + * + * @param Note $note Note to check. + * @return Note */ - public function __construct() + public static function maybe_update_notice($note) { } /** @@ -14468,7 +14535,7 @@ public function __construct() * * Retrieves the first notice of this type. * - * @return int|void Note id or null in case no note was found. + * @return Note|null Note or null in case no note was found. */ private static function get_current_notice() { @@ -14499,10 +14566,9 @@ private static function note_up_to_date($note, $update_url, $current_actions) * * If a $note_id is given, the method updates the note instead of creating a new one. * - * @param integer $note_id Note db record to update. - * @return int Created/Updated note id + * @param null|Note $note Note db record to update. NULL to create a new one. */ - private static function update_needed_notice($note_id = \null) + private static function update_needed_notice(?\Automattic\WooCommerce\Admin\Notes\Note $note = \null) { } /** @@ -14510,9 +14576,9 @@ private static function update_needed_notice($note_id = \null) * * This is the second out of 3 notices displayed to the user. * - * @param int $note_id Note id to update. + * @param Note $note Note to update. */ - private static function update_in_progress_notice($note_id) + private static function update_in_progress_notice(\Automattic\WooCommerce\Admin\Notes\Note $note) { } /** @@ -14520,9 +14586,17 @@ private static function update_in_progress_notice($note_id) * * This is the last notice (3 out of 3 notices) displayed to the user. * - * @param int $note_id Note id to update. + * @param Note $note Note to update. */ - private static function update_done_notice($note_id) + private static function update_done_notice(\Automattic\WooCommerce\Admin\Notes\Note $note) + { + } + /** + * Creates the db update note if needed. + * + * @since 10.3.0 + */ + public static function add_notice() { } /** @@ -14535,6 +14609,8 @@ private static function update_done_notice($note_id) * store owner hasn't acknowledged the successful db update), still show the Thanks notice. * If the db does not need an update, and the notice has been actioned, then notice should *not* be shown. * The notice should also be hidden if the db does not need an update and the notice does not exist. + * + * @deprecated 10.3.0 */ public static function show_reminder() { @@ -17906,6 +17982,14 @@ private function load_file($path) public function autoload($class) { } + /** + * Recursively load REST API V4 controllers from subdirectories. + * + * @param string $file File name to search for. + */ + private function load_rest_v4_controller_recursively($file): bool + { + } } /** * WC_Background_Emailer Class. @@ -19148,6 +19232,28 @@ private function get_saved_cart() private function populate_cart_from_order($order_id, $cart) { } + /** + * Remove the draft order from the session and delete it. + */ + private function remove_draft_order() + { + } + /** + * Remove shipping data for all packages from session. + * + * @return void + */ + private function remove_shipping_for_package_from_session() + { + } + /** + * Check if the cart has shippable products. + * + * @return bool + */ + private function cart_has_shippable_products() + { + } } /** * WC_Cart_Totals class. @@ -19943,7 +20049,7 @@ public function get_shipping_tax() * Gets cart total. This is the total of items in the cart, but after discounts. Subtotal is before discounts. * * @since 3.2.0 - * @return float + * @return float|string|int */ public function get_cart_contents_total() { @@ -22348,6 +22454,16 @@ public function set_status($status) public function set_discount_type($discount_type) { } + /** + * Set discount type, optionally disabling the type verification. + * + * @since 10.3.0 + * @param string $discount_type Discount type. + * @param bool $verify_discount_type Whether to verify if the discount type is valid. + */ + private function set_discount_type_core($discount_type, bool $verify_discount_type) + { + } /** * Set amount. * @@ -25790,7 +25906,7 @@ class WC_Frontend_Scripts * * @var array */ - private static $scripts = array(); + private static $registered_scripts = array(); /** * Contains an array of script handles registered by WC. * @@ -25809,6 +25925,12 @@ class WC_Frontend_Scripts public static function init() { } + /** + * Add warnings for deprecated script handles. + */ + public static function add_legacy_script_warnings() + { + } /** * Get styles for the frontend. * @@ -25880,6 +26002,14 @@ private static function register_style($handle, $path, $deps = array(), $version private static function enqueue_style($handle, $path = '', $deps = array(), $version = \WC_VERSION, $media = 'all', $has_rtl = \false) { } + /** + * Get scripts for the frontend. + * + * @return array + */ + private static function get_scripts(): array + { + } /** * Register all WC scripts. */ @@ -26011,7 +26141,7 @@ class WC_Geo_IP * * @var array */ - public $GEOIP_COUNTRY_CODES = array('', 'AP', 'EU', 'AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM', 'CW', 'AO', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AW', 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BM', 'BN', 'BO', 'BR', 'BS', 'BT', 'BV', 'BW', 'BY', 'BZ', 'CA', 'CC', 'CD', 'CF', 'CG', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU', 'CV', 'CX', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC', 'EE', 'EG', 'EH', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FK', 'FM', 'FO', 'FR', 'SX', 'GA', 'GB', 'GD', 'GE', 'GF', 'GH', 'GI', 'GL', 'GM', 'GN', 'GP', 'GQ', 'GR', 'GS', 'GT', 'GU', 'GW', 'GY', 'HK', 'HM', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IN', 'IO', 'IQ', 'IR', 'IS', 'IT', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN', 'KP', 'KR', 'KW', 'KY', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK', 'LR', 'LS', 'LT', 'LU', 'LV', 'LY', 'MA', 'MC', 'MD', 'MG', 'MH', 'MK', 'ML', 'MM', 'MN', 'MO', 'MP', 'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NC', 'NE', 'NF', 'NG', 'NI', 'NL', 'NO', 'NP', 'NR', 'NU', 'NZ', 'OM', 'PA', 'PE', 'PF', 'PG', 'PH', 'PK', 'PL', 'PM', 'PN', 'PR', 'PS', 'PT', 'PW', 'PY', 'QA', 'RE', 'RO', 'RU', 'RW', 'SA', 'SB', 'SC', 'SD', 'SE', 'SG', 'SH', 'SI', 'SJ', 'SK', 'SL', 'SM', 'SN', 'SO', 'SR', 'ST', 'SV', 'SY', 'SZ', 'TC', 'TD', 'TF', 'TG', 'TH', 'TJ', 'TK', 'TM', 'TN', 'TO', 'TL', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA', 'UG', 'UM', 'US', 'UY', 'UZ', 'VA', 'VC', 'VE', 'VG', 'VI', 'VN', 'VU', 'WF', 'WS', 'YE', 'YT', 'RS', 'ZA', 'ZM', 'ME', 'ZW', 'A1', 'A2', 'O1', 'AX', 'GG', 'IM', 'JE', 'BL', 'MF', 'BQ', 'SS', 'O1'); + public $GEOIP_COUNTRY_CODES = array('', 'AP', 'EU', 'AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM', 'CW', 'AO', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AW', 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BM', 'BN', 'BO', 'BR', 'BS', 'BT', 'BV', 'BW', 'BY', 'BZ', 'CA', 'CC', 'CD', 'CF', 'CG', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU', 'CV', 'CX', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC', 'EE', 'EG', 'EH', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FK', 'FM', 'FO', 'FR', 'SX', 'GA', 'GB', 'GD', 'GE', 'GF', 'GH', 'GI', 'GL', 'GM', 'GN', 'GP', 'GQ', 'GR', 'GS', 'GT', 'GU', 'GW', 'GY', 'HK', 'HM', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IN', 'IO', 'IQ', 'IR', 'IS', 'IT', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN', 'KP', 'KR', 'KW', 'KY', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK', 'LR', 'LS', 'LT', 'LU', 'LV', 'LY', 'MA', 'MC', 'MD', 'MG', 'MH', 'MK', 'ML', 'MM', 'MN', 'MO', 'MP', 'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NC', 'NE', 'NF', 'NG', 'NI', 'NL', 'NO', 'NP', 'NR', 'NU', 'NZ', 'OM', 'PA', 'PE', 'PF', 'PG', 'PH', 'PK', 'PL', 'PM', 'PN', 'PR', 'PS', 'PT', 'PW', 'PY', 'QA', 'RE', 'RO', 'RU', 'RW', 'SA', 'SB', 'SC', 'SD', 'SE', 'SG', 'SH', 'SI', 'SJ', 'SK', 'SL', 'SM', 'SN', 'SO', 'SR', 'ST', 'SV', 'SY', 'SZ', 'TC', 'TD', 'TF', 'TG', 'TH', 'TJ', 'TK', 'TM', 'TN', 'TO', 'TL', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA', 'UG', 'UM', 'US', 'UY', 'UZ', 'VA', 'VC', 'VE', 'VG', 'VI', 'VN', 'VU', 'WF', 'WS', 'YE', 'YT', 'RS', 'ZA', 'ZM', 'ME', 'ZW', 'A1', 'A2', 'O1', 'AX', 'GG', 'IM', 'JE', 'BL', 'MF', 'BQ', 'SS', 'XK', 'O1'); /** * 3 letters country codes. * @@ -26023,7 +26153,7 @@ class WC_Geo_IP * * @var array */ - public $GEOIP_COUNTRY_NAMES = array('', 'Asia/Pacific Region', 'Europe', 'Andorra', 'United Arab Emirates', 'Afghanistan', 'Antigua and Barbuda', 'Anguilla', 'Albania', 'Armenia', 'Curacao', 'Angola', 'Antarctica', 'Argentina', 'American Samoa', 'Austria', 'Australia', 'Aruba', 'Azerbaijan', 'Bosnia and Herzegovina', 'Barbados', 'Bangladesh', 'Belgium', 'Burkina Faso', 'Bulgaria', 'Bahrain', 'Burundi', 'Benin', 'Bermuda', 'Brunei Darussalam', 'Bolivia', 'Brazil', 'Bahamas', 'Bhutan', 'Bouvet Island', 'Botswana', 'Belarus', 'Belize', 'Canada', 'Cocos (Keeling) Islands', 'Congo, The Democratic Republic of the', 'Central African Republic', 'Congo', 'Switzerland', "Cote D'Ivoire", 'Cook Islands', 'Chile', 'Cameroon', 'China', 'Colombia', 'Costa Rica', 'Cuba', 'Cape Verde', 'Christmas Island', 'Cyprus', 'Czech Republic', 'Germany', 'Djibouti', 'Denmark', 'Dominica', 'Dominican Republic', 'Algeria', 'Ecuador', 'Estonia', 'Egypt', 'Western Sahara', 'Eritrea', 'Spain', 'Ethiopia', 'Finland', 'Fiji', 'Falkland Islands (Malvinas)', 'Micronesia, Federated States of', 'Faroe Islands', 'France', 'Sint Maarten (Dutch part)', 'Gabon', 'United Kingdom', 'Grenada', 'Georgia', 'French Guiana', 'Ghana', 'Gibraltar', 'Greenland', 'Gambia', 'Guinea', 'Guadeloupe', 'Equatorial Guinea', 'Greece', 'South Georgia and the South Sandwich Islands', 'Guatemala', 'Guam', 'Guinea-Bissau', 'Guyana', 'Hong Kong', 'Heard Island and McDonald Islands', 'Honduras', 'Croatia', 'Haiti', 'Hungary', 'Indonesia', 'Ireland', 'Israel', 'India', 'British Indian Ocean Territory', 'Iraq', 'Iran, Islamic Republic of', 'Iceland', 'Italy', 'Jamaica', 'Jordan', 'Japan', 'Kenya', 'Kyrgyzstan', 'Cambodia', 'Kiribati', 'Comoros', 'Saint Kitts and Nevis', "Korea, Democratic People's Republic of", 'Korea, Republic of', 'Kuwait', 'Cayman Islands', 'Kazakhstan', "Lao People's Democratic Republic", 'Lebanon', 'Saint Lucia', 'Liechtenstein', 'Sri Lanka', 'Liberia', 'Lesotho', 'Lithuania', 'Luxembourg', 'Latvia', 'Libya', 'Morocco', 'Monaco', 'Moldova, Republic of', 'Madagascar', 'Marshall Islands', 'Macedonia', 'Mali', 'Myanmar', 'Mongolia', 'Macau', 'Northern Mariana Islands', 'Martinique', 'Mauritania', 'Montserrat', 'Malta', 'Mauritius', 'Maldives', 'Malawi', 'Mexico', 'Malaysia', 'Mozambique', 'Namibia', 'New Caledonia', 'Niger', 'Norfolk Island', 'Nigeria', 'Nicaragua', 'Netherlands', 'Norway', 'Nepal', 'Nauru', 'Niue', 'New Zealand', 'Oman', 'Panama', 'Peru', 'French Polynesia', 'Papua New Guinea', 'Philippines', 'Pakistan', 'Poland', 'Saint Pierre and Miquelon', 'Pitcairn Islands', 'Puerto Rico', 'Palestinian Territory', 'Portugal', 'Palau', 'Paraguay', 'Qatar', 'Reunion', 'Romania', 'Russian Federation', 'Rwanda', 'Saudi Arabia', 'Solomon Islands', 'Seychelles', 'Sudan', 'Sweden', 'Singapore', 'Saint Helena', 'Slovenia', 'Svalbard and Jan Mayen', 'Slovakia', 'Sierra Leone', 'San Marino', 'Senegal', 'Somalia', 'Suriname', 'Sao Tome and Principe', 'El Salvador', 'Syrian Arab Republic', 'Eswatini', 'Turks and Caicos Islands', 'Chad', 'French Southern Territories', 'Togo', 'Thailand', 'Tajikistan', 'Tokelau', 'Turkmenistan', 'Tunisia', 'Tonga', 'Timor-Leste', 'Türkiye', 'Trinidad and Tobago', 'Tuvalu', 'Taiwan', 'Tanzania, United Republic of', 'Ukraine', 'Uganda', 'United States Minor Outlying Islands', 'United States', 'Uruguay', 'Uzbekistan', 'Holy See (Vatican City State)', 'Saint Vincent and the Grenadines', 'Venezuela', 'Virgin Islands, British', 'Virgin Islands, U.S.', 'Vietnam', 'Vanuatu', 'Wallis and Futuna', 'Samoa', 'Yemen', 'Mayotte', 'Serbia', 'South Africa', 'Zambia', 'Montenegro', 'Zimbabwe', 'Anonymous Proxy', 'Satellite Provider', 'Other', 'Aland Islands', 'Guernsey', 'Isle of Man', 'Jersey', 'Saint Barthelemy', 'Saint Martin', 'Bonaire, Saint Eustatius and Saba', 'South Sudan', 'Other'); + public $GEOIP_COUNTRY_NAMES = array('', 'Asia/Pacific Region', 'Europe', 'Andorra', 'United Arab Emirates', 'Afghanistan', 'Antigua and Barbuda', 'Anguilla', 'Albania', 'Armenia', 'Curacao', 'Angola', 'Antarctica', 'Argentina', 'American Samoa', 'Austria', 'Australia', 'Aruba', 'Azerbaijan', 'Bosnia and Herzegovina', 'Barbados', 'Bangladesh', 'Belgium', 'Burkina Faso', 'Bulgaria', 'Bahrain', 'Burundi', 'Benin', 'Bermuda', 'Brunei Darussalam', 'Bolivia', 'Brazil', 'Bahamas', 'Bhutan', 'Bouvet Island', 'Botswana', 'Belarus', 'Belize', 'Canada', 'Cocos (Keeling) Islands', 'Congo, The Democratic Republic of the', 'Central African Republic', 'Congo', 'Switzerland', "Cote D'Ivoire", 'Cook Islands', 'Chile', 'Cameroon', 'China', 'Colombia', 'Costa Rica', 'Cuba', 'Cape Verde', 'Christmas Island', 'Cyprus', 'Czech Republic', 'Germany', 'Djibouti', 'Denmark', 'Dominica', 'Dominican Republic', 'Algeria', 'Ecuador', 'Estonia', 'Egypt', 'Western Sahara', 'Eritrea', 'Spain', 'Ethiopia', 'Finland', 'Fiji', 'Falkland Islands (Malvinas)', 'Micronesia, Federated States of', 'Faroe Islands', 'France', 'Sint Maarten (Dutch part)', 'Gabon', 'United Kingdom', 'Grenada', 'Georgia', 'French Guiana', 'Ghana', 'Gibraltar', 'Greenland', 'Gambia', 'Guinea', 'Guadeloupe', 'Equatorial Guinea', 'Greece', 'South Georgia and the South Sandwich Islands', 'Guatemala', 'Guam', 'Guinea-Bissau', 'Guyana', 'Hong Kong', 'Heard Island and McDonald Islands', 'Honduras', 'Croatia', 'Haiti', 'Hungary', 'Indonesia', 'Ireland', 'Israel', 'India', 'British Indian Ocean Territory', 'Iraq', 'Iran, Islamic Republic of', 'Iceland', 'Italy', 'Jamaica', 'Jordan', 'Japan', 'Kenya', 'Kyrgyzstan', 'Cambodia', 'Kiribati', 'Comoros', 'Saint Kitts and Nevis', "Korea, Democratic People's Republic of", 'Korea, Republic of', 'Kuwait', 'Cayman Islands', 'Kazakhstan', "Lao People's Democratic Republic", 'Lebanon', 'Saint Lucia', 'Liechtenstein', 'Sri Lanka', 'Liberia', 'Lesotho', 'Lithuania', 'Luxembourg', 'Latvia', 'Libya', 'Morocco', 'Monaco', 'Moldova, Republic of', 'Madagascar', 'Marshall Islands', 'Macedonia', 'Mali', 'Myanmar', 'Mongolia', 'Macau', 'Northern Mariana Islands', 'Martinique', 'Mauritania', 'Montserrat', 'Malta', 'Mauritius', 'Maldives', 'Malawi', 'Mexico', 'Malaysia', 'Mozambique', 'Namibia', 'New Caledonia', 'Niger', 'Norfolk Island', 'Nigeria', 'Nicaragua', 'Netherlands', 'Norway', 'Nepal', 'Nauru', 'Niue', 'New Zealand', 'Oman', 'Panama', 'Peru', 'French Polynesia', 'Papua New Guinea', 'Philippines', 'Pakistan', 'Poland', 'Saint Pierre and Miquelon', 'Pitcairn Islands', 'Puerto Rico', 'Palestinian Territory', 'Portugal', 'Palau', 'Paraguay', 'Qatar', 'Reunion', 'Romania', 'Russian Federation', 'Rwanda', 'Saudi Arabia', 'Solomon Islands', 'Seychelles', 'Sudan', 'Sweden', 'Singapore', 'Saint Helena', 'Slovenia', 'Svalbard and Jan Mayen', 'Slovakia', 'Sierra Leone', 'San Marino', 'Senegal', 'Somalia', 'Suriname', 'Sao Tome and Principe', 'El Salvador', 'Syrian Arab Republic', 'Eswatini', 'Turks and Caicos Islands', 'Chad', 'French Southern Territories', 'Togo', 'Thailand', 'Tajikistan', 'Tokelau', 'Turkmenistan', 'Tunisia', 'Tonga', 'Timor-Leste', 'Türkiye', 'Trinidad and Tobago', 'Tuvalu', 'Taiwan', 'Tanzania, United Republic of', 'Ukraine', 'Uganda', 'United States Minor Outlying Islands', 'United States', 'Uruguay', 'Uzbekistan', 'Holy See (Vatican City State)', 'Saint Vincent and the Grenadines', 'Venezuela', 'Virgin Islands, British', 'Virgin Islands, U.S.', 'Vietnam', 'Vanuatu', 'Wallis and Futuna', 'Samoa', 'Yemen', 'Mayotte', 'Serbia', 'South Africa', 'Zambia', 'Montenegro', 'Zimbabwe', 'Anonymous Proxy', 'Satellite Provider', 'Other', 'Aland Islands', 'Guernsey', 'Isle of Man', 'Jersey', 'Saint Barthelemy', 'Saint Martin', 'Bonaire, Saint Eustatius and Saba', 'South Sudan', 'Kosovo', 'Other'); /** * 2 letters continent codes. * @@ -26522,9 +26652,14 @@ class WC_Install * via dbDelta at both install and update time. If any other kind of database change is required * at install time (e.g. populating tables), use the 'woocommerce_installed' hook. * + * IMPORTANT: + * When adding new update callbacks after feature freeze, always use a unique version key with a suffix (e.g. `10.2.0-1`) + * if the base version already exists in the array. + * This ensures all users, including those on beta or RC versions, receive the update. + * * @var array */ - private static $db_updates = array('2.0.0' => array('wc_update_200_file_paths', 'wc_update_200_permalinks', 'wc_update_200_subcat_display', 'wc_update_200_taxrates', 'wc_update_200_line_items', 'wc_update_200_images', 'wc_update_200_db_version'), '2.0.9' => array('wc_update_209_brazillian_state', 'wc_update_209_db_version'), '2.1.0' => array('wc_update_210_remove_pages', 'wc_update_210_file_paths', 'wc_update_210_db_version'), '2.2.0' => array('wc_update_220_shipping', 'wc_update_220_order_status', 'wc_update_220_variations', 'wc_update_220_attributes', 'wc_update_220_db_version'), '2.3.0' => array('wc_update_230_options', 'wc_update_230_db_version'), '2.4.0' => array('wc_update_240_options', 'wc_update_240_shipping_methods', 'wc_update_240_api_keys', 'wc_update_240_refunds', 'wc_update_240_db_version'), '2.4.1' => array('wc_update_241_variations', 'wc_update_241_db_version'), '2.5.0' => array('wc_update_250_currency', 'wc_update_250_db_version'), '2.6.0' => array('wc_update_260_options', 'wc_update_260_termmeta', 'wc_update_260_zones', 'wc_update_260_zone_methods', 'wc_update_260_refunds', 'wc_update_260_db_version'), '3.0.0' => array('wc_update_300_grouped_products', 'wc_update_300_settings', 'wc_update_300_product_visibility', 'wc_update_300_db_version'), '3.1.0' => array('wc_update_310_downloadable_products', 'wc_update_310_old_comments', 'wc_update_310_db_version'), '3.1.2' => array('wc_update_312_shop_manager_capabilities', 'wc_update_312_db_version'), '3.2.0' => array('wc_update_320_mexican_states', 'wc_update_320_db_version'), '3.3.0' => array('wc_update_330_image_options', 'wc_update_330_webhooks', 'wc_update_330_product_stock_status', 'wc_update_330_set_default_product_cat', 'wc_update_330_clear_transients', 'wc_update_330_set_paypal_sandbox_credentials', 'wc_update_330_db_version'), '3.4.0' => array('wc_update_340_states', 'wc_update_340_state', 'wc_update_340_last_active', 'wc_update_340_db_version'), '3.4.3' => array('wc_update_343_cleanup_foreign_keys', 'wc_update_343_db_version'), '3.4.4' => array('wc_update_344_recreate_roles', 'wc_update_344_db_version'), '3.5.0' => array('wc_update_350_reviews_comment_type', 'wc_update_350_db_version'), '3.5.2' => array('wc_update_352_drop_download_log_fk'), '3.5.4' => array('wc_update_354_modify_shop_manager_caps', 'wc_update_354_db_version'), '3.6.0' => array('wc_update_360_product_lookup_tables', 'wc_update_360_term_meta', 'wc_update_360_downloadable_product_permissions_index', 'wc_update_360_db_version'), '3.7.0' => array('wc_update_370_tax_rate_classes', 'wc_update_370_mro_std_currency', 'wc_update_370_db_version'), '3.9.0' => array('wc_update_390_move_maxmind_database', 'wc_update_390_change_geolocation_database_update_cron', 'wc_update_390_db_version'), '4.0.0' => array('wc_update_product_lookup_tables', 'wc_update_400_increase_size_of_column', 'wc_update_400_reset_action_scheduler_migration_status', 'wc_admin_update_0201_order_status_index', 'wc_admin_update_0230_rename_gross_total', 'wc_admin_update_0251_remove_unsnooze_action', 'wc_update_400_db_version'), '4.4.0' => array('wc_update_440_insert_attribute_terms_for_variable_products', 'wc_admin_update_110_remove_facebook_note', 'wc_admin_update_130_remove_dismiss_action_from_tracking_opt_in_note', 'wc_update_440_db_version'), '4.5.0' => array('wc_update_450_sanitize_coupons_code', 'wc_update_450_db_version'), '5.0.0' => array('wc_update_500_fix_product_review_count', 'wc_admin_update_160_remove_facebook_note', 'wc_admin_update_170_homescreen_layout', 'wc_update_500_db_version'), '5.6.0' => array('wc_update_560_create_refund_returns_page', 'wc_update_560_db_version'), '6.0.0' => array('wc_update_600_migrate_rate_limit_options', 'wc_admin_update_270_delete_report_downloads', 'wc_admin_update_271_update_task_list_options', 'wc_admin_update_280_order_status', 'wc_admin_update_290_update_apperance_task_option', 'wc_admin_update_290_delete_default_homepage_layout_option', 'wc_update_600_db_version'), '6.3.0' => array('wc_update_630_create_product_attributes_lookup_table', 'wc_admin_update_300_update_is_read_from_last_read', 'wc_update_630_db_version'), '6.4.0' => array('wc_update_640_add_primary_key_to_product_attributes_lookup_table', 'wc_admin_update_340_remove_is_primary_from_note_action', 'wc_update_640_db_version'), '6.5.0' => array('wc_update_650_approved_download_directories'), '6.5.1' => array('wc_update_651_approved_download_directories'), '6.7.0' => array('wc_update_670_purge_comments_count_cache', 'wc_update_670_delete_deprecated_remote_inbox_notifications_option'), '7.0.0' => array('wc_update_700_remove_download_log_fk', 'wc_update_700_remove_recommended_marketing_plugins_transient'), '7.2.1' => array('wc_update_721_adjust_new_zealand_states', 'wc_update_721_adjust_ukraine_states'), '7.2.2' => array('wc_update_722_adjust_new_zealand_states', 'wc_update_722_adjust_ukraine_states'), '7.5.0' => array('wc_update_750_add_columns_to_order_stats_table', 'wc_update_750_disable_new_product_management_experience'), '7.7.0' => array('wc_update_770_remove_multichannel_marketing_feature_options'), '7.9.0' => array('wc_update_790_blockified_product_grid_block'), '8.1.0' => array('wc_update_810_migrate_transactional_metadata_for_hpos'), '8.3.0' => array('wc_update_830_rename_checkout_template', 'wc_update_830_rename_cart_template'), '8.6.0' => array('wc_update_860_remove_recommended_marketing_plugins_transient'), '8.7.0' => array('wc_update_870_prevent_listing_of_transient_files_directory'), '8.9.0' => array('wc_update_890_update_connect_to_woocommerce_note', 'wc_update_890_update_paypal_standard_load_eligibility'), '8.9.1' => array('wc_update_891_create_plugin_autoinstall_history_option'), '9.1.0' => array('wc_update_910_add_launch_your_store_tour_option', 'wc_update_910_remove_obsolete_user_meta'), '9.2.0' => array('wc_update_920_add_wc_hooked_blocks_version_option'), '9.3.0' => array('wc_update_930_add_woocommerce_coming_soon_option', 'wc_update_930_migrate_user_meta_for_launch_your_store_tour'), '9.4.0' => array('wc_update_940_add_phone_to_order_address_fts_index', 'wc_update_940_remove_help_panel_highlight_shown'), '9.5.0' => array('wc_update_950_tracking_option_autoload'), '9.6.1' => array('wc_update_961_migrate_default_email_base_color'), '9.8.0' => array('wc_update_980_remove_order_attribution_install_banner_dismissed_option'), '9.8.5' => array('wc_update_985_enable_new_payments_settings_page_feature'), '9.9.0' => array('wc_update_990_remove_wc_count_comments_transient', 'wc_update_990_remove_email_notes'), '10.0.0' => array('wc_update_1000_multisite_visibility_setting', 'wc_update_1000_remove_patterns_toolkit_transient'), '10.2.0' => array('wc_update_1020_add_old_refunded_order_items_to_product_lookup_table')); + private static $db_updates = array('2.0.0' => array('wc_update_200_file_paths', 'wc_update_200_permalinks', 'wc_update_200_subcat_display', 'wc_update_200_taxrates', 'wc_update_200_line_items', 'wc_update_200_images', 'wc_update_200_db_version'), '2.0.9' => array('wc_update_209_brazillian_state', 'wc_update_209_db_version'), '2.1.0' => array('wc_update_210_remove_pages', 'wc_update_210_file_paths', 'wc_update_210_db_version'), '2.2.0' => array('wc_update_220_shipping', 'wc_update_220_order_status', 'wc_update_220_variations', 'wc_update_220_attributes', 'wc_update_220_db_version'), '2.3.0' => array('wc_update_230_options', 'wc_update_230_db_version'), '2.4.0' => array('wc_update_240_options', 'wc_update_240_shipping_methods', 'wc_update_240_api_keys', 'wc_update_240_refunds', 'wc_update_240_db_version'), '2.4.1' => array('wc_update_241_variations', 'wc_update_241_db_version'), '2.5.0' => array('wc_update_250_currency', 'wc_update_250_db_version'), '2.6.0' => array('wc_update_260_options', 'wc_update_260_termmeta', 'wc_update_260_zones', 'wc_update_260_zone_methods', 'wc_update_260_refunds', 'wc_update_260_db_version'), '3.0.0' => array('wc_update_300_grouped_products', 'wc_update_300_settings', 'wc_update_300_product_visibility', 'wc_update_300_db_version'), '3.1.0' => array('wc_update_310_downloadable_products', 'wc_update_310_old_comments', 'wc_update_310_db_version'), '3.1.2' => array('wc_update_312_shop_manager_capabilities', 'wc_update_312_db_version'), '3.2.0' => array('wc_update_320_mexican_states', 'wc_update_320_db_version'), '3.3.0' => array('wc_update_330_image_options', 'wc_update_330_webhooks', 'wc_update_330_product_stock_status', 'wc_update_330_set_default_product_cat', 'wc_update_330_clear_transients', 'wc_update_330_set_paypal_sandbox_credentials', 'wc_update_330_db_version'), '3.4.0' => array('wc_update_340_states', 'wc_update_340_state', 'wc_update_340_last_active', 'wc_update_340_db_version'), '3.4.3' => array('wc_update_343_cleanup_foreign_keys', 'wc_update_343_db_version'), '3.4.4' => array('wc_update_344_recreate_roles', 'wc_update_344_db_version'), '3.5.0' => array('wc_update_350_reviews_comment_type', 'wc_update_350_db_version'), '3.5.2' => array('wc_update_352_drop_download_log_fk'), '3.5.4' => array('wc_update_354_modify_shop_manager_caps', 'wc_update_354_db_version'), '3.6.0' => array('wc_update_360_product_lookup_tables', 'wc_update_360_term_meta', 'wc_update_360_downloadable_product_permissions_index', 'wc_update_360_db_version'), '3.7.0' => array('wc_update_370_tax_rate_classes', 'wc_update_370_mro_std_currency', 'wc_update_370_db_version'), '3.9.0' => array('wc_update_390_move_maxmind_database', 'wc_update_390_change_geolocation_database_update_cron', 'wc_update_390_db_version'), '4.0.0' => array('wc_update_product_lookup_tables', 'wc_update_400_increase_size_of_column', 'wc_update_400_reset_action_scheduler_migration_status', 'wc_admin_update_0201_order_status_index', 'wc_admin_update_0230_rename_gross_total', 'wc_admin_update_0251_remove_unsnooze_action', 'wc_update_400_db_version'), '4.4.0' => array('wc_update_440_insert_attribute_terms_for_variable_products', 'wc_admin_update_110_remove_facebook_note', 'wc_admin_update_130_remove_dismiss_action_from_tracking_opt_in_note', 'wc_update_440_db_version'), '4.5.0' => array('wc_update_450_sanitize_coupons_code', 'wc_update_450_db_version'), '5.0.0' => array('wc_update_500_fix_product_review_count', 'wc_admin_update_160_remove_facebook_note', 'wc_admin_update_170_homescreen_layout', 'wc_update_500_db_version'), '5.6.0' => array('wc_update_560_create_refund_returns_page', 'wc_update_560_db_version'), '6.0.0' => array('wc_update_600_migrate_rate_limit_options', 'wc_admin_update_270_delete_report_downloads', 'wc_admin_update_271_update_task_list_options', 'wc_admin_update_280_order_status', 'wc_admin_update_290_update_apperance_task_option', 'wc_admin_update_290_delete_default_homepage_layout_option', 'wc_update_600_db_version'), '6.3.0' => array('wc_update_630_create_product_attributes_lookup_table', 'wc_admin_update_300_update_is_read_from_last_read', 'wc_update_630_db_version'), '6.4.0' => array('wc_update_640_add_primary_key_to_product_attributes_lookup_table', 'wc_admin_update_340_remove_is_primary_from_note_action', 'wc_update_640_db_version'), '6.5.0' => array('wc_update_650_approved_download_directories'), '6.5.1' => array('wc_update_651_approved_download_directories'), '6.7.0' => array('wc_update_670_purge_comments_count_cache', 'wc_update_670_delete_deprecated_remote_inbox_notifications_option'), '7.0.0' => array('wc_update_700_remove_download_log_fk', 'wc_update_700_remove_recommended_marketing_plugins_transient'), '7.2.1' => array('wc_update_721_adjust_new_zealand_states', 'wc_update_721_adjust_ukraine_states'), '7.2.2' => array('wc_update_722_adjust_new_zealand_states', 'wc_update_722_adjust_ukraine_states'), '7.5.0' => array('wc_update_750_add_columns_to_order_stats_table', 'wc_update_750_disable_new_product_management_experience'), '7.7.0' => array('wc_update_770_remove_multichannel_marketing_feature_options'), '7.9.0' => array('wc_update_790_blockified_product_grid_block'), '8.1.0' => array('wc_update_810_migrate_transactional_metadata_for_hpos'), '8.3.0' => array('wc_update_830_rename_checkout_template', 'wc_update_830_rename_cart_template'), '8.6.0' => array('wc_update_860_remove_recommended_marketing_plugins_transient'), '8.7.0' => array('wc_update_870_prevent_listing_of_transient_files_directory'), '8.9.0' => array('wc_update_890_update_connect_to_woocommerce_note', 'wc_update_890_update_paypal_standard_load_eligibility'), '8.9.1' => array('wc_update_891_create_plugin_autoinstall_history_option'), '9.1.0' => array('wc_update_910_add_launch_your_store_tour_option', 'wc_update_910_remove_obsolete_user_meta'), '9.2.0' => array('wc_update_920_add_wc_hooked_blocks_version_option'), '9.3.0' => array('wc_update_930_add_woocommerce_coming_soon_option', 'wc_update_930_migrate_user_meta_for_launch_your_store_tour'), '9.4.0' => array('wc_update_940_add_phone_to_order_address_fts_index', 'wc_update_940_remove_help_panel_highlight_shown'), '9.5.0' => array('wc_update_950_tracking_option_autoload'), '9.6.1' => array('wc_update_961_migrate_default_email_base_color'), '9.8.0' => array('wc_update_980_remove_order_attribution_install_banner_dismissed_option'), '9.8.5' => array('wc_update_985_enable_new_payments_settings_page_feature'), '9.9.0' => array('wc_update_990_remove_wc_count_comments_transient', 'wc_update_990_remove_email_notes'), '10.0.0' => array('wc_update_1000_multisite_visibility_setting', 'wc_update_1000_remove_patterns_toolkit_transient'), '10.2.0' => array('wc_update_1020_add_old_refunded_order_items_to_product_lookup_table'), '10.3.0' => array('wc_update_1030_add_comments_date_type_index')); /** * Option name used to track new installations of WooCommerce. * @@ -26579,10 +26714,27 @@ public static function manual_database_update() * Add WC Admin based db update notice. * * @since 4.0.0 + * @deprecated 10.3.0 */ public static function wc_admin_db_update_notice() { } + /** + * Adds the db update notice. + * + * @since 10.3.0 + */ + private static function add_update_db_notice() + { + } + /** + * Removes the db update notice. + * + * @since 10.3.0 + */ + public static function remove_update_db_notice() + { + } /** * Run manual database update. */ @@ -28081,6 +28233,18 @@ public function get_cogs_value_html(): string public function get_cogs_value_per_unit_tooltip_text(): string { } + /** + * Returns the refunded Cost of Goods Sold value in html format. + * + * @param float $refunded_cost The refunded value. + * @param array|null $wc_price_arg Arguments to be passed to wc_price, defaults to an array containing only the currency symbol. + * @param WC_Order|null $order Order that contains this line item, if null, get_order will be invoked. + * + * @return string + */ + public function get_cogs_refund_value_html(float $refunded_cost, ?array $wc_price_arg = \null, ?\WC_Order $order = \null): string + { + } } /** * Order item coupon class. @@ -35205,6 +35369,22 @@ public function delete_session($customer_id) public function update_session_timestamp($customer_id, $timestamp) { } + /** + * Destroys the WooCommerce session if it contains no data for non-logged-in users. + * + * This method helps improve caching performance by removing session cookies when they + * are no longer needed, allowing non-logged-in customers to receive cached pages. + * Only runs if the destroy-empty-sessions feature is enabled. + * + * @return void + * + * @since 10.3.0 + * + * @internal For exclusive usage of WooCommerce core, backwards compatibility not guaranteed. + */ + public function destroy_session_if_empty() + { + } /** * Check if a session exists in the database. * @@ -35755,6 +35935,16 @@ class WC_Shipping_Zones public static function get_zones($context = 'admin') { } + /** + * Retrieve Shipping_Zone data objects for the given zone_ids. + * + * @param array|null $zone_ids The zone_ids of the zones to retrieve. An empty array will return no results. Use null for all zones. + * + * @return WC_Shipping_Zone[] + */ + public static function get_shipping_zones(?array $zone_ids = \null) + { + } /** * Get shipping zone using it's ID * @@ -37206,6 +37396,14 @@ private static function is_jetpack_staging_site() public static function get_tracking_data() { } + /** + * Get address autocomplete info. + * + * @return array Address autocomplete info. + */ + public static function get_address_autocomplete_info() + { + } /** * Get the current theme info, theme name and version. * @@ -37358,6 +37556,14 @@ private static function get_category_counts() private static function get_brands_counts() { } + /** + * Get migrator CLI statistics. + * + * @return array + */ + private static function get_migrator_data() + { + } /** * Get a list of all active payment gateways. * @@ -38200,7 +38406,7 @@ final class WooCommerce * * @var string */ - public $version = '10.2.2'; + public $version = '10.3.0'; /** * WooCommerce Schema version. * @@ -38340,6 +38546,16 @@ public function __set(string $key, $value) public function legacy_rest_api_is_available() { } + /** + * Get the WooCommerce version. + * + * @since 10.3.0 + * + * @return string The WooCommerce version. + */ + public function stable_version(): string + { + } /** * WooCommerce Constructor. */ @@ -39942,7 +40158,7 @@ public function read(&$order) * Set the properties of an object and log the first error found while doing so. * * @param $order WC_Order $order Order object. - * @param array $props The properties to set. + * @param array $props The properties to set. */ private function set_order_props(&$order, array $props) { @@ -40710,6 +40926,24 @@ public function get_order_count(&$customer) public function get_total_spent(&$customer) { } + /** + * Get the customer data to store in the session. + * + * @param WC_Customer $customer Customer object. + * @return array + */ + private function get_customer_session_data($customer) + { + } + /** + * Returns whether the customer data is the same as a default customer. + * + * @param array $customer_data The customer data to check. + * @return bool + */ + private function is_default_customer_data(array $customer_data): bool + { + } } /** * WC Customer Data Store. @@ -40843,6 +41077,8 @@ public function search_customers($term, $limit = '') /** * Get all user ids who have `billing_email` set to any of the email passed in array. * + * @deprecated since 10.3.0 and not used by WooCommerce core anymore. + * * @param array $emails List of emails to check against. * * @return array @@ -41744,6 +41980,15 @@ private function prime_raw_meta_cache_for_orders($order_ids, $query_vars) public function untrash_order(\WC_Order $order): bool { } + /** + * Generate meta query for total filtering with operators. + * + * @param array $total_params Total query parameters with value, operator. + * @return array|false Meta query array or false if invalid. + */ + private function generate_total_query(array $total_params) + { + } } /** * Order Item Type Data Store Interface @@ -43487,20 +43732,20 @@ public function untrash_variations($product_id) * Validate the children data by checking the structure and type of the data. * * @param array $children The children data. - * @param string $current_version The current transient version. + * @param string $deprecated Was the current transient version, unused since 10.3.0. * @return bool True if valid, false otherwise. */ - protected function validate_children_data($children, $current_version) + protected function validate_children_data($children, $deprecated) { } /** * Validate the prices data by checking the structure and type of the data. * * @param array $prices_array The prices data. - * @param string $current_version The current version of the data. + * @param string $deprecated Was the current transient version, unused since 10.3.0. * @return bool True if valid, false otherwise. */ - protected function validate_prices_data($prices_array, $current_version) + protected function validate_prices_data($prices_array, $deprecated) { } } @@ -43778,6 +44023,38 @@ public function update(&$zone) public function read(&$zone) { } + /** + * Reads multiple WC_Shipping_Zone objects from the data store. + * + * @param WC_Shipping_Zone[] $zones Array of zones to read keyed by the zone_id. + * + * @return void + * + * @throws Exception If invalid zone_id givein for data store. + */ + public function read_multiple(array &$zones) + { + } + /** + * Retrieve the zone data for the given zone_ids. + * + * @param array $ids The zone_ids to retrieve. + * + * @return stdClass[] An array of objects containing the zone data, keyed by the zone_id. + */ + private function get_zone_data_for_ids(array $ids) + { + } + /** + * Retrieve the zone location data for the given zone_ids. + * + * @param array $ids The zone_ids to retrieve. + * + * @return stdClass[] An array of objects containing the zone_id, location_code, and location_type for each zone location. + */ + private function get_zone_locations_for_ids(array $ids) + { + } /** * Deletes a shipping zone from the database. * @@ -43870,14 +44147,6 @@ public function get_zones() public function get_zone_id_by_instance_id($id) { } - /** - * Read location data from the database. - * - * @param WC_Shipping_Zone $zone Shipping zone object. - */ - private function read_zone_locations(&$zone) - { - } /** * Save locations to the DB. * This function clears old locations, then re-inserts new if any changes are found. @@ -44167,6 +44436,12 @@ class WC_Email extends \WC_Settings_API * @var bool */ protected $customer_email = \false; + /** + * Email group slug. + * + * @var string + */ + public $email_group = ''; /** * List of preg* regular expression patterns to search for, * used in conjunction with $plain_replace. @@ -44345,6 +44620,24 @@ public function setup_locale() public function restore_locale() { } + /** + * Get available email groups with their titles. + * + * @since 10.3.0 + * @return array Associative array of email group slugs => titles. + */ + public function get_email_groups() + { + } + /** + * Get the title for the current email group. + * + * @since 10.3.0 + * @return string The email group title. Falls back to the email group slug if not found. + */ + public function get_email_group_title() + { + } /** * Get email subject. * @@ -47869,6 +48162,93 @@ public function get_settings_url() { } } + /** + * Handles PayPal Buttons. + */ + class WC_Gateway_Paypal_Buttons + { + /** + * The option for the client-id. + * + * @var string + */ + private const CLIENT_ID_OPTION = 'woocommerce_paypal_client_id'; + /** + * The gateway instance. + * + * @var WC_Gateway_Paypal + */ + private $gateway; + /** + * Whether the gateway should use Orders v2 API. + * + * @var bool + */ + private $enabled = \false; + /** + * The request instance. + * + * @var WC_Gateway_Paypal_Request + */ + private $request; + /** + * Constructor. + * + * @param WC_Gateway_Paypal $gateway The gateway instance. + */ + public function __construct(\WC_Gateway_Paypal $gateway) + { + } + /** + * Get the options for the PayPal buttons. + * + * @return array + */ + public function get_options() + { + } + /** + * Get the common attributes for the PayPal JS SDK script and modules. + * + * @return array + */ + public function get_common_options() + { + } + /** + * Get the client-id for the PayPal buttons. + * + * @return string|null The PayPal client-id, or null if the request fails. + */ + public function get_client_id() + { + } + /** + * Get the page type for the PayPal buttons. + * + * @return string + */ + public function get_page_type() + { + } + /** + * Whether PayPal Buttons is enabled. + * + * @return bool + */ + public function is_enabled() + { + } + /** + * Get the current page URL, to be used for App Switch. + * Limited to checkout, cart, and product pages for security. + * + * @return string + */ + public function get_current_page_for_app_switch() + { + } + } /** * WC_Gateway_Paypal Class. */ @@ -47885,7 +48265,7 @@ class WC_Gateway_Paypal extends \WC_Payment_Gateway * * @var bool */ - public static $log_enabled = \false; + public static $log_enabled = \null; /** * Logger instance * @@ -47904,6 +48284,12 @@ class WC_Gateway_Paypal extends \WC_Payment_Gateway * @var bool */ public $debug; + /** + * The intent of the payment (capture or authorize). + * + * @var string + */ + public $intent; /** * Email address to send payments to. * @@ -47922,12 +48308,65 @@ class WC_Gateway_Paypal extends \WC_Payment_Gateway * @var string */ public $identity_token; + /** + * Jetpack connection manager. + * + * @var Jetpack_Connection_Manager + */ + private $jetpack_connection_manager; + /** + * Whether the Transact onboarding is complete. + * + * @var bool + */ + private $transact_onboarding_complete; + /** + * The *Singleton* instance of this class + * + * @var WC_Gateway_Paypal + */ + private static $instance; + /** + * Returns the *Singleton* instance of this class. + * + * @return WC_Gateway_Paypal The *Singleton* instance. + */ + public static function get_instance() + { + } + /** + * Set the instance of the gateway. + * + * @param WC_Gateway_Paypal $instance The instance of the gateway. + * @return void + */ + public static function set_instance($instance) + { + } /** * Constructor for the gateway. */ public function __construct() { } + /** + * Update the shipping and billing information for the order. + * Hooked on 'woocommerce_before_thankyou'. + * + * @param int $order_id The order ID. + * @return void + */ + public function update_addresses_in_order($order_id) + { + } + /** + * Onboard the merchant with the Transact platform. + * + * @return void + */ + public function maybe_onboard_with_transact() + { + } /** * Return whether or not this gateway still requires setup to function. * @@ -48008,6 +48447,15 @@ public function admin_options() public function init_form_fields() { } + /** + * Filter to remove fields for Orders v2. + * + * @param array $form_fields Form fields. + * @return array + */ + public function maybe_remove_fields($form_fields) + { + } /** * Get the transaction URL. * @@ -48022,6 +48470,7 @@ public function get_transaction_url($order) * * @param int $order_id Order ID. * @return array + * @throws Exception If the PayPal order creation fails. */ public function process_payment($order_id) { @@ -48068,6 +48517,29 @@ public function capture_payment($order_id) public function admin_scripts() { } + /** + * Enqueue scripts. + */ + public function enqueue_scripts() + { + } + /** + * Add PayPal SDK attributes to the script. + * + * @param array $attrs Attributes. + * @return array + */ + public function add_paypal_sdk_attributes($attrs) + { + } + /** + * Builds the PayPal payment fields area. + * + * @since 10.3.0 + */ + public function render_buttons_container() + { + } /** * Custom PayPal order received text. * @@ -48079,6 +48551,16 @@ public function admin_scripts() public function order_received_text($text, $order) { } + /** + * Hide "Pay" and "Cancel" action buttons for pending orders as orders v2 takes a while to be captured. + * + * @param array $actions An array with the default actions. + * @param WC_Order $order The order. + * @return array + */ + public function hide_action_buttons($actions, $order) + { + } /** * Determines whether PayPal Standard should be loaded or not. * @@ -48099,6 +48581,38 @@ public function should_load() public function has_paypal_orders() { } + /** + * Check if the gateway should use Orders v2 API. + * + * @return bool + */ + public function should_use_orders_v2() + { + } + /** + * Get the Jetpack connection manager. + * + * @return Jetpack_Connection_Manager + */ + public function get_jetpack_connection_manager() + { + } + /** + * Whether the Transact onboarding is complete. + * + * @return bool + */ + public function is_transact_onboarding_complete() + { + } + /** + * Set the Transact onboarding as complete. + * + * @return void + */ + public function set_transact_onboarding_complete() + { + } } /** * Handles Refunds and other API requests such as capture. @@ -48207,6 +48721,64 @@ public static function refund_order($order, $amount = \null, $reason = '', $sand { } } + /** + * WC_Gateway_Paypal_Constants Class. + */ + class WC_Gateway_Paypal_Constants + { + /** + * PayPal proxy request timeout. + */ + const WPCOM_PROXY_REQUEST_TIMEOUT = 60; + /** + * PayPal payment statuses. + */ + const STATUS_COMPLETED = 'COMPLETED'; + const STATUS_APPROVED = 'APPROVED'; + const STATUS_CAPTURED = 'CAPTURED'; + /** + * PayPal payment intents. + */ + const INTENT_CAPTURE = 'CAPTURE'; + const INTENT_AUTHORIZE = 'AUTHORIZE'; + /** + * PayPal payment actions. + */ + const PAYMENT_ACTION_CAPTURE = 'capture'; + const PAYMENT_ACTION_AUTHORIZE = 'authorize'; + /** + * PayPal shipping preferences. + */ + const SHIPPING_NO_SHIPPING = 'NO_SHIPPING'; + const SHIPPING_GET_FROM_FILE = 'GET_FROM_FILE'; + const SHIPPING_SET_PROVIDED_ADDRESS = 'SET_PROVIDED_ADDRESS'; + /** + * PayPal user actions. + */ + const USER_ACTION_PAY_NOW = 'PAY_NOW'; + /** + * Maximum lengths for PayPal fields. + */ + const PAYPAL_ORDER_ITEM_NAME_MAX_LENGTH = 127; + const PAYPAL_INVOICE_ID_MAX_LENGTH = 127; + const PAYPAL_ADDRESS_LINE_MAX_LENGTH = 300; + const PAYPAL_STATE_MAX_LENGTH = 300; + const PAYPAL_CITY_MAX_LENGTH = 120; + const PAYPAL_POSTAL_CODE_MAX_LENGTH = 60; + /** + * Supported payment sources. + */ + const PAYMENT_SOURCE_PAYPAL = 'paypal'; + const PAYMENT_SOURCE_VENMO = 'venmo'; + const PAYMENT_SOURCE_PAYLATER = 'paylater'; + const SUPPORTED_PAYMENT_SOURCES = array(self::PAYMENT_SOURCE_PAYPAL, self::PAYMENT_SOURCE_VENMO, self::PAYMENT_SOURCE_PAYLATER); + /** + * Fields to redact from logs. + * + * @var array + */ + const FIELDS_TO_REDACT = array('given_name', 'surname', 'full_name', 'address_line_1', 'address_line_2', 'admin_area_1', 'admin_area_2', 'postal_code', 'phone', 'phone_number', 'national_number'); + } /** * Helper for PayPal gateway. */ @@ -48228,6 +48800,36 @@ public static function is_paypal_gateway_available() public static function is_orders_v2_migration_eligible() { } + /** + * Get the WC order from the PayPal custom ID. + * + * @param string $custom_id The custom ID string from the PayPal order. + * @return WC_Order|null + */ + public static function get_wc_order_from_paypal_custom_id($custom_id) + { + } + /** + * Remove PII (Personally Identifiable Information) from data for logging. + * + * This function recursively traverses the data array and redacts sensitive information + * while preserving the structure for debugging purposes. + * + * @param mixed $data The data to remove PII from (array, string, or other types). + * @return mixed The data with PII redacted. + */ + public static function redact_data($data) + { + } + /** + * Mask email address before @ keeping the full domain. + * + * @param string $email The email address to mask. + * @return string The masked email address or original input if invalid. + */ + public static function mask_email($email) + { + } } /** * Handles Responses. @@ -48459,6 +49061,12 @@ protected function send_ipn_email_notification($subject, $message) */ class WC_Gateway_Paypal_Notices { + /** + * The PayPal gateway instance. + * + * @var WC_Gateway_Paypal + */ + private $gateway; /** * Constructor. */ @@ -48581,6 +49189,28 @@ class WC_Gateway_Paypal_Request * @var string */ protected $endpoint; + /** + * The API version for the proxy endpoint. + * + * @var int + */ + private const WPCOM_PROXY_ENDPOINT_API_VERSION = 2; + /** + * The base for the proxy REST endpoint. + * + * @var string + */ + private const WPCOM_PROXY_REST_BASE = 'transact/paypal_standard/proxy'; + /** + * Proxy REST endpoints. + * + * @var string + */ + private const WPCOM_PROXY_ORDER_ENDPOINT = 'order'; + private const WPCOM_PROXY_PAYMENT_CAPTURE_ENDPOINT = 'payment/capture'; + private const WPCOM_PROXY_PAYMENT_AUTHORIZE_ENDPOINT = 'payment/authorize'; + private const WPCOM_PROXY_PAYMENT_CAPTURE_AUTH_ENDPOINT = 'payment/capture_auth'; + private const WPCOM_PROXY_CLIENT_ID_ENDPOINT = 'client_id'; /** * Constructor. * @@ -48599,6 +49229,164 @@ public function __construct($gateway) public function get_request_url($order, $sandbox = \false) { } + /** + * Create a PayPal order using the Orders v2 API. + * + * This method creates a PayPal order and returns the order details including + * the approval URL where customers will be redirected to complete payment. + * + * @param WC_Order $order Order object. + * @param string $payment_source The payment source. + * @param array $js_sdk_params Extra parameters for a PayPal JS SDK (Buttons) request. + * @return array|null + * @throws Exception If the PayPal order creation fails. + */ + public function create_paypal_order($order, $payment_source = \WC_Gateway_Paypal_Constants::PAYMENT_SOURCE_PAYPAL, $js_sdk_params = array()) + { + } + /** + * Get PayPal order details. + * + * @param string $paypal_order_id The ID of the PayPal order. + * @return array + * @throws Exception If the PayPal order details request fails. + * @throws Exception If the PayPal order details are not found. + */ + public function get_paypal_order_details($paypal_order_id) + { + } + /** + * Authorize or capture a PayPal payment using the Orders v2 API. + * + * This method authorizes or captures a PayPal payment and updates the order status. + * + * @param WC_Order $order Order object. + * @param string $action_url The URL to authorize or capture the payment. + * @param string $action The action to perform. Either 'authorize' or 'capture'. + * @return void + * @throws Exception If the PayPal payment authorization or capture fails. + */ + public function authorize_or_capture_payment($order, $action_url, $action = \WC_Gateway_Paypal_Constants::PAYMENT_ACTION_CAPTURE) + { + } + /** + * Capture a PayPal payment that has been authorized. + * + * @param WC_Order $order Order object. + * @return void + * @throws Exception If the PayPal payment capture fails. + */ + public function capture_authorized_payment($order) + { + } + /** + * Get the approve link from the response data. + * + * @param int $http_code The HTTP code of the response. + * @param array $response_data The response data. + * @return string|null + */ + private function get_approve_link($http_code, $response_data) + { + } + /** + * Build the request parameters for the PayPal create-order request. + * + * @param WC_Order $order Order object. + * @param string $payment_source The payment source. + * @param array $js_sdk_params Extra parameters for a PayPal JS SDK (Buttons) request. + * @return array + */ + private function get_paypal_create_order_request_params($order, $payment_source, $js_sdk_params) + { + } + /** + * Get the amount data for the PayPal order purchase unit field. + * + * @param WC_Order $order Order object. + * @return array + */ + public function get_paypal_order_purchase_unit_amount($order) + { + } + /** + * Build the custom ID for the PayPal order. The custom ID will be used by the proxy for webhook forwarding, + * and by later steps to identify the order. + * + * @param WC_Order $order Order object. + * @return string + * @throws Exception If the custom ID is too long. + */ + private function get_paypal_order_custom_id($order) + { + } + /** + * Get the order items for the PayPal create-order request. + * + * @param WC_Order $order Order object. + * @return array + */ + private function get_paypal_order_items($order) + { + } + /** + * Get the subtotal for all items, before discounts. + * + * @param WC_Order $order Order object. + * @return float + */ + private function get_paypal_order_items_subtotal($order) + { + } + /** + * Get the value for the intent field in the create-order request. + * + * @return string + */ + private function get_paypal_order_intent() + { + } + /** + * Get the shipping preference for the PayPal create-order request. + * + * @param WC_Order $order Order object. + * @return string + */ + private function get_paypal_shipping_preference($order) + { + } + /** + * Get the shipping information for the PayPal create-order request. + * + * @param WC_Order $order Order object. + * @return array|null Returns null if the shipping is not required, + * or the address is not set, or is incomplete. + */ + private function get_paypal_order_shipping($order) + { + } + /** + * Fetch the PayPal client-id from the Transact platform. + * + * @return string|null The PayPal client-id, or null if the request fails. + * @throws Exception If the request fails. + */ + public function fetch_paypal_client_id() + { + } + /** + * Send a request to the API proxy. + * + * @param string $method The HTTP method to use. + * @param string $endpoint The endpoint to request. + * @param array $request_body The request body. + * + * @return array|null The API response body, or null if the request fails. + * @throws Exception If the site ID is not found. + */ + private function send_wpcom_proxy_request($method, $endpoint, $request_body) + { + } /** * Limit length of an arg. * @@ -48790,6 +49578,211 @@ protected function number_format($price, $order) { } } + /** + * Handles Transact account management. + */ + final class WC_Gateway_Paypal_Transact_Account_Manager + { + /** + * The API version for the proxy endpoint. + * + * @var int + */ + private const WPCOM_PROXY_ENDPOINT_API_VERSION = 2; + /** + * Transact provider type, for provider onboarding. + * + * @var string + */ + private const TRANSACT_PROVIDER_TYPE = 'paypal_standard'; + /** + * Cache keys for the merchant and provider accounts. + * + * @var string + */ + private const TRANSACT_MERCHANT_ACCOUNT_CACHE_KEY_LIVE = 'woocommerce_paypal_transact_merchant_account_live'; + private const TRANSACT_MERCHANT_ACCOUNT_CACHE_KEY_TEST = 'woocommerce_paypal_transact_merchant_account_test'; + private const TRANSACT_PROVIDER_ACCOUNT_CACHE_KEY_LIVE = 'woocommerce_paypal_transact_provider_account_live'; + private const TRANSACT_PROVIDER_ACCOUNT_CACHE_KEY_TEST = 'woocommerce_paypal_transact_provider_account_test'; + /** + * The expiry time for the Transact account cache. + * + * @var int + */ + private const TRANSACT_ACCOUNT_CACHE_EXPIRY = 60 * 60 * 24; + // 24 hours. + /** + * Paypal gateway object. + * + * @var WC_Gateway_Paypal + */ + private $gateway; + /** + * Constructor. + * + * @param WC_Gateway_Paypal $gateway Paypal gateway object. + */ + public function __construct(\WC_Gateway_Paypal $gateway) + { + } + /** + * Onboard the merchant with the Transact platform. + * + * @return void + */ + public function do_onboarding() + { + } + /** + * Get the Transact account (merchant or provider) data. Performs a fetch if the account + * is not in cache or expired. + * + * @param string $account_type The type of account to get (merchant or provider). + * @return array|null Returns null if the transact account cannot be retrieved. + */ + public function get_transact_account_data($account_type) + { + } + /** + * Get the cache key for the transact account. + * + * @param string $account_type The type of account to get (merchant or provider). + * @return string|null The cache key, or null if the account type is invalid. + */ + private function get_cache_key($account_type) + { + } + /** + * Fetch the merchant account from the Transact platform. + * + * @return array|null The API response body, or null if the request fails. + */ + private function fetch_merchant_account() + { + } + /** + * Fetch the provider account from the Transact platform. + * + * @return bool True if the provider account exists, false otherwise. + */ + private function fetch_provider_account() + { + } + /** + * Create the merchant account with the Transact platform. + * + * @return array|null The API response body, or null if the request fails. + */ + private function create_merchant_account() + { + } + /** + * Create the provider account with the Transact platform. + * + * @return bool True if the provider account creation was successful, false otherwise. + */ + private function create_provider_account() + { + } + /** + * Update the transact account (merchant or provider) cache. + * + * @param string $cache_key The cache key to update. + * @param array $account_data The transact account data. + */ + private function update_transact_account_cache($cache_key, $account_data) + { + } + /** + * Get the transact account (merchant or provider) from the database cache. + * + * @param string $cache_key The cache key to get the account. + * @return bool|null The transact account data, or null if the cache is + * empty or expired. + */ + private function get_transact_account_from_cache($cache_key) + { + } + /** + * Send a request to the Transact platform. + * + * @param string $method The HTTP method to use. + * @param string $endpoint The endpoint to request. + * @param array $request_body The request body. + * + * @return array|null The API response body, or null if the request fails. + */ + private function send_transact_api_request($method, $endpoint, $request_body) + { + } + } + /** + * Handles webhook events. + */ + class WC_Gateway_Paypal_Webhook_Handler + { + /** + * Process the webhook event. + * + * @param WP_REST_Request $request The request object. + */ + public function process_webhook(\WP_REST_Request $request) + { + } + /** + * Process the CHECKOUT.ORDER.APPROVED webhook event. + * + * @param array $event The webhook event data. + */ + private function process_checkout_order_approved($event) + { + } + /** + * Process the PAYMENT.CAPTURE.COMPLETED webhook event. + * + * @param array $event The webhook event data. + */ + private function process_payment_capture_completed($event) + { + } + /** + * Process the PAYMENT.CAPTURE.PENDING webhook event. + * + * @param array $event The webhook event data. + */ + private function process_payment_capture_pending($event) + { + } + /** + * Process the PAYMENT.AUTHORIZATION.CREATED webhook event. + * + * @param array $event The webhook event data. + */ + private function process_payment_authorization_created($event) + { + } + /** + * Capture the payment. + * + * @param WC_Order $order The order object. + * @param array $links The links from the webhook event. + * @param string $action The action to perform (capture or authorize). + * @return void + */ + private function authorize_or_capture_payment($order, $links, $action) + { + } + /** + * Get the action URL from the links. + * + * @param array $links The links from the webhook event. + * @param string $action The action to perform (capture or authorize). + * @return string|null + */ + private function get_action_url($links, $action) + { + } + } /** * WooCommerce Importer Interface * @@ -58191,6 +59184,213 @@ private function flatten_options_keys(array $options): array { } } + /** + * REST API PayPal buttons controller class. + * + * @package WooCommerce\RestApi + * @extends WC_REST_Controller + */ + class WC_REST_Paypal_Buttons_Controller extends \WC_REST_Controller + { + /** + * Endpoint namespace. + * + * @var string + */ + protected $namespace = 'wc/v3'; + /** + * Route base. + * + * @var string + */ + protected $rest_base = 'paypal-buttons'; + /** + * Register the routes for the PayPal buttons functionality handler. + * + * @return void + */ + public function register_routes() + { + } + /** + * Validate the create order request. + * + * @param WP_REST_Request $request The request object. + * @return bool True if the create order request is valid, false otherwise. + */ + public function validate_create_order_request(\WP_REST_Request $request) + { + } + /** + * Validate the cancel payment request. + * + * @param WP_REST_Request $request The request object. + * @return bool True if the cancel payment request is valid, false otherwise. + */ + public function validate_cancel_payment_request(\WP_REST_Request $request) + { + } + /** + * Create a PayPal order. + * + * @param WP_REST_Request $request The request object. + * @return WP_REST_Response The response object. + */ + public function create_order(\WP_REST_Request $request) + { + } + /** + * Cancel a PayPal payment. This is used to move the woocommerce order back to a draft status. + * + * @param WP_REST_Request $request The request object. + * @return WP_REST_Response The response object. + */ + public function cancel_payment(\WP_REST_Request $request) + { + } + } + /** + * REST API PayPal Standard controller class. + * + * @package WooCommerce\RestApi + * @extends WC_REST_Controller + */ + class WC_REST_Paypal_Standard_Controller extends \WC_REST_Controller + { + /** + * Endpoint namespace. + * + * @var string + */ + protected $namespace = 'wc/v3'; + /** + * Route base. + * + * @var string + */ + protected $rest_base = 'paypal-standard'; + /** + * Register the routes for PayPal Standard REST API requests. + * + * @return void + */ + public function register_routes() + { + } + /** + * Callback for when the customer updates their shipping details in PayPal. + * https://developer.paypal.com/docs/checkout/standard/customize/shipping-module/#server-side-shipping-callbacks + * + * @param WP_REST_Request $request The request object. + * @return WP_REST_Response The response object. + */ + public function process_shipping_callback(\WP_REST_Request $request) + { + } + /** + * Rebuild the session cart. + * + * @param WC_Order $order The order object. + * @return void + */ + private function rebuild_cart_from_order($order) + { + } + /** + * Recompute the fees for the order. + * + * @param WC_Order $order The order object. + * @return void + */ + private function recompute_fees($order) + { + } + /** + * Update the WooCommerce order with the new shipping address. + * + * @param WC_Order $order The order object. + * @param array $shipping_address The shipping address. + * @return void + */ + private function update_order_shipping_address($order, $shipping_address) + { + } + /** + * Get the shipping options for the order. + * + * @param WC_Order $order The order object. + * @param array $selected_shipping_option The selected shipping option. + * @return array The shipping options. + */ + private function get_updated_shipping_options($order, $selected_shipping_option) + { + } + /** + * Get the shipping rate id from the order. + * + * @param WC_Order $order The order object. + * @return string The shipping rate id. + */ + private function get_order_shipping_rate_id($order) + { + } + /** + * Get the error response for the update shipping request. + * + * @param string $issue The issue with the shipping address. + * @return array The error response. + */ + private function get_update_shipping_error_response($issue = 'ADDRESS_ERROR') + { + } + } + /** + * REST API PayPal webhook handler controller class. + * + * @package WooCommerce\RestApi + * @extends WC_REST_Controller + */ + class WC_REST_Paypal_Webhooks_Controller extends \WC_REST_Controller + { + /** + * Endpoint namespace. + * + * @var string + */ + protected $namespace = 'wc/v3'; + /** + * Route base. + * + * @var string + */ + protected $rest_base = 'paypal-webhooks'; + /** + * Register the routes for the PayPal webhook handler. + * + * @return void + */ + public function register_routes() + { + } + /** + * Validate the webhook. + * + * @param WP_REST_Request $request The request object. + * @return bool True if the webhook is valid, false otherwise. + */ + public function validate_webhook(\WP_REST_Request $request) + { + } + /** + * Process the webhook. + * + * @param WP_REST_Request $request The request object. + * @return WP_REST_Response The response object. + */ + public function process_webhook(\WP_REST_Request $request) + { + } + } /** * REST API Product Attribute Terms controller class. * @@ -59697,6 +60897,36 @@ private function adjust_cities_and_postcodes(&$request) { } } + /** + * REST API variations controller class. + * + * @package WooCommerce\RestApi + * @extends WC_REST_Product_Variations_Controller + */ + class WC_REST_Variations_Controller extends \WC_REST_Product_Variations_Controller + { + /** + * Route base. + * + * @var string + */ + protected $rest_base = 'variations'; + /** + * Register the routes for variations. + */ + public function register_routes() + { + } + /** + * Prepare objects query. + * + * @param WP_REST_Request $request Full details about the request. + * @return array + */ + protected function prepare_objects_query($request) + { + } + } /** * REST API Webhooks controller class. * @@ -59721,4731 +60951,5630 @@ protected function get_default_api_version() { } } -} -namespace Automattic\WooCommerce\RestApi { /** - * Main package class. + * WooCommerce REST API Version 4 Base Controller * - * @deprecated Use \Automattic\WooCommerce\RestApi\Server directly. + * @package WooCommerce\RestApi + * @extends WP_REST_Controller + * @version 4.0.0 */ - class Package + abstract class WC_REST_V4_Controller extends \WP_REST_Controller { /** - * Version. + * Endpoint namespace. * - * @deprecated since 4.5.0. This tracks WooCommerce version now. * @var string */ - const VERSION = WC_VERSION; + protected $namespace = 'wc/v4'; /** - * Init the package - load the REST API Server class. + * Route base. * - * @deprecated since 4.5.0. Directly call Automattic\WooCommerce\RestApi\Server::instance()->init() + * @var string */ - public static function init() + protected $rest_base = ''; + /** + * Check permissions for a given request. + * + * @param WP_REST_Request $request Full details about the request. + * @param string $permission The permission to check for. + * @return bool|WP_Error + */ + protected function check_permissions($request, $permission = 'read') { } /** - * Return the version of the package. + * Get the default REST API version. * - * @deprecated since 4.5.0. This tracks WooCommerce version now. * @return string */ - public static function get_version() + protected function get_api_version() { } /** - * Return the path to the package. + * Prepare a response for inserting into a collection. * - * @deprecated since 4.5.0. Directly call Automattic\WooCommerce\RestApi\Server::get_path() - * @return string + * @param WP_REST_Response $response Response object. + * @return array Response data. */ - public static function get_path() + public function prepare_response_for_collection($response) + { + } + /** + * Get the base schema for the API. + * + * @return array + */ + protected function get_base_schema() { } } -} -namespace Automattic\WooCommerce\RestApi\Utilities { /** - * Singleton trait. + * WooCommerce REST API Version 4 Fulfillments Controller + * + * @package WooCommerce\RestApi + * @extends WC_REST_V4_Controller + * @version 4.0.0 */ - trait SingletonTrait + class WC_REST_Fulfillments_V4_Controller extends \WC_REST_V4_Controller { /** - * The single instance of the class. + * Endpoint namespace. * - * @var object + * @var string */ - protected static $instance = null; + protected $namespace = 'wc/v4'; /** - * Constructor + * Route base. * - * @return void + * @var string */ - protected function __construct() - { - } + protected $rest_base = 'fulfillments'; /** - * Get class instance. + * Order fulfillments controller instance. * - * @return object Instance. + * @var OrderFulfillmentsRestController */ - final public static function instance() + protected $order_fulfillments_controller; + /** + * Constructor. + * + * @since 4.0.0 + */ + public function __construct() { } /** - * Prevent cloning. + * Register the routes for fulfillments. + * + * @since 4.0.0 */ - private function __clone() + public function register_routes() { } /** - * Prevent unserializing. + * Get a list of fulfillments for a specific order. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_REST_Response */ - final public function __wakeup() + public function get_fulfillments(\WP_REST_Request $request): \WP_REST_Response { } - } -} -namespace Automattic\WooCommerce\RestApi { - /** - * Class responsible for loading the REST API and all REST API namespaces. - */ - class Server - { - use \Automattic\WooCommerce\RestApi\Utilities\SingletonTrait; /** - * REST API namespaces and endpoints. + * Create a fulfillment for a specific order. * - * @var array + * @param WP_REST_Request $request Full details about the request. + * @return WP_REST_Response */ - protected $controllers = array(); + public function create_fulfillment(\WP_REST_Request $request): \WP_REST_Response + { + } /** - * Hook into WordPress ready to init the REST API as needed. + * Get a specific fulfillment for a specific order. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_REST_Response */ - public function init() + public function get_fulfillment(\WP_REST_Request $request): \WP_REST_Response { } /** - * Register REST API routes. + * Update a specific fulfillment for a specific order. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_REST_Response */ - public function register_rest_routes() + public function update_fulfillment(\WP_REST_Request $request): \WP_REST_Response { } /** - * Get API namespaces - new namespaces should be registered here. + * Delete a specific fulfillment for a specific order. * - * @return array List of Namespaces and Main controller classes. + * @param WP_REST_Request $request Full details about the request. + * @return WP_REST_Response */ - protected function get_rest_namespaces() + public function delete_fulfillment(\WP_REST_Request $request): \WP_REST_Response { } /** - * List of controllers in the wc/v1 namespace. + * Permission check for REST API endpoints, given the request method. + * For all fulfillments methods that have an order_id, we need to be sure the user has permission to view the order. + * For all other methods, we check if the user is logged in as admin and has the required capability. * - * @return array + * @param WP_REST_Request $request The request for which the permission is checked. + * @return bool|\WP_Error True if the current user has the capability, otherwise an "Unauthorized" error or False if no error is available for the request method. + * + * @throws \WP_Error If the URL contains an order, but the order does not exist. */ - protected function get_v1_controllers() + public function check_permission_for_fulfillments(\WP_REST_Request $request) { } /** - * List of controllers in the wc/v2 namespace. + * Returns an authentication error message for a given HTTP verb. * - * @return array + * @param string $method HTTP method. + * @return array|null Error information on success, null otherwise. */ - protected function get_v2_controllers() + protected function get_authentication_error_by_method(string $method) { } /** - * List of controllers in the wc/v3 namespace. + * Get the arguments for the get order fulfillments endpoint. * * @return array */ - protected function get_v3_controllers() + private function get_args_for_get_fulfillments(): array { } /** - * List of controllers in the telemetry namespace. + * Get the schema for the get order fulfillments endpoint. * * @return array */ - protected function get_telemetry_controllers() + private function get_schema_for_get_fulfillments(): array { } /** - * Return the path to the package. + * Get the arguments for the create fulfillment endpoint. * - * @return string + * @return array */ - public static function get_path() + private function get_args_for_create_fulfillment(): array { } - } -} -namespace Automattic\WooCommerce\RestApi\Utilities { - /** - * ImageAttachment class. - */ - class ImageAttachment - { /** - * Attachment ID. + * Get the schema for the create fulfillment endpoint. * - * @var integer + * @return array */ - public $id = 0; + private function get_schema_for_create_fulfillment(): array + { + } /** - * Object attached to. + * Get the arguments for the get fulfillment endpoint. * - * @var integer + * @return array */ - public $object_id = 0; + private function get_args_for_get_fulfillment(): array + { + } /** - * Constructor. + * Get the schema for the get fulfillment endpoint. * - * @param integer $id Attachment ID. - * @param integer $object_id Object ID. + * @return array */ - public function __construct($id = 0, $object_id = 0) + private function get_schema_for_get_fulfillment(): array { } /** - * Upload an attachment file. + * Get the arguments for the update fulfillment endpoint. * - * @throws \WC_REST_Exception REST API exceptions. - * @param string $src URL to file. + * @return array */ - public function upload_image_from_src($src) + private function get_args_for_update_fulfillment(): array { } /** - * Update attachment alt text. + * Get the schema for the update fulfillment endpoint. * - * @param string $text Text to set. + * @return array */ - public function update_alt_text($text) + private function get_schema_for_update_fulfillment(): array { } /** - * Update attachment name. + * Get the arguments for the delete fulfillment endpoint. * - * @param string $text Text to set. + * @return array */ - public function update_name($text) + private function get_args_for_delete_fulfillment(): array { } - } -} -namespace { - /** - * WC_Shipping_Flat_Rate class. - */ - class WC_Shipping_Flat_Rate extends \WC_Shipping_Method - { /** - * Cost passed to [fee] shortcode. + * Get the schema for the delete fulfillment endpoint. * - * @var string Cost. + * @return array */ - protected $fee_cost = ''; + private function get_schema_for_delete_fulfillment(): array + { + } /** - * Shipping method cost. + * Get the base schema for the fulfillment with a read context. * - * @var string + * @return array */ - public $cost; + private function get_read_schema_for_fulfillment() + { + } /** - * Shipping method type. + * Get the base args for the fulfillment with a write context. * - * @var string - */ - public $type; - /** - * Constructor. + * @param bool $is_create Whether the args list is for a create request. * - * @param int $instance_id Shipping method instance ID. + * @return array */ - public function __construct($instance_id = 0) + private function get_write_args_for_fulfillment(bool $is_create = \false) { } /** - * Init user set variables. + * Get the schema for the meta data. + * + * @return array */ - public function init() + private function get_schema_for_meta_data(): array { } /** - * Evaluate a cost from a sum/string. + * Prepare an error response. * - * @param string $sum Sum of shipping. - * @param array $args Args, must contain `cost` and `qty` keys. Having `array()` as default is for back compat reasons. - * @return string + * @param string $code The error code. + * @param string $message The error message. + * @param array $data Additional error data, including 'status' key for HTTP status code. + * + * @return WP_REST_Response The error response. */ - protected function evaluate_cost($sum, $args = array()) + private function prepare_error_response($code, $message, $data): \WP_REST_Response { } + } + /** + * REST API Ping controller class. + * + * @package WooCommerce\RestApi + * @extends WC_REST_V4_Controller + */ + class WC_REST_Ping_V4_Controller extends \WC_REST_V4_Controller + { /** - * Work out fee (shortcode). + * Route base. * - * @param array $atts Attributes. - * @return string + * @var string */ - public function fee($atts) - { - } + protected $rest_base = 'ping'; /** - * Calculate the shipping costs. + * Register the routes for ping. * - * @param array $package Package of items from cart. + * @since 4.0.0 */ - public function calculate_shipping($package = array()) + public function register_routes() { } /** - * Get items in package. + * Check whether a given request has permission to read ping. * - * @param array $package Package of items from cart. - * @return int + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean */ - public function get_package_item_qty($package) + public function get_ping_permissions_check($request) { } /** - * Finds and returns shipping classes and the products with said class. + * Get ping response. * - * @param mixed $package Package of items from cart. - * @return array + * @since 4.0.0 + * @param WP_REST_Request $request Request data. + * @return WP_Error|WP_REST_Response */ - public function find_shipping_classes($package) + public function get_ping($request) { } /** - * Sanitize the cost field. + * Get the ping schema, conforming to JSON Schema. * - * @since 3.4.0 - * @param string $value Unsanitized value. - * @throws Exception Last error triggered. - * @return string + * @since 4.0.0 + * @return array */ - public function sanitize_cost($value) + public function get_item_schema() { } } /** - * Free Shipping Method. - * - * A simple shipping method for free shipping. + * REST API Products controller class. * - * @class WC_Shipping_Free_Shipping - * @version 2.6.0 - * @package WooCommerce\Classes\Shipping + * @package WooCommerce\RestApi + * @extends WC_REST_Products_V2_Controller */ - class WC_Shipping_Free_Shipping extends \WC_Shipping_Method + class WC_REST_Products_V4_Controller extends \WC_REST_Products_V2_Controller { + use \Automattic\WooCommerce\Internal\CostOfGoodsSold\CogsAwareRestControllerTrait; /** - * Min amount to be valid. + * Endpoint namespace. * - * @var integer + * @var string */ - public $min_amount = 0; + protected $namespace = 'wc/v4'; /** - * Requires option. + * The value of the 'search_sku' argument if present. + * + * See prepare_objects_query() * * @var string */ - public $requires = ''; + private $search_sku_arg_value = ''; /** - * Ignore discounts. + * If the 'search_name_or_sku' argument is present this will be set + * to an array of the (space-separated) tokens that form the argument value. * - * If set, free shipping would be available based on pre-discount order amount. + * @var array|null + */ + private $search_name_or_sku_tokens = \null; + /** + * If the 'search_fields' argument is present with 'search' this will be set + * to an array containing the fields to search and tokenized search terms. * - * @var string + * @var array|null */ - public $ignore_discounts; + private $search_fields_tokens = \null; /** - * Constructor. + * Suggested product ids. * - * @param int $instance_id Shipping method instance. + * @var array */ - public function __construct($instance_id = 0) - { - } + private $suggested_products_ids = array(); /** - * Initialize free shipping. + * Product statuses to exclude from the query. + * + * @var array */ - public function init() - { - } + private $exclude_status = array(); /** - * Sanitize the cost field. + * Stores attachment IDs processed during the current request for potential cleanup. * - * @since 8.3.0 - * @param string $value Unsanitized value. - * @throws Exception Last error triggered. - * @return string + * @var array */ - public function sanitize_cost($value) - { - } + private $processed_attachment_ids_for_request = array(); /** - * Init form fields. + * Register the routes for products. */ - public function init_form_fields() + public function register_routes() { } /** - * Get setting form fields for instances of this shipping method within zones. + * Duplicate a product and returns the duplicated product. + * The product status is set to "draft" and the name includes a "(copy)" at the end by default. * - * @return array + * @param WP_REST_Request $request Request data. + * @return WP_REST_Response|WP_Error */ - public function get_instance_form_fields() + public function duplicate_product($request) { } /** - * See if free shipping is available based on the package and cart. + * Get the images for a product or product variation. * - * @param array $package Shipping package. - * @return bool + * @param WC_Product|WC_Product_Variation $product Product instance. + * @return array */ - public function is_available($package) + protected function get_images($product) { } /** - * Called to calculate shipping rates for this method. Rates can be added using the add_rate() method. - * - * @uses WC_Shipping_Method::add_rate() + * Make extra product orderby features supported by WooCommerce available to the WC API. + * This includes 'price', 'popularity', and 'rating'. * - * @param array $package Shipping package. + * @param WP_REST_Request $request Request data. + * @return array */ - public function calculate_shipping($package = array()) + protected function prepare_objects_query($request) { } /** - * Enqueue JS to handle free shipping options. + * Get objects. * - * Static so that's enqueued only once. + * @param array $query_args Query args. + * @return array */ - public static function enqueue_admin_js() + protected function get_objects($query_args) { } - } - /** - * Flat Rate Shipping Method. - * - * This class is here for backwards compatibility for methods existing before zones existed. - * - * @deprecated 2.6.0 - * @version 2.4.0 - * @package WooCommerce\Classes\Shipping - */ - class WC_Shipping_Legacy_Flat_Rate extends \WC_Shipping_Method - { - /** - * Cost passed to [fee] shortcode. - * - * @var string - */ - protected $fee_cost = ''; - /** - * Shipping method cost. - * - * @var string - */ - public $cost; /** - * Shipping method type. + * Join `wc_product_meta_lookup` table when SKU search query is present. * - * @var string + * @param string $join Join clause used to search posts. + * @return string */ - public $type; + public function add_search_criteria_to_wp_query_join($join) + { + } /** - * Shipping method options. + * Add a where clause for matching the SKU field. * - * @deprecated 2.4.0 - * @var string - */ - public $options; - /** - * Constructor. + * @param string $where Where clause used to search posts. + * @return string */ - public function __construct() + public function add_search_criteria_to_wp_query_where($where) { } /** - * Process and redirect if disabled. + * Build search clauses for dynamic product search. + * + * @param array $tokens Search tokens. + * @param array $fields Fields to search in. + * @return string */ - public function process_admin_options() + private function build_dynamic_search_clauses($tokens, $fields) { } /** - * Return the name of the option in the WP DB. + * Exclude product statuses from the query. * - * @since 2.6.0 + * @param string $where Where clause used to search posts. * @return string */ - public function get_option_key() + public function exclude_product_statuses($where) { } /** - * Init function. + * Set product images. + * + * @throws WC_REST_Exception REST API exceptions. + * @param WC_Product $product Product instance. + * @param array $images Images data. + * @return WC_Product */ - public function init() + protected function set_product_images($product, $images) { } /** - * Initialise Settings Form Fields. + * Prepare a single product for create or update. + * + * @param WP_REST_Request $request Request object. + * @param bool $creating If is creating a new object. + * @return WP_Error|WC_Data */ - public function init_form_fields() + protected function prepare_object_for_database($request, $creating = \false) { } /** - * Evaluate a cost from a sum/string. + * Get the Product's schema, conforming to JSON Schema. * - * @param string $sum Sum to evaluate. - * @param array $args Arguments. - * @return string + * @return array */ - protected function evaluate_cost($sum, $args = array()) + public function get_item_schema() { } /** - * Work out fee (shortcode). + * Add new options for 'orderby' to the collection params. * - * @param array $atts Shortcode attributes. - * @return string + * @return array */ - public function fee($atts) + public function get_collection_params() { } /** - * Calculate shipping. + * Add new options for the suggested-products endpoint. * - * @param array $package (default: array()). + * @return array */ - public function calculate_shipping($package = array()) + public function get_suggested_products_collection_params() { } /** - * Get items in package. + * Get the downloads for a product. * - * @param array $package Package information. - * @return int + * @param WC_Product $product Product instance. + * + * @return array */ - public function get_package_item_qty($package) + protected function get_downloads($product) { } /** - * Finds and returns shipping classes and the products with said class. + * Get product data. + * + * @param WC_Product $product Product instance. + * @param string $context Request context. Options: 'view' and 'edit'. * - * @param mixed $package Package information. * @return array */ - public function find_shipping_classes($package) + protected function get_product_data($product, $context = 'view') { } /** - * Adds extra calculated flat rates. - * - * @deprecated 2.4.0 - * - * Additional rates defined like this: - * Option Name | Additional Cost [+- Percents%] | Per Cost Type (order, class, or item). + * Get the suggested products. * - * @param null $method Deprecated. - * @param array $rate Rate information. + * @param WP_REST_Request $request Request object. + * @return object */ - public function calculate_extra_shipping($method, $rate) + public function get_suggested_products($request) { } /** - * Calculate the percentage adjustment for each shipping rate. + * Core function to prepare a single product output for response + * (doesn't fire hooks, ensure_response, or add links). * - * @deprecated 2.4.0 - * @param float $cost Cost. - * @param float $percent_adjustment Percent adjustment. - * @param string $percent_operator Percent operator. - * @param float $base_price Base price. - * @return float + * @param WC_Data $object_data Object data. + * @param WP_REST_Request $request Request object. + * @param string $context Request context. + * @return array Product data to be included in the response. */ - public function calc_percentage_adjustment($cost, $percent_adjustment, $percent_operator, $base_price) + protected function prepare_object_for_response_core($object_data, $request, $context): array { } /** - * Get extra cost. + * Create a single item. + * Handles cleanup of orphaned images if product creation fails. * - * @deprecated 2.4.0 - * @param string $cost_string Cost string. - * @param string $type Type. - * @param array $package Package information. - * @return float + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. */ - public function get_extra_cost($cost_string, $type, $package) + public function create_item($request) { } } /** - * Free Shipping Method. - * - * This class is here for backwards compatibility for methods existing before zones existed. + * REST API Email Settings controller class. * - * @deprecated 2.6.0 - * @version 2.4.0 - * @package WooCommerce\Classes\Shipping + * @package WooCommerce\RestApi + * @extends WC_REST_V4_Controller */ - class WC_Shipping_Legacy_Free_Shipping extends \WC_Shipping_Method + class WC_REST_Email_Settings_V4_Controller extends \WC_REST_V4_Controller { /** - * Min amount to be valid. - * - * @var float - */ - public $min_amount; - /** - * Requires option. + * Route base. * * @var string */ - public $requires; + protected $rest_base = 'settings/email'; /** - * Constructor. + * Register routes. */ - public function __construct() + public function register_routes() { } /** - * Process and redirect if disabled. + * Check permissions for reading email settings. + * + * @param WP_REST_Request $request Full details about the request. + * @return bool|WP_Error */ - public function process_admin_options() + public function get_item_permissions_check($request) { } /** - * Return the name of the option in the WP DB. + * Get update arguments for the endpoint. * - * @since 2.6.0 - * @return string + * @return array */ - public function get_option_key() + private function get_update_args() { } /** - * Init function. + * Check permissions for updating email settings. + * + * @param WP_REST_Request $request Full details about the request. + * @return bool|WP_Error */ - public function init() + public function update_item_permissions_check($request) { } /** - * Initialise Gateway Settings Form Fields. + * Get email settings. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_REST_Response|WP_Error */ - public function init_form_fields() + public function get_item($request) { } /** - * Check if package is available. + * Update email settings. * - * @param array $package Package information. - * @return bool + * @param WP_REST_Request $request Full details about the request. + * @return WP_REST_Response|WP_Error */ - public function is_available($package) + public function update_item($request) { } /** - * Calculate shipping. + * Validate a setting value before updating. * - * @param array $package Package information. + * @param string $setting_id Setting ID. + * @param mixed $value Setting value. + * @param string $reply_to_enabled Reply-to enabled. + * @return bool|WP_Error True if valid, WP_Error if invalid. */ - public function calculate_shipping($package = array()) + private function validate_setting_value($setting_id, $value, $reply_to_enabled) { } - } - /** - * International Delivery - Based on the Flat Rate Shipping Method. - * - * This class is here for backwards compatibility for methods existing before zones existed. - * - * @deprecated 2.6.0 - * @version 2.4.0 - * @package WooCommerce\Classes\Shipping - */ - class WC_Shipping_Legacy_International_Delivery extends \WC_Shipping_Legacy_Flat_Rate - { /** - * Constructor. + * Sanitize setting value based on setting ID. + * + * @param string $setting_id Setting ID. + * @param mixed $value Setting value. + * @return mixed Sanitized value. */ - public function __construct() + private function sanitize_setting_value($setting_id, $value) { } /** - * Return the name of the option in the WP DB. + * Get email settings data by transforming email settings into REST API format. * - * @since 2.6.0 - * @return string + * @return array */ - public function get_option_key() + private function get_email_settings_data() { } /** - * Initialise settings form fields. + * Get the schema for email settings, conforming to JSON Schema. + * + * @return array */ - public function init_form_fields() + public function get_item_schema() { } /** - * Check if package is available. + * Get the schema for individual setting fields. * - * @param array $package Package information. - * @return bool + * @return array */ - public function is_available($package) + private function get_field_schema() { } } /** - * Local Pickup Shipping Method. - * - * A simple shipping method allowing free pickup as a shipping method. + * REST API General Settings controller class. * - * @class WC_Shipping_Local_Pickup - * @version 2.6.0 - * @package WooCommerce\Classes\Shipping + * @package WooCommerce\RestApi + * @extends WC_REST_V4_Controller */ - class WC_Shipping_Local_Pickup extends \WC_Shipping_Method + class WC_REST_General_Settings_V4_Controller extends \WC_REST_V4_Controller { /** - * Shipping method cost. + * Route base. * * @var string */ - public $cost; + protected $rest_base = 'settings/general'; /** - * Constructor. + * WC_Settings_General instance. * - * @param int $instance_id Instance ID. + * @var WC_Settings_General */ - public function __construct($instance_id = 0) - { - } + protected $settings_general_instance; /** - * Initialize local pickup. + * Get the WC_Settings_General instance. + * + * @return WC_Settings_General */ - public function init() + private function get_settings_general_instance() { } /** - * Calculate local pickup shipping. - * - * @param array $package Package information. + * Register routes. */ - public function calculate_shipping($package = array()) + public function register_routes() { } /** - * Sanitize the cost field. + * Check permissions for reading general settings. * - * @since 8.3.0 - * @param string $value Unsanitized value. - * @throws Exception Last error triggered. - * @return string + * @param WP_REST_Request $request Full details about the request. + * @return bool|WP_Error */ - public function sanitize_cost($value) + public function get_item_permissions_check($request) { } /** - * Init form fields. + * Get update arguments for the endpoint. + * + * @return array */ - public function init_form_fields() + private function get_update_args() { } - } - /** - * Local Delivery Shipping Method. - * - * This class is here for backwards compatibility for methods existing before zones existed. - * - * @deprecated 2.6.0 - * @version 2.3.0 - * @package WooCommerce\Classes\Shipping - */ - class WC_Shipping_Legacy_Local_Delivery extends \WC_Shipping_Local_Pickup - { - /** - * Shipping method fee type. - * - * How to calculate delivery charges. - * - * @var string - */ - public $type; /** - * Allowed post/zip codes for the shipping method. + * Check permissions for updating general settings. * - * @var string - */ - public $codes; - /** - * Constructor. + * @param WP_REST_Request $request Full details about the request. + * @return bool|WP_Error */ - public function __construct() + public function update_item_permissions_check($request) { } /** - * Process and redirect if disabled. + * Get general settings. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_REST_Response|WP_Error */ - public function process_admin_options() + public function get_item($request) { } /** - * Return the name of the option in the WP DB. + * Update general settings. * - * @since 2.6.0 - * @return string + * @param WP_REST_Request $request Full details about the request. + * @return WP_REST_Response|WP_Error */ - public function get_option_key() + public function update_item($request) { } /** - * Init function. + * Validate a setting value before updating. + * + * @param string $setting_id Setting ID. + * @param mixed $value Setting value. + * @return bool|WP_Error True if valid, WP_Error if invalid. */ - public function init() + private function validate_setting_value($setting_id, $value) { } /** - * Calculate_shipping function. + * Sanitize setting value based on its type. * - * @param array $package (default: array()). + * @param string $setting_type Setting type. + * @param mixed $value Setting value. + * @return mixed Sanitized value. */ - public function calculate_shipping($package = array()) + private function sanitize_setting_value($setting_type, $value) { } /** - * Init form fields. + * Get the display order for a settings group. + * + * @param array $setting Setting definition array. + * @return int Display order. */ - public function init_form_fields() + private function get_group_order($setting) { } - } - /** - * Local Pickup Shipping Method. - * - * This class is here for backwards compatibility for methods existing before zones existed. - * - * @deprecated 2.6.0 - * @version 2.3.0 - * @package WooCommerce\Classes\Shipping - */ - class WC_Shipping_Legacy_Local_Pickup extends \WC_Shipping_Method - { /** - * Allowed post/zip codes for the shipping method. + * Get general settings data by transforming WC_Settings_General data into REST API format. * - * @var string - */ - public $codes; - /** - * Constructor. + * @return array */ - public function __construct() + private function get_general_settings_data() { } /** - * Process and redirect if disabled. + * Transform a WooCommerce setting into REST API field format. + * + * @param array $setting WooCommerce setting array. + * @return array|null Transformed field or null if should be skipped. */ - public function process_admin_options() + private function transform_setting_to_field($setting) { } /** - * Return the name of the option in the WP DB. + * Get options for specific field types. * - * @since 2.6.0 - * @return string + * @param string $field_type Field type. + * @param string $field_id Field ID. + * @return array Field options. */ - public function get_option_key() + private function get_field_options($field_type, $field_id) { } /** - * Init function. + * Get country/state options for single select country field. + * + * @return array Country/state options. */ - public function init() + private function get_country_state_options() { } /** - * Calculate shipping. + * Get currency options. * - * @param array $package Package information. + * @return array Currency options. */ - public function calculate_shipping($package = array()) + private function get_currency_options() { } /** - * Initialize form fields. + * Normalize WooCommerce field types to REST API field types. + * + * @param string $wc_type WooCommerce field type. + * @return string Normalized field type. */ - public function init_form_fields() + private function normalize_field_type($wc_type) { } /** - * Get postcodes for this method. + * Validate country or state code. * - * @return array + * @param string $country_or_state Country or state code. + * @return boolean Valid or not valid. */ - public function get_valid_postcodes() + private function validate_country_or_state_code($country_or_state) { } /** - * See if a given postcode matches valid postcodes. + * Get the schema for general settings, conforming to JSON Schema. * - * @param string $postcode Postcode to check. - * @param string $country code Code of the country to check postcode against. - * @return boolean + * @return array */ - public function is_valid_postcode($postcode, $country) + public function get_item_schema() { } /** - * See if the method is available. + * Get the schema for individual setting fields. * - * @param array $package Package information. - * @return bool + * @return array */ - public function is_available($package) + private function get_field_schema() { } + } + /** + * REST API Settings V4 controller class. + * + * @package WooCommerce\RestApi + * @extends WC_REST_Setting_Options_Controller + */ + class WC_REST_Settings_V4_Controller extends \WC_REST_Setting_Options_Controller + { /** - * Clean function. + * Endpoint namespace. * - * @access public - * @param mixed $code Code. - * @return string + * @var string */ - public function clean($code) - { - } + protected $namespace = 'wc/v4'; } +} +namespace Automattic\WooCommerce\RestApi { /** - * Shortcode cart class. + * Main package class. + * + * @deprecated Use \Automattic\WooCommerce\RestApi\Server directly. */ - class WC_Shortcode_Cart + class Package { /** - * Calculate shipping for the cart. + * Version. * - * @throws Exception When some data is invalid. + * @deprecated since 4.5.0. This tracks WooCommerce version now. + * @var string */ - public static function calculate_shipping() - { - } + const VERSION = WC_VERSION; /** - * Output the cart shortcode. + * Init the package - load the REST API Server class. * - * @param array $atts Shortcode attributes. + * @deprecated since 4.5.0. Directly call Automattic\WooCommerce\RestApi\Server::instance()->init() */ - public static function output($atts) + public static function init() { } - } - /** - * Shortcode checkout class. - */ - class WC_Shortcode_Checkout - { /** - * Get the shortcode content. + * Return the version of the package. * - * @param array $atts Shortcode attributes. + * @deprecated since 4.5.0. This tracks WooCommerce version now. * @return string */ - public static function get($atts) + public static function get_version() { } /** - * Output the shortcode. + * Return the path to the package. * - * @param array $atts Shortcode attributes. + * @deprecated since 4.5.0. Directly call Automattic\WooCommerce\RestApi\Server::get_path() + * @return string */ - public static function output($atts) + public static function get_path() { } + } +} +namespace Automattic\WooCommerce\RestApi\Utilities { + /** + * Singleton trait. + */ + trait SingletonTrait + { /** - * Show the pay page. + * The single instance of the class. * - * @throws Exception When validate fails. - * @param int $order_id Order ID. + * @var object */ - private static function order_pay($order_id) + protected static $instance = null; + /** + * Constructor + * + * @return void + */ + protected function __construct() { } /** - * Show the thanks page. + * Get class instance. * - * @param int $order_id Order ID. + * @return object Instance. */ - private static function order_received($order_id = 0) + final public static function instance() { } /** - * Show the checkout. + * Prevent cloning. */ - private static function checkout() + private function __clone() { } /** - * Tries to determine if the user's email address should be verified before rendering either the 'order received' or - * 'order pay' pages. This should only be applied to guest orders. - * - * @param WC_Order $order The order for which a need for email verification is being determined. - * @param string $context The context in which email verification is being tested. - * - * @return bool + * Prevent unserializing. */ - private static function guest_should_verify_email(\WC_Order $order, string $context): bool + final public function __wakeup() { } } +} +namespace Automattic\WooCommerce\RestApi { /** - * Shortcode my account class. + * Class responsible for loading the REST API and all REST API namespaces. */ - class WC_Shortcode_My_Account + class Server { + use \Automattic\WooCommerce\RestApi\Utilities\SingletonTrait; /** - * Get the shortcode content. - * - * @param array $atts Shortcode attributes. + * REST API namespaces and endpoints. * - * @return string + * @var array */ - public static function get($atts) - { - } + protected $controllers = array(); /** - * Output the shortcode. - * - * @param array $atts Shortcode attributes. + * Hook into WordPress ready to init the REST API as needed. */ - public static function output($atts) + public function init() { } /** - * Add notices to the my account page. - * - * Historically a filter has existed to render a message above the my account page content while the user is - * logged out. See `woocommerce_my_account_message`. + * Register REST API routes. */ - private static function my_account_add_notices() + public function register_rest_routes() { } /** - * My account page. + * Get API namespaces - new namespaces should be registered here. * - * @param array $atts Shortcode attributes. + * @return array List of Namespaces and Main controller classes. */ - private static function my_account($atts) + protected function get_rest_namespaces() { } /** - * View order page. + * List of controllers in the wc/v1 namespace. * - * @param int $order_id Order ID. + * @return array */ - public static function view_order($order_id) + protected function get_v1_controllers() { } /** - * Edit account details page. + * List of controllers in the wc/v2 namespace. + * + * @return array */ - public static function edit_account() + protected function get_v2_controllers() { } /** - * Edit address page. + * List of controllers in the wc/v3 namespace. * - * @param string $load_address Type of address; 'billing' or 'shipping'. + * @return array */ - public static function edit_address($load_address = 'billing') + protected function get_v3_controllers() { } /** - * Lost password page handling. + * List of controllers in the wc/v4 namespace. + * + * @return array */ - public static function lost_password() + protected function get_v4_controllers() { } /** - * Handles sending password retrieval email to customer. - * - * Based on retrieve_password() in core wp-login.php. + * Get instance of a V4 controller. * - * @uses $wpdb WordPress Database object - * @return bool True: when finish. False: on error + * @param string $identifier Controller identifier. + * @param string $route Route class name. + * @return object The instance of the controller. */ - public static function retrieve_password() + protected function get_v4_controller($identifier, $route) { } /** - * Retrieves a user row based on password reset key and login. + * List of controllers in the telemetry namespace. * - * @uses $wpdb WordPress Database object. - * @param string $key Hash to validate sending user's password. - * @param string $login The user login. - * @return WP_User|bool User's database row on success, false for invalid keys + * @return array */ - public static function check_password_reset_key($key, $login) + protected function get_telemetry_controllers() { } /** - * Handles resetting the user's password. - * - * @since 9.4.0 This will log the user in after resetting the password/session. + * Return the path to the package. * - * @param object $user The user. - * @param string $new_pass New password for the user in plaintext. + * @return string */ - public static function reset_password($user, $new_pass) + public static function get_path() { } + } +} +namespace Automattic\WooCommerce\RestApi\Utilities { + /** + * ImageAttachment class. + */ + class ImageAttachment + { /** - * Set or unset the cookie. + * Attachment ID. * - * @param string $value Cookie value. + * @var integer */ - public static function set_reset_password_cookie($value = '') + public $id = 0; + /** + * Object attached to. + * + * @var integer + */ + public $object_id = 0; + /** + * Constructor. + * + * @param integer $id Attachment ID. + * @param integer $object_id Object ID. + */ + public function __construct($id = 0, $object_id = 0) { } /** - * Show the add payment method page. + * Upload an attachment file. + * + * @throws \WC_REST_Exception REST API exceptions. + * @param string $src URL to file. */ - public static function add_payment_method() + public function upload_image_from_src($src) { } - } - /** - * Shortcode order tracking class. - */ - class WC_Shortcode_Order_Tracking - { /** - * Get the shortcode content. + * Update attachment alt text. * - * @param array $atts Shortcode attributes. - * @return string + * @param string $text Text to set. */ - public static function get($atts) + public function update_alt_text($text) { } /** - * Output the shortcode. + * Update attachment name. * - * @param array $atts Shortcode attributes. + * @param string $text Text to set. */ - public static function output($atts) + public function update_name($text) { } } +} +namespace { /** - * Products shortcode class. + * WC_Shipping_Flat_Rate class. */ - class WC_Shortcode_Products + class WC_Shipping_Flat_Rate extends \WC_Shipping_Method { /** - * Shortcode type. - * - * @since 3.2.0 - * @var string - */ - protected $type = 'products'; - /** - * Attributes. + * Cost passed to [fee] shortcode. * - * @since 3.2.0 - * @var array + * @var string Cost. */ - protected $attributes = array(); + protected $fee_cost = ''; /** - * Query args. + * Shipping method cost. * - * @since 3.2.0 - * @var array + * @var string */ - protected $query_args = array(); + public $cost; /** - * Set custom visibility. + * Shipping method type. * - * @since 3.2.0 - * @var bool + * @var string */ - protected $custom_visibility = \false; + public $type; /** - * Initialize shortcode. + * Constructor. * - * @since 3.2.0 - * @param array $attributes Shortcode attributes. - * @param string $type Shortcode type. + * @param int $instance_id Shipping method instance ID. */ - public function __construct($attributes = array(), $type = 'products') + public function __construct($instance_id = 0) { } /** - * Get shortcode attributes. - * - * @since 3.2.0 - * @return array + * Init user set variables. */ - public function get_attributes() + public function init() { } /** - * Get query args. + * Evaluate a cost from a sum/string. * - * @since 3.2.0 - * @return array + * @param string $sum Sum of shipping. + * @param array $args Args, must contain `cost` and `qty` keys. Having `array()` as default is for back compat reasons. + * @return string */ - public function get_query_args() + protected function evaluate_cost($sum, $args = array()) { } /** - * Get shortcode type. + * Work out fee (shortcode). * - * @since 3.2.0 + * @param array $atts Attributes. * @return string */ - public function get_type() + public function fee($atts) { } /** - * Get shortcode content. + * Calculate the shipping costs. * - * @since 3.2.0 - * @return string + * @param array $package Package of items from cart. */ - public function get_content() + public function calculate_shipping($package = array()) { } /** - * Parse attributes. + * Get items in package. * - * @since 3.2.0 - * @param array $attributes Shortcode attributes. - * @return array + * @param array $package Package of items from cart. + * @return int */ - protected function parse_attributes($attributes) + public function get_package_item_qty($package) { } /** - * Parse legacy attributes. + * Finds and returns shipping classes and the products with said class. * - * @since 3.2.0 - * @param array $attributes Attributes. + * @param mixed $package Package of items from cart. * @return array */ - protected function parse_legacy_attributes($attributes) + public function find_shipping_classes($package) { } /** - * Parse query args. + * Sanitize the cost field. * - * @since 3.2.0 - * @return array + * @since 3.4.0 + * @param string $value Unsanitized value. + * @throws Exception Last error triggered. + * @return string */ - protected function parse_query_args() + public function sanitize_cost($value) { } + } + /** + * Free Shipping Method. + * + * A simple shipping method for free shipping. + * + * @class WC_Shipping_Free_Shipping + * @version 2.6.0 + * @package WooCommerce\Classes\Shipping + */ + class WC_Shipping_Free_Shipping extends \WC_Shipping_Method + { /** - * Set skus query args. + * Min amount to be valid. * - * @since 3.2.0 - * @param array $query_args Query args. + * @var integer */ - protected function set_skus_query_args(&$query_args) - { - } + public $min_amount = 0; /** - * Set ids query args. + * Requires option. * - * @since 3.2.0 - * @param array $query_args Query args. + * @var string */ - protected function set_ids_query_args(&$query_args) + public $requires = ''; + /** + * Ignore discounts. + * + * If set, free shipping would be available based on pre-discount order amount. + * + * @var string + */ + public $ignore_discounts; + /** + * Constructor. + * + * @param int $instance_id Shipping method instance. + */ + public function __construct($instance_id = 0) { } /** - * Set attributes query args. - * - * @since 3.2.0 - * @param array $query_args Query args. + * Initialize free shipping. */ - protected function set_attributes_query_args(&$query_args) + public function init() { } /** - * Set categories query args. + * Sanitize the cost field. * - * @since 3.2.0 - * @param array $query_args Query args. + * @since 8.3.0 + * @param string $value Unsanitized value. + * @throws Exception Last error triggered. + * @return string */ - protected function set_categories_query_args(&$query_args) + public function sanitize_cost($value) { } /** - * Set tags query args. - * - * @since 3.3.0 - * @param array $query_args Query args. + * Init form fields. */ - protected function set_tags_query_args(&$query_args) + public function init_form_fields() { } /** - * Set sale products query args. + * Get setting form fields for instances of this shipping method within zones. * - * @since 3.2.0 - * @param array $query_args Query args. + * @return array */ - protected function set_sale_products_query_args(&$query_args) + public function get_instance_form_fields() { } /** - * Set best selling products query args. + * See if free shipping is available based on the package and cart. * - * @since 3.2.0 - * @param array $query_args Query args. + * @param array $package Shipping package. + * @return bool */ - protected function set_best_selling_products_query_args(&$query_args) + public function is_available($package) { } /** - * Set top rated products query args. + * Called to calculate shipping rates for this method. Rates can be added using the add_rate() method. * - * @since 3.6.5 - * @param array $query_args Query args. + * @uses WC_Shipping_Method::add_rate() + * + * @param array $package Shipping package. */ - protected function set_top_rated_products_query_args(&$query_args) + public function calculate_shipping($package = array()) { } /** - * Set visibility as hidden. + * Enqueue JS to handle free shipping options. * - * @since 3.2.0 - * @param array $query_args Query args. + * Static so that's enqueued only once. */ - protected function set_visibility_hidden_query_args(&$query_args) + public static function enqueue_admin_js() { } + } + /** + * Flat Rate Shipping Method. + * + * This class is here for backwards compatibility for methods existing before zones existed. + * + * @deprecated 2.6.0 + * @version 2.4.0 + * @package WooCommerce\Classes\Shipping + */ + class WC_Shipping_Legacy_Flat_Rate extends \WC_Shipping_Method + { /** - * Set visibility as catalog. + * Cost passed to [fee] shortcode. * - * @since 3.2.0 - * @param array $query_args Query args. + * @var string */ - protected function set_visibility_catalog_query_args(&$query_args) + protected $fee_cost = ''; + /** + * Shipping method cost. + * + * @var string + */ + public $cost; + /** + * Shipping method type. + * + * @var string + */ + public $type; + /** + * Shipping method options. + * + * @deprecated 2.4.0 + * @var string + */ + public $options; + /** + * Constructor. + */ + public function __construct() { } /** - * Set visibility as search. - * - * @since 3.2.0 - * @param array $query_args Query args. + * Process and redirect if disabled. */ - protected function set_visibility_search_query_args(&$query_args) + public function process_admin_options() { } /** - * Set visibility as featured. + * Return the name of the option in the WP DB. * - * @since 3.2.0 - * @param array $query_args Query args. + * @since 2.6.0 + * @return string */ - protected function set_visibility_featured_query_args(&$query_args) + public function get_option_key() { } /** - * Set visibility query args. - * - * @since 3.2.0 - * @param array $query_args Query args. + * Init function. */ - protected function set_visibility_query_args(&$query_args) + public function init() { } /** - * Set product as visible when querying for hidden products. - * - * @since 3.2.0 - * @param bool $visibility Product visibility. - * @return bool + * Initialise Settings Form Fields. */ - public function set_product_as_visible($visibility) + public function init_form_fields() { } /** - * Get wrapper classes. + * Evaluate a cost from a sum/string. * - * @since 3.2.0 - * @param int $columns Number of columns. - * @return array + * @param string $sum Sum to evaluate. + * @param array $args Arguments. + * @return string */ - protected function get_wrapper_classes($columns) + protected function evaluate_cost($sum, $args = array()) { } /** - * Generate and return the transient name for this shortcode based on the query args. + * Work out fee (shortcode). * - * @since 3.3.0 + * @param array $atts Shortcode attributes. * @return string */ - protected function get_transient_name() + public function fee($atts) { } /** - * Run the query and return an array of data, including queried ids and pagination information. + * Calculate shipping. * - * @since 3.3.0 - * @return object Object with the following props; ids, per_page, found_posts, max_num_pages, current_page + * @param array $package (default: array()). */ - protected function get_query_results() + public function calculate_shipping($package = array()) { } /** - * Loop over found products. + * Get items in package. * - * @since 3.2.0 - * @return string + * @param array $package Package information. + * @return int */ - protected function product_loop() + public function get_package_item_qty($package) { } /** - * Order by rating. + * Finds and returns shipping classes and the products with said class. * - * @since 3.2.0 - * @param array $args Query args. + * @param mixed $package Package information. * @return array */ - public static function order_by_rating_post_clauses($args) + public function find_shipping_classes($package) { } - } - /** - * WC_Twenty_Eleven class. - */ - class WC_Twenty_Eleven - { /** - * Theme init. + * Adds extra calculated flat rates. + * + * @deprecated 2.4.0 + * + * Additional rates defined like this: + * Option Name | Additional Cost [+- Percents%] | Per Cost Type (order, class, or item). + * + * @param null $method Deprecated. + * @param array $rate Rate information. */ - public static function init() + public function calculate_extra_shipping($method, $rate) { } /** - * Open wrappers. + * Calculate the percentage adjustment for each shipping rate. + * + * @deprecated 2.4.0 + * @param float $cost Cost. + * @param float $percent_adjustment Percent adjustment. + * @param string $percent_operator Percent operator. + * @param float $base_price Base price. + * @return float */ - public static function output_content_wrapper() + public function calc_percentage_adjustment($cost, $percent_adjustment, $percent_operator, $base_price) { } /** - * Close wrappers. + * Get extra cost. + * + * @deprecated 2.4.0 + * @param string $cost_string Cost string. + * @param string $type Type. + * @param array $package Package information. + * @return float */ - public static function output_content_wrapper_end() + public function get_extra_cost($cost_string, $type, $package) { } } /** - * WC_Twenty_Fifteen class. + * Free Shipping Method. + * + * This class is here for backwards compatibility for methods existing before zones existed. + * + * @deprecated 2.6.0 + * @version 2.4.0 + * @package WooCommerce\Classes\Shipping */ - class WC_Twenty_Fifteen + class WC_Shipping_Legacy_Free_Shipping extends \WC_Shipping_Method { /** - * Theme init. + * Min amount to be valid. + * + * @var float */ - public static function init() - { - } + public $min_amount; /** - * Open wrappers. + * Requires option. + * + * @var string */ - public static function output_content_wrapper() - { - } + public $requires; /** - * Close wrappers. + * Constructor. */ - public static function output_content_wrapper_end() + public function __construct() { } - } - /** - * WC_Twenty_Fourteen class. - */ - class WC_Twenty_Fourteen - { /** - * Theme init. + * Process and redirect if disabled. */ - public static function init() + public function process_admin_options() { } /** - * Open wrappers. + * Return the name of the option in the WP DB. + * + * @since 2.6.0 + * @return string */ - public static function output_content_wrapper() + public function get_option_key() { } /** - * Close wrappers. + * Init function. */ - public static function output_content_wrapper_end() + public function init() { } - } - /** - * WC_Twenty_Nineteen class. - */ - class WC_Twenty_Nineteen - { /** - * Theme init. + * Initialise Gateway Settings Form Fields. */ - public static function init() + public function init_form_fields() { } /** - * Open the Twenty Nineteen wrapper. - */ - public static function output_content_wrapper() + * Check if package is available. + * + * @param array $package Package information. + * @return bool + */ + public function is_available($package) { } /** - * Close the Twenty Nineteen wrapper. + * Calculate shipping. + * + * @param array $package Package information. */ - public static function output_content_wrapper_end() + public function calculate_shipping($package = array()) + { + } + } + /** + * International Delivery - Based on the Flat Rate Shipping Method. + * + * This class is here for backwards compatibility for methods existing before zones existed. + * + * @deprecated 2.6.0 + * @version 2.4.0 + * @package WooCommerce\Classes\Shipping + */ + class WC_Shipping_Legacy_International_Delivery extends \WC_Shipping_Legacy_Flat_Rate + { + /** + * Constructor. + */ + public function __construct() { } /** - * Enqueue CSS for this theme. + * Return the name of the option in the WP DB. * - * @param array $styles Array of registered styles. - * @return array + * @since 2.6.0 + * @return string */ - public static function enqueue_styles($styles) + public function get_option_key() { } /** - * Tweak Twenty Nineteen features. + * Initialise settings form fields. */ - public static function tweak_theme_features() + public function init_form_fields() { } /** - * Filters Twenty Nineteen custom colors CSS. + * Check if package is available. * - * @param string $css Base theme colors CSS. - * @param int $primary_color The user's selected color hue. - * @param string $saturation Filtered theme color saturation level. + * @param array $package Package information. + * @return bool */ - public static function custom_colors_css($css, $primary_color, $saturation) + public function is_available($package) { } } /** - * WC_Twenty_Seventeen class. + * Local Pickup Shipping Method. + * + * A simple shipping method allowing free pickup as a shipping method. + * + * @class WC_Shipping_Local_Pickup + * @version 2.6.0 + * @package WooCommerce\Classes\Shipping */ - class WC_Twenty_Seventeen + class WC_Shipping_Local_Pickup extends \WC_Shipping_Method { /** - * Theme init. + * Shipping method cost. + * + * @var string */ - public static function init() - { - } + public $cost; /** - * Enqueue CSS for this theme. + * Constructor. * - * @param array $styles Array of registered styles. - * @return array + * @param int $instance_id Instance ID. */ - public static function enqueue_styles($styles) + public function __construct($instance_id = 0) { } /** - * Open the Twenty Seventeen wrapper. + * Initialize local pickup. */ - public static function output_content_wrapper() + public function init() { } /** - * Close the Twenty Seventeen wrapper. + * Calculate local pickup shipping. + * + * @param array $package Package information. */ - public static function output_content_wrapper_end() + public function calculate_shipping($package = array()) { } /** - * Custom colors. + * Sanitize the cost field. * - * @param string $css Styles. - * @param string $hue Color. - * @param string $saturation Saturation. + * @since 8.3.0 + * @param string $value Unsanitized value. + * @throws Exception Last error triggered. * @return string */ - public static function custom_colors_css($css, $hue, $saturation) - { - } - } - /** - * WC_Twenty_Sixteen class. - */ - class WC_Twenty_Sixteen - { - /** - * Theme init. - */ - public static function init() - { - } - /** - * Open wrappers. - */ - public static function output_content_wrapper() + public function sanitize_cost($value) { } /** - * Close wrappers. + * Init form fields. */ - public static function output_content_wrapper_end() + public function init_form_fields() { } } /** - * WC_Twenty_Ten class. + * Local Delivery Shipping Method. + * + * This class is here for backwards compatibility for methods existing before zones existed. + * + * @deprecated 2.6.0 + * @version 2.3.0 + * @package WooCommerce\Classes\Shipping */ - class WC_Twenty_Ten + class WC_Shipping_Legacy_Local_Delivery extends \WC_Shipping_Local_Pickup { /** - * Theme init. + * Shipping method fee type. + * + * How to calculate delivery charges. + * + * @var string */ - public static function init() + public $type; + /** + * Allowed post/zip codes for the shipping method. + * + * @var string + */ + public $codes; + /** + * Constructor. + */ + public function __construct() { } /** - * Open wrappers. + * Process and redirect if disabled. */ - public static function output_content_wrapper() + public function process_admin_options() { } /** - * Close wrappers. + * Return the name of the option in the WP DB. + * + * @since 2.6.0 + * @return string */ - public static function output_content_wrapper_end() + public function get_option_key() { } - } - /** - * WC_Twenty_Thirteen class. - */ - class WC_Twenty_Thirteen - { /** - * Theme init. + * Init function. */ - public static function init() + public function init() { } /** - * Open wrappers. + * Calculate_shipping function. + * + * @param array $package (default: array()). */ - public static function output_content_wrapper() + public function calculate_shipping($package = array()) { } /** - * Close wrappers. + * Init form fields. */ - public static function output_content_wrapper_end() + public function init_form_fields() { } } /** - * WC_Twenty_Twelve class. + * Local Pickup Shipping Method. + * + * This class is here for backwards compatibility for methods existing before zones existed. + * + * @deprecated 2.6.0 + * @version 2.3.0 + * @package WooCommerce\Classes\Shipping */ - class WC_Twenty_Twelve + class WC_Shipping_Legacy_Local_Pickup extends \WC_Shipping_Method { /** - * Theme init. + * Allowed post/zip codes for the shipping method. + * + * @var string */ - public static function init() - { - } + public $codes; /** - * Open wrappers. + * Constructor. */ - public static function output_content_wrapper() + public function __construct() { } /** - * Close wrappers. + * Process and redirect if disabled. */ - public static function output_content_wrapper_end() + public function process_admin_options() { } /** - * Add theme compatibility styles. + * Return the name of the option in the WP DB. * - * @return void + * @since 2.6.0 + * @return string */ - public static function enqueue_styles() + public function get_option_key() { } - } - /** - * WC_Twenty_Twenty_One class. - */ - class WC_Twenty_Twenty_One - { /** - * Theme init. + * Init function. */ - public static function init() + public function init() { } /** - * Enqueue CSS for this theme. + * Calculate shipping. * - * @param array $styles Array of registered styles. - * @return array + * @param array $package Package information. */ - public static function enqueue_styles($styles) + public function calculate_shipping($package = array()) { } /** - * Enqueue the wp-admin CSS overrides for this theme. + * Initialize form fields. */ - public static function enqueue_admin_styles() + public function init_form_fields() { } - } - /** - * WC_Twenty_Twenty_Three class. - */ - class WC_Twenty_Twenty_Three - { /** - * Theme init. + * Get postcodes for this method. + * + * @return array */ - public static function init() + public function get_valid_postcodes() { } /** - * Enqueue CSS for this theme. + * See if a given postcode matches valid postcodes. * - * @param array $styles Array of registered styles. - * @return array + * @param string $postcode Postcode to check. + * @param string $country code Code of the country to check postcode against. + * @return boolean */ - public static function enqueue_styles($styles) + public function is_valid_postcode($postcode, $country) { } /** - * Wrap checkout order review with a `col2-set` div. + * See if the method is available. + * + * @param array $package Package information. + * @return bool */ - public static function before_order_review() + public function is_available($package) { } /** - * Close the div wrapper. + * Clean function. + * + * @access public + * @param mixed $code Code. + * @return string */ - public static function after_order_review() + public function clean($code) { } } /** - * WC_Twenty_Twenty_One class. + * Shortcode cart class. */ - class WC_Twenty_Twenty_Two + class WC_Shortcode_Cart { /** - * Theme init. - */ - public static function init() - { - } - /** - * Enqueue CSS for this theme. + * Calculate shipping for the cart. * - * @param array $styles Array of registered styles. - * @return array - */ - public static function enqueue_styles($styles) - { - } - /** - * Wrap checkout order review with a `col2-set` div. + * @throws Exception When some data is invalid. */ - public static function before_order_review() + public static function calculate_shipping() { } /** - * Close the div wrapper. + * Output the cart shortcode. + * + * @param array $atts Shortcode attributes. */ - public static function after_order_review() + public static function output($atts) { } } /** - * WC_Twenty_Twenty class. + * Shortcode checkout class. */ - class WC_Twenty_Twenty + class WC_Shortcode_Checkout { /** - * Theme init. + * Get the shortcode content. + * + * @param array $atts Shortcode attributes. + * @return string */ - public static function init() + public static function get($atts) { } /** - * Open the Twenty Twenty wrapper. + * Output the shortcode. + * + * @param array $atts Shortcode attributes. */ - public static function output_content_wrapper() + public static function output($atts) { } /** - * Close the Twenty Twenty wrapper. + * Show the pay page. + * + * @throws Exception When validate fails. + * @param int $order_id Order ID. */ - public static function output_content_wrapper_end() + private static function order_pay($order_id) { } /** - * Set background color to white if it's default, otherwise don't touch it. + * Show the thanks page. + * + * @param int $order_id Order ID. */ - public static function set_white_background() + private static function order_received($order_id = 0) { } /** - * Enqueue CSS for this theme. + * Show the checkout. + */ + private static function checkout() + { + } + /** + * Tries to determine if the user's email address should be verified before rendering either the 'order received' or + * 'order pay' pages. This should only be applied to guest orders. * - * @param array $styles Array of registered styles. - * @return array + * @param WC_Order $order The order for which a need for email verification is being determined. + * @param string $context The context in which email verification is being tested. + * + * @return bool */ - public static function enqueue_styles($styles) + private static function guest_should_verify_email(\WC_Order $order, string $context): bool { } } /** - * This class adds actions to track usage of WooCommerce. + * Shortcode my account class. */ - class WC_Site_Tracking + class WC_Shortcode_My_Account { /** - * Check if tracking is enabled. + * Get the shortcode content. * - * @return bool + * @param array $atts Shortcode attributes. + * + * @return string */ - public static function is_tracking_enabled() + public static function get($atts) { } /** - * Register scripts required to record events from javascript. + * Output the shortcode. + * + * @param array $atts Shortcode attributes. */ - public static function register_scripts() + public static function output($atts) { } /** - * Add scripts required to record events from javascript. + * Add notices to the my account page. + * + * Historically a filter has existed to render a message above the my account page content while the user is + * logged out. See `woocommerce_my_account_message`. */ - public static function enqueue_scripts() + private static function my_account_add_notices() { } /** - * Adds the tracking function to the admin footer. + * My account page. + * + * @param array $atts Shortcode attributes. */ - public static function add_tracking_function() + private static function my_account($atts) { } /** - * Adds a function to load tracking scripts and enable them client-side on the fly. - * Note that this function does not update `woocommerce_allow_tracking` in the database - * and will not persist enabled tracking across page loads. + * View order page. + * + * @param int $order_id Order ID. */ - public static function add_enable_tracking_function() + public static function view_order($order_id) { } /** - * Init tracking. + * Edit account details page. */ - public static function init() + public static function edit_account() { } /** - * Sets a cookie for tracking purposes, but only if tracking is enabled/allowed. - * - * @internal - * @since 9.2.0 - * - * @param string $cookie_key The key of the cookie. - * @param string $cookie_value The value of the cookie. - * @param int $expire Expiry of the cookie. - * @param bool $secure Whether the cookie should be served only over https. - * @param bool $http_only Whether the cookie is only accessible over HTTP. + * Edit address page. * - * @return bool If setting the cookie was attempted (will be false if tracking is not allowed). + * @param string $load_address Type of address; 'billing' or 'shipping'. */ - public static function set_tracking_cookie(string $cookie_key, string $cookie_value, int $expire = 0, bool $secure = \false, bool $http_only = \false): bool + public static function edit_address($load_address = 'billing') { } - } - /** - * WC_Tracks_Client class. - */ - class WC_Tracks_Client - { - /** - * Pixel URL. - */ - const PIXEL = 'https://pixel.wp.com/t.gif'; - /** - * Browser type. - */ - const BROWSER_TYPE = 'php-agent'; - /** - * User agent. - */ - const USER_AGENT_SLUG = 'tracks-client'; /** - * Initialize tracks client class - * - * @return void + * Lost password page handling. */ - public static function init() + public static function lost_password() { } /** - * Check if identity cookie is set, if not set it. + * Handles sending password retrieval email to customer. * - * @return void + * Based on retrieve_password() in core wp-login.php. + * + * @uses $wpdb WordPress Database object + * @return bool True: when finish. False: on error */ - public static function maybe_set_identity_cookie() + public static function retrieve_password() { } /** - * Record a Tracks event + * Retrieves a user row based on password reset key and login. * - * @param array $event Array of event properties. - * @return bool|WP_Error True on success, WP_Error on failure. + * @uses $wpdb WordPress Database object. + * @param string $key Hash to validate sending user's password. + * @param string $login The user login. + * @return WP_User|bool User's database row on success, false for invalid keys */ - public static function record_event($event) + public static function check_password_reset_key($key, $login) { } /** - * Synchronously request the pixel. + * Handles resetting the user's password. * - * @param string $pixel pixel url and query string. - * @return bool Always returns true. + * @since 9.4.0 This will log the user in after resetting the password/session. + * + * @param object $user The user. + * @param string $new_pass New password for the user in plaintext. */ - public static function record_pixel($pixel) + public static function reset_password($user, $new_pass) { } /** - * Create a timestamp representing milliseconds since 1970-01-01 + * Set or unset the cookie. * - * @return string A string representing a timestamp. + * @param string $value Cookie value. */ - public static function build_timestamp() + public static function set_reset_password_cookie($value = '') { } /** - * Add request timestamp and no cache parameter to pixel. - * Use this the latest possible before the HTTP request. - * - * @param string $pixel Pixel URL. - * @return string Pixel URL with request timestamp and URL terminator. + * Show the add payment method page. */ - public static function add_request_timestamp_and_nocache($pixel) + public static function add_payment_method() { } + } + /** + * Shortcode order tracking class. + */ + class WC_Shortcode_Order_Tracking + { /** - * Get a user's identity to send to Tracks. If Jetpack exists, default to its implementation. + * Get the shortcode content. * - * @param int $user_id User id. - * @return array Identity properties. + * @param array $atts Shortcode attributes. + * @return string */ - public static function get_identity($user_id) + public static function get($atts) { } /** - * Grabs the user's anon id from cookies, or generates and sets a new one + * Output the shortcode. * - * @return string An anon id for the user + * @param array $atts Shortcode attributes. */ - public static function get_anon_id() + public static function output($atts) { } } /** - * WC_Tracks_Event class. + * Products shortcode class. */ - #[\AllowDynamicProperties] - class WC_Tracks_Event + class WC_Shortcode_Products { /** - * Event name regex. + * Shortcode type. + * + * @since 3.2.0 + * @var string */ - public const EVENT_NAME_REGEX = '/^(([a-z0-9]+)_){1}([a-z0-9_]+)$/'; + protected $type = 'products'; /** - * Property name regex. + * Attributes. + * + * @since 3.2.0 + * @var array */ - public const PROP_NAME_REGEX = '/^[a-z_][a-z0-9_]*$/'; + protected $attributes = array(); /** - * Error message as WP_Error. + * Query args. * - * @var WP_Error + * @since 3.2.0 + * @var array */ - public $error; + protected $query_args = array(); /** - * WC_Tracks_Event constructor. + * Set custom visibility. * - * @param array $event Event properties. + * @since 3.2.0 + * @var bool */ - public function __construct($event) + protected $custom_visibility = \false; + /** + * Initialize shortcode. + * + * @since 3.2.0 + * @param array $attributes Shortcode attributes. + * @param string $type Shortcode type. + */ + public function __construct($attributes = array(), $type = 'products') { } /** - * Record Tracks event + * Get shortcode attributes. * - * @return bool Always returns true. + * @since 3.2.0 + * @return array */ - public function record() + public function get_attributes() { } /** - * Annotate the event with all relevant info. + * Get query args. * - * @param array $event Event arguments. - * @return bool|WP_Error True on success, WP_Error on failure. + * @since 3.2.0 + * @return array */ - public static function validate_and_sanitize($event) + public function get_query_args() { } /** - * Build a pixel URL that will send a Tracks event when fired. - * On error, returns an empty string (''). + * Get shortcode type. * - * @return string A pixel URL or empty string ('') if there were invalid args. + * @since 3.2.0 + * @return string */ - public function build_pixel_url() + public function get_type() { } /** - * Check if event name is valid. + * Get shortcode content. * - * @param string $name Event name. - * @return false|int + * @since 3.2.0 + * @return string */ - public static function event_name_is_valid($name) + public function get_content() { } /** - * Check if a property name is valid. + * Parse attributes. * - * @param string $name Event property. - * @return false|int + * @since 3.2.0 + * @param array $attributes Shortcode attributes. + * @return array */ - public static function prop_name_is_valid($name) + protected function parse_attributes($attributes) { } /** - * Check event names + * Parse legacy attributes. * - * @param object $event An event object. + * @since 3.2.0 + * @param array $attributes Attributes. + * @return array */ - public static function scrutinize_event_names($event) + protected function parse_legacy_attributes($attributes) { } - } - /** - * WC_Tracks_Footer_Pixel class. - */ - class WC_Tracks_Footer_Pixel - { /** - * Singleton instance. + * Parse query args. * - * @var WC_Tracks_Footer_Pixel + * @since 3.2.0 + * @return array */ - protected static $instance = \null; + protected function parse_query_args() + { + } /** - * Events to send to Tracks. + * Set skus query args. * - * @var array + * @since 3.2.0 + * @param array $query_args Query args. */ - protected $events = array(); + protected function set_skus_query_args(&$query_args) + { + } /** - * Instantiate the singleton. + * Set ids query args. * - * @return WC_Tracks_Footer_Pixel + * @since 3.2.0 + * @param array $query_args Query args. */ - public static function instance() + protected function set_ids_query_args(&$query_args) { } /** - * Constructor - attach hooks to the singleton instance. + * Set attributes query args. + * + * @since 3.2.0 + * @param array $query_args Query args. */ - public function __construct() + protected function set_attributes_query_args(&$query_args) { } /** - * Record a Tracks event + * Set categories query args. * - * @param array $event Array of event properties. - * @return bool|WP_Error True on success, WP_Error on failure. + * @since 3.2.0 + * @param array $query_args Query args. */ - public static function record_event($event) + protected function set_categories_query_args(&$query_args) { } /** - * Add a Tracks event to the queue. + * Set tags query args. * - * @param WC_Tracks_Event $event Event to track. + * @since 3.3.0 + * @param array $query_args Query args. */ - public function add_event($event) + protected function set_tags_query_args(&$query_args) { } /** - * Add events as tracking pixels to page footer. + * Set sale products query args. + * + * @since 3.2.0 + * @param array $query_args Query args. */ - public function render_tracking_pixels() + protected function set_sale_products_query_args(&$query_args) { } /** - * Fire off API calls for events that weren't converted to pixels. + * Set best selling products query args. * - * This handles wp_redirect(). + * @since 3.2.0 + * @param array $query_args Query args. */ - public function send_tracks_requests() + protected function set_best_selling_products_query_args(&$query_args) { } /** - * Get all events. + * Set top rated products query args. + * + * @since 3.6.5 + * @param array $query_args Query args. */ - public static function get_events() + protected function set_top_rated_products_query_args(&$query_args) { } /** - * Clear all queued events. + * Set visibility as hidden. + * + * @since 3.2.0 + * @param array $query_args Query args. */ - public static function clear_events() + protected function set_visibility_hidden_query_args(&$query_args) { } - } - /** - * PHP Tracks Client - * - * @package WooCommerce\Tracks - */ - /** - * WC_Tracks class. - */ - class WC_Tracks - { /** - * Tracks event name prefix. + * Set visibility as catalog. + * + * @since 3.2.0 + * @param array $query_args Query args. */ - const PREFIX = 'wcadmin_'; + protected function set_visibility_catalog_query_args(&$query_args) + { + } /** - * Get total product counts. + * Set visibility as search. * - * @return int Number of products. + * @since 3.2.0 + * @param array $query_args Query args. */ - public static function get_products_count() + protected function set_visibility_search_query_args(&$query_args) { } /** - * Gather blog related properties. + * Set visibility as featured. * - * @param int $user_id User id. - * @return array Blog details. + * @since 3.2.0 + * @param array $query_args Query args. */ - public static function get_blog_details($user_id) + protected function set_visibility_featured_query_args(&$query_args) { } /** - * Gather details from the request to the server. + * Set visibility query args. * - * @return array Server details. + * @since 3.2.0 + * @param array $query_args Query args. */ - public static function get_server_details() + protected function set_visibility_query_args(&$query_args) { } /** - * Get role-related details. + * Set product as visible when querying for hidden products. * - * @param WP_User $user The user object. - * @return array The role details. + * @since 3.2.0 + * @param bool $visibility Product visibility. + * @return bool */ - public static function get_role_details($user) + public function set_product_as_visible($visibility) { } /** - * Record an event in Tracks - this is the preferred way to record events from PHP. - * Note: the event request won't be made if $properties has a member called `error`. + * Get wrapper classes. * - * @param string $event_name The name of the event. - * @param array $event_properties Custom properties to send with the event. - * @return bool|WP_Error True for success or WP_Error if the event pixel could not be fired. + * @since 3.2.0 + * @param int $columns Number of columns. + * @return array */ - public static function record_event($event_name, $event_properties = array()) + protected function get_wrapper_classes($columns) { } /** - * Track when the user attempts to toggle - * woocommerce_allow_tracking option. + * Generate and return the transient name for this shortcode based on the query args. * - * @since x.x.x + * @since 3.3.0 + * @return string + */ + protected function get_transient_name() + { + } + /** + * Run the query and return an array of data, including queried ids and pagination information. * - * @param string $prev_value The previous value for the setting. 'yes' or 'no'. - * @param string $new_value The new value for the setting. 'yes' or 'no'. - * @param string $context Which avenue the user utilized to toggle. + * @since 3.3.0 + * @return object Object with the following props; ids, per_page, found_posts, max_num_pages, current_page */ - public static function track_woocommerce_allow_tracking_toggled($prev_value, $new_value, $context = 'settings') + protected function get_query_results() { } /** - * Get all properties for the event including filtered and identity properties. + * Loop over found products. * - * @param string $event_name Event name. - * @param array $event_properties Event specific properties. + * @since 3.2.0 + * @return string + */ + protected function product_loop() + { + } + /** + * Order by rating. + * + * @since 3.2.0 + * @param array $args Query args. * @return array */ - public static function get_properties($event_name, $event_properties) + public static function order_by_rating_post_clauses($args) { } } /** - * This class adds actions to track usage of the WooCommerce Onboarding Wizard. + * WC_Twenty_Eleven class. */ - class WC_Admin_Setup_Wizard_Tracking + class WC_Twenty_Eleven { /** - * Steps for the setup wizard - * - * @var array - */ - private $steps = array(); - /** - * Init tracking. - * - * @deprecated 4.6.0 + * Theme init. */ - public function init() + public static function init() { } /** - * Get the name of the current step. - * - * @deprecated 4.6.0 - * @return string + * Open wrappers. */ - public function get_current_step() + public static function output_content_wrapper() { } /** - * Add footer scripts to OBW via woocommerce_setup_footer - * - * @deprecated 4.6.0 + * Close wrappers. */ - public function add_footer_scripts() + public static function output_content_wrapper_end() { } + } + /** + * WC_Twenty_Fifteen class. + */ + class WC_Twenty_Fifteen + { /** - * Dequeue unwanted scripts from OBW footer. - * - * @deprecated 4.6.0 + * Theme init. */ - public function dequeue_non_allowed_scripts() + public static function init() { } /** - * Track when tracking is opted into and OBW has started. - * - * @param string $option Option name. - * @param string $value Option value. - * - * @deprecated 4.6.0 + * Open wrappers. */ - public function track_start($option, $value) + public static function output_content_wrapper() { } /** - * Track the marketing form on submit. - * - * @deprecated 4.6.0 + * Close wrappers. */ - public function track_ready_next_steps() + public static function output_content_wrapper_end() { } + } + /** + * WC_Twenty_Fourteen class. + */ + class WC_Twenty_Fourteen + { /** - * Track various events when a step is saved. - * - * @deprecated 4.6.0 + * Theme init. */ - public function add_step_save_events() + public static function init() { } /** - * Track store setup and store properties on save. - * - * @deprecated 4.6.0 + * Open wrappers. */ - public function track_store_setup() + public static function output_content_wrapper() { } /** - * Track payment gateways selected. - * - * @deprecated 4.6.0 + * Close wrappers. */ - public function track_payments() + public static function output_content_wrapper_end() { } + } + /** + * WC_Twenty_Nineteen class. + */ + class WC_Twenty_Nineteen + { /** - * Track shipping units and whether or not labels are set. - * - * @deprecated 4.6.0 + * Theme init. */ - public function track_shipping() + public static function init() { } /** - * Track recommended plugins selected for install. - * - * @deprecated 4.6.0 + * Open the Twenty Nineteen wrapper. */ - public function track_recommended() + public static function output_content_wrapper() { } /** - * Tracks when Jetpack is activated through the OBW. - * - * @deprecated 4.6.0 + * Close the Twenty Nineteen wrapper. */ - public function track_jetpack_activate() + public static function output_content_wrapper_end() { } /** - * Tracks when last next_steps screen is viewed in the OBW. + * Enqueue CSS for this theme. * - * @deprecated 4.6.0 + * @param array $styles Array of registered styles. + * @return array */ - public function track_next_steps() + public static function enqueue_styles($styles) { } /** - * Track skipped steps. - * - * @deprecated 4.6.0 + * Tweak Twenty Nineteen features. */ - public function track_skip_step() + public static function tweak_theme_features() { } /** - * Set the OBW steps inside this class instance. - * - * @param array $steps Array of OBW steps. + * Filters Twenty Nineteen custom colors CSS. * - * @deprecated 4.6.0 + * @param string $css Base theme colors CSS. + * @param int $primary_color The user's selected color hue. + * @param string $saturation Filtered theme color saturation level. */ - public function set_obw_steps($steps) + public static function custom_colors_css($css, $primary_color, $saturation) { } } /** - * WooCommerce Coupon Tracking - * - * @package WooCommerce\Tracks - */ - /** - * This class adds actions to track usage of a WooCommerce Coupon. + * WC_Twenty_Seventeen class. */ - class WC_Coupon_Tracking + class WC_Twenty_Seventeen { /** - * Init tracking. + * Theme init. */ - public function init() + public static function init() { } /** - * Send a Tracks event when a coupon is updated. + * Enqueue CSS for this theme. * - * @param WC_Coupon $coupon The coupon that has been updated. - * @param Array $updated_props The props of the coupon that have been updated. + * @param array $styles Array of registered styles. + * @return array */ - public function track_coupon_updated($coupon, $updated_props) + public static function enqueue_styles($styles) { } - } - /** - * This class adds actions to track usage of WooCommerce Orders. - */ - class WC_Coupons_Tracking - { /** - * Init tracking. + * Open the Twenty Seventeen wrapper. */ - public function init() + public static function output_content_wrapper() { } /** - * Add a listener on the "Apply" button to track bulk actions. + * Close the Twenty Seventeen wrapper. */ - public function tracks_coupons_bulk_actions() + public static function output_content_wrapper_end() { } /** - * Track page view events. + * Custom colors. + * + * @param string $css Styles. + * @param string $hue Color. + * @param string $saturation Saturation. + * @return string */ - public function tracks_coupons_events() + public static function custom_colors_css($css, $hue, $saturation) { } } /** - * This class adds actions to track usage of the WooCommerce Extensions page. + * WC_Twenty_Sixteen class. */ - class WC_Extensions_Tracking + class WC_Twenty_Sixteen { /** - * Init tracking. + * Theme init. */ - public function init() + public static function init() { } /** - * Send a Tracks event when an Extensions page is viewed. + * Open wrappers. */ - public function track_extensions_page() + public static function output_content_wrapper() { } /** - * Send a Tracks event when the Extensions page gets a bad response or no response - * from the WCCOM extensions API. - * - * @param string $error Error message. + * Close wrappers. */ - public function track_extensions_page_connection_error(string $error = '') + public static function output_content_wrapper_end() { } + } + /** + * WC_Twenty_Ten class. + */ + class WC_Twenty_Ten + { /** - * Send a Tracks even when a Helper connection process is initiated. + * Theme init. */ - public function track_helper_connection_start() + public static function init() { } /** - * Send a Tracks even when a Helper connection process is cancelled. + * Open wrappers. */ - public function track_helper_connection_cancelled() + public static function output_content_wrapper() { } /** - * Send a Tracks even when a Helper connection process completed successfully. + * Close wrappers. */ - public function track_helper_connection_complete() + public static function output_content_wrapper_end() { } + } + /** + * WC_Twenty_Thirteen class. + */ + class WC_Twenty_Thirteen + { /** - * Send a Tracks even when a Helper has been disconnected. + * Theme init. */ - public function track_helper_disconnected() + public static function init() { } /** - * Send a Tracks even when Helper subscriptions are refreshed. + * Open wrappers. */ - public function track_helper_subscriptions_refresh() + public static function output_content_wrapper() { } /** - * Send a Tracks event when addon is installed via the Extensions page. - * - * @param string $addon_id Addon slug. - * @param string $section Extensions tab. + * Close wrappers. */ - public function track_addon_install($addon_id, $section) + public static function output_content_wrapper_end() { } } /** - * This class adds actions to track usage of WooCommerce Imports. + * WC_Twenty_Twelve class. */ - class WC_Importer_Tracking + class WC_Twenty_Twelve { /** - * Init tracking. + * Theme init. */ - public function init() + public static function init() { } /** - * Route product importer action to the right callback. - * - * @return void + * Open wrappers. */ - public function track_product_importer() + public static function output_content_wrapper() { } /** - * Send a Tracks event when the product importer is started. - * - * @return void + * Close wrappers. */ - public function track_product_importer_start() + public static function output_content_wrapper_end() { } /** - * Send a Tracks event when the product importer has finished. + * Add theme compatibility styles. * * @return void */ - public function track_product_importer_complete() + public static function enqueue_styles() { } } /** - * This class adds actions to track usage of a WooCommerce Order. + * WC_Twenty_Twenty_One class. */ - class WC_Order_Tracking + class WC_Twenty_Twenty_One { /** - * Init tracking. + * Theme init. */ - public function init() + public static function init() { } /** - * Send a Tracks event when an order is viewed. + * Enqueue CSS for this theme. * - * @param WC_Order $order Order. + * @param array $styles Array of registered styles. + * @return array */ - public function track_order_viewed($order) + public static function enqueue_styles($styles) { } - } - /** - * This class adds actions to track usage of WooCommerce Orders. - */ - class WC_Orders_Tracking - { /** - * Init tracking. + * Enqueue the wp-admin CSS overrides for this theme. */ - public function init() + public static function enqueue_admin_styles() { } + } + /** + * WC_Twenty_Twenty_Three class. + */ + class WC_Twenty_Twenty_Three + { /** - * Send a track event when on the Order Listing page, and search results are being displayed. - * - * @deprecated 8.6.0 - * - * @param array $order_ids Array of order_ids that are matches for the search. - * @param string $term The string that was used in the search. - * @param array $search_fields Fields that were used in the original search. + * Theme init. */ - public function track_order_search($order_ids, $term, $search_fields) + public static function init() { } /** - * Send a track event when on the Order Listing page, and search results are being displayed. + * Enqueue CSS for this theme. * - * @since 8.6.0 + * @param array $styles Array of registered styles. + * @return array */ - public function track_search_in_orders_list() + public static function enqueue_styles($styles) { } /** - * Send a Tracks event when the Orders page is viewed. + * Wrap checkout order review with a `col2-set` div. */ - public function track_orders_view() + public static function before_order_review() { } /** - * Send a Tracks event when an order status is changed. - * - * @param int $id Order id. - * @param string $previous_status the old WooCommerce order status. - * @param string $next_status the new WooCommerce order status. + * Close the div wrapper. */ - public function track_order_status_change($id, $previous_status, $next_status) + public static function after_order_review() { } + } + /** + * WC_Twenty_Twenty_One class. + */ + class WC_Twenty_Twenty_Two + { /** - * Send a Tracks event when an order date is changed. - * - * @param int $id Order id. + * Theme init. */ - public function track_created_date_change($id) + public static function init() { } /** - * Track order actions taken. + * Enqueue CSS for this theme. * - * @param int $order_id Order ID. + * @param array $styles Array of registered styles. + * @return array */ - public function track_order_action($order_id) + public static function enqueue_styles($styles) { } /** - * Track "add order" button on the Edit Order screen. + * Wrap checkout order review with a `col2-set` div. */ - public function track_add_order_from_edit() + public static function before_order_review() { } /** - * Adds the tracking scripts for product setting pages. + * Close the div wrapper. */ - public function possibly_add_order_tracking_scripts() + public static function after_order_review() { } } /** - * This class adds actions to track usage of the Product Collection Block. + * WC_Twenty_Twenty class. */ - class WC_Product_Collection_Block_Tracking + class WC_Twenty_Twenty { /** - * Init Tracking. + * Theme init. */ - public function init() + public static function init() { } /** - * Track feature usage of the Product Collection block within the site editor. - * - * @param int $post_id The post ID. - * @param \WP_Post $post The post object. - * - * @return void + * Open the Twenty Twenty wrapper. */ - public function track_collection_instances($post_id, $post) + public static function output_content_wrapper() { } /** - * Track usage of the Product Collection block within the given blocks. - * - * @param array $blocks The parsed blocks to check. - * @param bool $is_in_single_product Whether we are in a single product container (used for keeping state in the recurring process). - * @param bool $is_in_template_part Whether we are in a template part (used for keeping state in the recurring process). - * @param bool $is_in_synced_pattern Whether we are in a synced block (used for keeping state in the recurring process). - * - * @return array Parsed instances of the Product Collection block. + * Close the Twenty Twenty wrapper. */ - private function parse_blocks_track_data($blocks, $is_in_single_product = \false, $is_in_template_part = \false, $is_in_synced_pattern = \false) + public static function output_content_wrapper_end() { } /** - * Parse editor's location context from WP Post. - * - * Possible contexts: - * - post - * - page - * - single-product - * - product-archive - * - cart - * - checkout - * - product-catalog - * - order-confirmation - * - * @param WP_Post $post The Post instance. - * - * @return string Returns the context. + * Set background color to white if it's default, otherwise don't touch it. */ - private function parse_editor_location_context($post) + public static function set_white_background() { } /** - * Parse the collection query filters from the query attributes. + * Enqueue CSS for this theme. * - * @param array $block The parsed block. - * @return array The filters data for tracking. + * @param array $styles Array of registered styles. + * @return array */ - private function get_query_filters_usage_data($block) + public static function enqueue_styles($styles) { } } /** - * This class adds actions to track usage of WooCommerce Products. + * This class adds actions to track usage of WooCommerce. */ - class WC_Products_Tracking + class WC_Site_Tracking { /** - * Tracks source. - */ - const TRACKS_SOURCE = 'product-legacy-editor'; - /** - * Init tracking. + * Check if tracking is enabled. + * + * @return bool */ - public function init() + public static function is_tracking_enabled() { } /** - * Send a Tracks event when the Products page is viewed. + * Register scripts required to record events from javascript. */ - public function track_products_view() + public static function register_scripts() { } /** - * Send a Tracks event when the Products Categories and Tags page is viewed. + * Add scripts required to record events from javascript. */ - public function track_categories_and_tags_view() + public static function enqueue_scripts() { } /** - * Send a Tracks event when a product is updated. - * - * @param int $product_id Product id. - * @param object $post WordPress post. + * Adds the tracking function to the admin footer. */ - public function track_product_updated($product_id, $post) + public static function add_tracking_function() { } /** - * Track the Update button being clicked on the client side. - * This is needed because `track_product_updated` (using the `edit_post` - * hook) is called in response to a number of other triggers. - * - * @param WP_Post $post The post, not used. + * Adds a function to load tracking scripts and enable them client-side on the fly. + * Note that this function does not update `woocommerce_allow_tracking` in the database + * and will not persist enabled tracking across page loads. */ - public function track_product_updated_client_side($post) + public static function add_enable_tracking_function() { } /** - * Get the IDs of the possible product type options. - * - * @return array + * Init tracking. */ - private static function get_possible_product_type_options_ids() + public static function init() { } /** - * Get the product type options for a product. + * Sets a cookie for tracking purposes, but only if tracking is enabled/allowed. * - * @param int $post_id The ID of the product. + * @internal + * @since 9.2.0 * - * @return array + * @param string $cookie_key The key of the cookie. + * @param string $cookie_value The value of the cookie. + * @param int $expire Expiry of the cookie. + * @param bool $secure Whether the cookie should be served only over https. + * @param bool $http_only Whether the cookie is only accessible over HTTP. + * + * @return bool If setting the cookie was attempted (will be false if tracking is not allowed). */ - private static function get_product_type_options($post_id) + public static function set_tracking_cookie(string $cookie_key, string $cookie_value, int $expire = 0, bool $secure = \false, bool $http_only = \false): bool { } + } + /** + * WC_Tracks_Client class. + */ + class WC_Tracks_Client + { /** - * Get a comma-separated string of the product type options that are enabled. - * - * @param array $product_type_options The product type options. - * - * @return string + * Pixel URL. */ - private static function get_product_type_options_string($product_type_options) - { - } + const PIXEL = 'https://pixel.wp.com/t.gif'; /** - * Send a Tracks event when a product is published. - * - * @param int $post_id Post ID. - * @param WP_Post $post Post object. - * @param bool $update Whether this is an existing post being updated. - * @param null|WP_Post $post_before Null for new posts, the WP_Post object prior - * to the update for updated posts. + * Browser type. */ - public function track_product_published($post_id, $post, $update, $post_before) - { - } + const BROWSER_TYPE = 'php-agent'; /** - * Send a Tracks event when a product category is created. + * User agent. + */ + const USER_AGENT_SLUG = 'tracks-client'; + /** + * Initialize tracks client class * - * @param int $category_id Category ID. + * @return void */ - public function track_product_category_created($category_id) + public static function init() { } /** - * Send a Tracks event when a product category is updated. + * Check if identity cookie is set, if not set it. * - * @param int $category_id Category ID. + * @return void */ - public function track_product_category_updated($category_id) + public static function maybe_set_identity_cookie() { } /** - * Adds the tracking scripts for product filtering actions. + * Record a Tracks event * - * @param string $hook Hook of the current page. - * @return string|boolean + * @param array $event Array of event properties. + * @return bool|WP_Error True on success, WP_Error on failure. */ - protected function get_product_screen($hook) + public static function record_event($event) { } /** - * Adds the tracking scripts for product filtering actions. + * Synchronously request the pixel. * - * @param string $hook Page hook. + * @param string $pixel pixel url and query string. + * @return bool Always returns true. */ - public function possibly_add_product_tracking_scripts($hook) + public static function record_pixel($pixel) { } /** - * Adds the tracking scripts for product setting pages. + * Create a timestamp representing milliseconds since 1970-01-01 * - * @param string $hook Page hook. + * @return string A string representing a timestamp. */ - public function possibly_add_product_import_scripts($hook) + public static function build_timestamp() { } /** - * Adds the tracking scripts for product attributes filtering actions. + * Add request timestamp and no cache parameter to pixel. + * Use this the latest possible before the HTTP request. * - * @param string $hook Page hook. + * @param string $pixel Pixel URL. + * @return string Pixel URL with request timestamp and URL terminator. */ - public function possibly_add_attribute_tracking_scripts($hook) + public static function add_request_timestamp_and_nocache($pixel) { } /** - * Adds the tracking scripts for tags and categories filtering actions. + * Get a user's identity to send to Tracks. If Jetpack exists, default to its implementation. * - * @param string $hook Page hook. + * @param int $user_id User id. + * @return array Identity properties. */ - public function possibly_add_tag_tracking_scripts($hook) + public static function get_identity($user_id) { } /** - * Check if the current process is importing products. + * Grabs the user's anon id from cookies, or generates and sets a new one * - * @return bool True if importing, false otherwise. + * @return string An anon id for the user */ - private function is_importing() + public static function get_anon_id() { } } /** - * This class adds actions to track usage of WooCommerce Settings. + * WC_Tracks_Event class. */ - class WC_Settings_Tracking + #[\AllowDynamicProperties] + class WC_Tracks_Event { /** - * List of allowed WooCommerce settings to potentially track updates for. - * - * @var array + * Event name regex. */ - protected $allowed_options = array(); + public const EVENT_NAME_REGEX = '/^(([a-z0-9]+)_){1}([a-z0-9_]+)$/'; /** - * WooCommerce settings that have been updated (and will be tracked). - * - * @var array + * Property name regex. */ - protected $updated_options = array(); + public const PROP_NAME_REGEX = '/^[a-z_][a-z0-9_]*$/'; /** - * List of option names that are dropdown menus. + * Error message as WP_Error. * - * @var array + * @var WP_Error */ - protected $dropdown_menu_options = array(); + public $error; /** - * List of options that have been modified. + * WC_Tracks_Event constructor. * - * @var array + * @param array $event Event properties. */ - protected $modified_options = array(); + public function __construct($event) + { + } /** - * List of options that have been deleted. + * Record Tracks event * - * @var array + * @return bool Always returns true. */ - protected $deleted_options = array(); + public function record() + { + } /** - * List of options that have been added. + * Annotate the event with all relevant info. * - * @var array + * @param array $event Event arguments. + * @return bool|WP_Error True on success, WP_Error on failure. */ - protected $added_options = array(); + public static function validate_and_sanitize($event) + { + } /** - * Toggled options. + * Build a pixel URL that will send a Tracks event when fired. + * On error, returns an empty string (''). * - * @var array - */ - protected $toggled_options = array('enabled' => array(), 'disabled' => array()); - /** - * Init tracking. + * @return string A pixel URL or empty string ('') if there were invalid args. */ - public function init() + public function build_pixel_url() { } /** - * Adds the option to the allowed and updated options directly. - * Currently used for settings that don't use update_option. + * Check if event name is valid. * - * @param array $option WooCommerce option that should be updated. + * @param string $name Event name. + * @return false|int */ - public function add_option_to_list_and_track_setting_change($option) + public static function event_name_is_valid($name) { } /** - * Add a WooCommerce option name to our allowed options list and attach - * the `update_option` hook. Rather than inspecting every updated - * option and pattern matching for "woocommerce", just build a dynamic - * list for WooCommerce options that might get updated. - * - * See `woocommerce_update_option` hook. + * Check if a property name is valid. * - * @param array $option WooCommerce option (config) that might get updated. + * @param string $name Event property. + * @return false|int */ - public function add_option_to_list($option) + public static function prop_name_is_valid($name) { } /** - * Add WooCommerce option to a list of updated options. + * Check event names * - * @param string $option_name Option being updated. - * @param mixed $old_value Old value of option. - * @param mixed $new_value New value of option. + * @param object $event An event object. */ - public function track_setting_change($option_name, $old_value, $new_value) + public static function scrutinize_event_names($event) { } + } + /** + * WC_Tracks_Footer_Pixel class. + */ + class WC_Tracks_Footer_Pixel + { /** - * Send a Tracks event for WooCommerce options that changed values. + * Singleton instance. + * + * @var WC_Tracks_Footer_Pixel */ - public function send_settings_change_event() + protected static $instance = \null; + /** + * Events to send to Tracks. + * + * @var array + */ + protected $events = array(); + /** + * Instantiate the singleton. + * + * @return WC_Tracks_Footer_Pixel + */ + public static function instance() { } /** - * Send a Tracks event for WooCommerce settings page views. + * Constructor - attach hooks to the singleton instance. */ - public function track_settings_page_view() + public function __construct() { } /** - * Adds the tracking scripts for product setting pages. + * Record a Tracks event * - * @param string $hook Page hook. + * @param array $event Array of event properties. + * @return bool|WP_Error True on success, WP_Error on failure. */ - public function possibly_add_settings_tracking_scripts($hook) + public static function record_event($event) { } - } - /** - * This class adds actions to track usage of WooCommerce Orders. - */ - class WC_Status_Tracking - { /** - * Init tracking. + * Add a Tracks event to the queue. + * + * @param WC_Tracks_Event $event Event to track. */ - public function init() + public function add_event($event) { } /** - * Add Tracks events to the status page. + * Add events as tracking pixels to page footer. */ - public function track_status_view() + public function render_tracking_pixels() { } - } - /** - * This class adds actions to track usage of themes on a WooCommerce store. - */ - class WC_Theme_Tracking - { /** - * Init tracking. + * Fire off API calls for events that weren't converted to pixels. + * + * This handles wp_redirect(). */ - public function init() + public function send_tracks_requests() { } /** - * Tracks the sites current theme the first time this code is run, and will only be run once. + * Get all events. */ - public function track_initial_theme() + public static function get_events() { } /** - * Send a Tracks event when a theme is activated so that we can track active block themes. + * Clear all queued events. */ - public function track_activated_theme() + public static function clear_events() { } } /** - * Product category dropdown walker class. + * PHP Tracks Client + * + * @package WooCommerce\Tracks */ - class WC_Product_Cat_Dropdown_Walker extends \Walker + /** + * WC_Tracks class. + */ + class WC_Tracks { /** - * What the class handles. - * - * @var string + * Tracks event name prefix. */ - public $tree_type = 'category'; + const PREFIX = 'wcadmin_'; /** - * DB fields to use. + * Get total product counts. * - * @var array + * @return int Number of products. */ - public $db_fields = array('parent' => 'parent', 'id' => 'term_id', 'slug' => 'slug'); + public static function get_products_count() + { + } /** - * Starts the list before the elements are added. - * - * @see Walker::start_el() - * @since 2.1.0 + * Gather blog related properties. * - * @param string $output Passed by reference. Used to append additional content. - * @param object $cat Category. - * @param int $depth Depth of category in reference to parents. - * @param array $args Arguments. - * @param int $current_object_id Current object ID. + * @param int $user_id User id. + * @return array Blog details. */ - public function start_el(&$output, $cat, $depth = 0, $args = array(), $current_object_id = 0) + public static function get_blog_details($user_id) { } /** - * Traverse elements to create list from elements. - * - * Display one element if the element doesn't have any children otherwise, - * display the element and its children. Will only traverse up to the max. - * depth and no ignore elements under that depth. It is possible to set the. - * max depth to include all depths, see walk() method. - * - * This method shouldn't be called directly, use the walk() method instead. - * - * @since 2.5.0 + * Gather details from the request to the server. * - * @param object $element Data object. - * @param array $children_elements List of elements to continue traversing. - * @param int $max_depth Max depth to traverse. - * @param int $depth Depth of current element. - * @param array $args Arguments. - * @param string $output Passed by reference. Used to append additional content. - * @return null Null on failure with no changes to parameters. + * @return array Server details. */ - public function display_element($element, &$children_elements, $max_depth, $depth, $args, &$output) + public static function get_server_details() { } - } - /** - * Product cat list walker class. - */ - class WC_Product_Cat_List_Walker extends \Walker - { /** - * What the class handles. + * Get role-related details. * - * @var string + * @param WP_User $user The user object. + * @return array The role details. */ - public $tree_type = 'product_cat'; + public static function get_role_details($user) + { + } /** - * DB fields to use. + * Record an event in Tracks - this is the preferred way to record events from PHP. + * Note: the event request won't be made if $properties has a member called `error`. * - * @var array + * @param string $event_name The name of the event. + * @param array $event_properties Custom properties to send with the event. + * @return bool|WP_Error True for success or WP_Error if the event pixel could not be fired. */ - public $db_fields = array('parent' => 'parent', 'id' => 'term_id', 'slug' => 'slug'); - /** - * Starts the list before the elements are added. - * - * @see Walker::start_lvl() - * @since 2.1.0 - * - * @param string $output Passed by reference. Used to append additional content. - * @param int $depth Depth of category. Used for tab indentation. - * @param array $args Will only append content if style argument value is 'list'. - */ - public function start_lvl(&$output, $depth = 0, $args = array()) - { - } - /** - * Ends the list of after the elements are added. - * - * @see Walker::end_lvl() - * @since 2.1.0 - * - * @param string $output Passed by reference. Used to append additional content. - * @param int $depth Depth of category. Used for tab indentation. - * @param array $args Will only append content if style argument value is 'list'. - */ - public function end_lvl(&$output, $depth = 0, $args = array()) - { - } - /** - * Start the element output. - * - * @see Walker::start_el() - * @since 2.1.0 - * - * @param string $output Passed by reference. Used to append additional content. - * @param object $cat Category. - * @param int $depth Depth of category in reference to parents. - * @param array $args Arguments. - * @param integer $current_object_id Current object ID. - */ - public function start_el(&$output, $cat, $depth = 0, $args = array(), $current_object_id = 0) + public static function record_event($event_name, $event_properties = array()) { } /** - * Ends the element output, if needed. + * Track when the user attempts to toggle + * woocommerce_allow_tracking option. * - * @see Walker::end_el() - * @since 2.1.0 + * @since x.x.x * - * @param string $output Passed by reference. Used to append additional content. - * @param object $cat Category. - * @param int $depth Depth of category. Not used. - * @param array $args Only uses 'list' for whether should append to output. + * @param string $prev_value The previous value for the setting. 'yes' or 'no'. + * @param string $new_value The new value for the setting. 'yes' or 'no'. + * @param string $context Which avenue the user utilized to toggle. */ - public function end_el(&$output, $cat, $depth = 0, $args = array()) + public static function track_woocommerce_allow_tracking_toggled($prev_value, $new_value, $context = 'settings') { } /** - * Traverse elements to create list from elements. - * - * Display one element if the element doesn't have any children otherwise, - * display the element and its children. Will only traverse up to the max. - * depth and no ignore elements under that depth. It is possible to set the. - * max depth to include all depths, see walk() method. - * - * This method shouldn't be called directly, use the walk() method instead. - * - * @since 2.5.0 + * Get all properties for the event including filtered and identity properties. * - * @param object $element Data object. - * @param array $children_elements List of elements to continue traversing. - * @param int $max_depth Max depth to traverse. - * @param int $depth Depth of current element. - * @param array $args Arguments. - * @param string $output Passed by reference. Used to append additional content. - * @return null Null on failure with no changes to parameters. + * @param string $event_name Event name. + * @param array $event_properties Event specific properties. + * @return array */ - public function display_element($element, &$children_elements, $max_depth, $depth, $args, &$output) + public static function get_properties($event_name, $event_properties) { } } /** - * WC_WCCOM_Site_Installer Class - * - * Contains functionalities to install products via WooCommerce.com helper connection. + * This class adds actions to track usage of the WooCommerce Onboarding Wizard. */ - class WC_WCCOM_Site_Installer + class WC_Admin_Setup_Wizard_Tracking { /** - * An instance of the WP_Upgrader class to be used for installation. + * Steps for the setup wizard * - * @var \WP_Upgrader $wp_upgrader + * @var array */ - private static $wp_upgrader; + private $steps = array(); /** - * Get WP.org plugin's main file. + * Init tracking. * - * @since 3.7.0 - * @param string $dir Directory name of the plugin. - * @return bool|string + * @deprecated 4.6.0 */ - public static function get_wporg_plugin_main_file($dir) + public function init() { } /** - * Get plugin info + * Get the name of the current step. * - * @since 3.9.0 - * @param string $dir Directory name of the plugin. - * @return bool|array + * @deprecated 4.6.0 + * @return string */ - public static function get_plugin_info($dir) + public function get_current_step() { } /** - * Get an instance of WP_Upgrader to use for installing plugins. + * Add footer scripts to OBW via woocommerce_setup_footer * - * @return WP_Upgrader + * @deprecated 4.6.0 */ - public static function get_wp_upgrader() + public function add_footer_scripts() { } - } - /** - * WC_WCCOM_Site Class - * - * Main class for WooCommerce.com connected site. - */ - class WC_WCCOM_Site - { - const AUTH_ERROR_FILTER_NAME = 'wccom_auth_error'; /** - * Load the WCCOM site class. + * Dequeue unwanted scripts from OBW footer. * - * @since 3.7.0 + * @deprecated 4.6.0 */ - public static function load() + public function dequeue_non_allowed_scripts() { } /** - * Include support files. + * Track when tracking is opted into and OBW has started. * - * @since 3.7.0 + * @param string $option Option name. + * @param string $value Option value. + * + * @deprecated 4.6.0 */ - protected static function includes() + public function track_start($option, $value) { } /** - * Authenticate WooCommerce.com request. + * Track the marketing form on submit. * - * @since 3.7.0 - * @param int|false $user_id User ID. - * @return int|false + * @deprecated 4.6.0 */ - public static function authenticate_wccom($user_id) + public function track_ready_next_steps() { } /** - * Get the authorization header. - * - * On certain systems and configurations, the Authorization header will be - * stripped out by the server or PHP. Typically this is then used to - * generate `PHP_AUTH_USER`/`PHP_AUTH_PASS` but not passed on. We use - * `getallheaders` here to try and grab it out instead. + * Track various events when a step is saved. * - * @since 3.7.0 - * @return string Authorization header if set. + * @deprecated 4.6.0 */ - protected static function get_authorization_header() + public function add_step_save_events() { } /** - * Check if this is a request to WCCOM Site REST API. + * Track store setup and store properties on save. * - * @since 3.7.0 - * @return bool + * @deprecated 4.6.0 */ - protected static function is_request_to_wccom_site_rest_api() + public function track_store_setup() { } /** - * Verify WooCommerce.com request from a given body and signature request. + * Track payment gateways selected. * - * @since 3.7.0 - * @param string $body Request body. - * @param string $signature Request signature found in X-Woo-Signature header. - * @param string $access_token_secret Access token secret for this site. - * @return bool + * @deprecated 4.6.0 */ - protected static function verify_wccom_request($body, $signature, $access_token_secret) + public function track_payments() { } /** - * Register wccom-site REST namespace. + * Track shipping units and whether or not labels are set. * - * @since 3.7.0 - * @param array $namespaces List of registered namespaces. - * @return array Registered namespaces. + * @deprecated 4.6.0 */ - public static function register_rest_namespace($namespaces) + public function track_shipping() { } - } - /** - * WC_WCCOM_Site_Installation_Manager class - */ - class WC_WCCOM_Site_Installation_Manager - { - const STEPS = array('get_product_info', 'download_product', 'unpack_product', 'move_product', 'activate_product'); /** - * The product ID. + * Track recommended plugins selected for install. * - * @var int + * @deprecated 4.6.0 */ - protected $product_id; + public function track_recommended() + { + } /** - * The idempotency key. + * Tracks when Jetpack is activated through the OBW. * - * @var string + * @deprecated 4.6.0 */ - protected $idempotency_key; + public function track_jetpack_activate() + { + } /** - * Constructor. + * Tracks when last next_steps screen is viewed in the OBW. * - * @param int $product_id The product ID. - * @param string $idempotency_key The idempotency key. + * @deprecated 4.6.0 */ - public function __construct(int $product_id, string $idempotency_key = '') + public function track_next_steps() { } /** - * Get the installation status. + * Track skipped steps. * - * @return WC_WCCOM_Site_Installation_State - * @throws Installer_Error If installation status request failed. + * @deprecated 4.6.0 */ - public function get_installation_status(): \WC_WCCOM_Site_Installation_State + public function track_skip_step() { } /** - * Run the installation. + * Set the OBW steps inside this class instance. * - * @param string $run_until_step The step to run until. - * @return bool - * @throws Installer_Error If installation failed to run. + * @param array $steps Array of OBW steps. + * + * @deprecated 4.6.0 */ - public function run_installation(string $run_until_step): bool + public function set_obw_steps($steps) { } + } + /** + * WooCommerce Coupon Tracking + * + * @package WooCommerce\Tracks + */ + /** + * This class adds actions to track usage of a WooCommerce Coupon. + */ + class WC_Coupon_Tracking + { /** - * Get the next step to run. - * - * @return bool - * @throws WC_REST_WCCOM_Site_Installer_Error If the installation cannot be rest. + * Init tracking. */ - public function reset_installation(): bool + public function init() { } /** - * Check if the installation can be run. + * Send a Tracks event when a coupon is updated. * - * @param string $run_until_step Run until this step. - * @param WC_WCCOM_Site_Installation_State $state Installation state. - * @return void - * @throws WC_REST_WCCOM_Site_Installer_Error If the installation cannot be run. + * @param WC_Coupon $coupon The coupon that has been updated. + * @param Array $updated_props The props of the coupon that have been updated. */ - protected function can_run_installation($run_until_step, $state) + public function track_coupon_updated($coupon, $updated_props) { } + } + /** + * This class adds actions to track usage of WooCommerce Orders. + */ + class WC_Coupons_Tracking + { /** - * Get the next step to run. - * - * @param WC_WCCOM_Site_Installation_State $state Installation state. - * @return string + * Init tracking. */ - protected function get_next_step($state): string + public function init() { } /** - * Get the steps to run. - * - * @param string $start_step The step to start from. - * @param string $end_step The step to end at. - * @return string[] + * Add a listener on the "Apply" button to track bulk actions. */ - protected function get_installation_steps(string $start_step, string $end_step) + public function tracks_coupons_bulk_actions() { } /** - * Run the step. - * - * @param string $step_name Step name. - * @param WC_WCCOM_Site_Installation_State $state Installation state. - * @return void - * @throws WC_REST_WCCOM_Site_Installer_Error If the step fails. + * Track page view events. */ - protected function run_step($step_name, $state) + public function tracks_coupons_events() { } } /** - * WC_WCCOM_Site_Installation_State_Storage class + * This class adds actions to track usage of the WooCommerce Extensions page. */ - class WC_WCCOM_Site_Installation_State_Storage + class WC_Extensions_Tracking { /** - * Get state from storage. - * - * @param int $product_id The product ID. - * @return WC_WCCOM_Site_Installation_State|null + * Init tracking. */ - public static function get_state($product_id): ?\WC_WCCOM_Site_Installation_State + public function init() { } /** - * Save state to storage. - * - * @param WC_WCCOM_Site_Installation_State $state The state to save. - * @return bool + * Send a Tracks event when an Extensions page is viewed. */ - public static function save_state(\WC_WCCOM_Site_Installation_State $state): bool + public function track_extensions_page() { } /** - * Delete state from storage. + * Send a Tracks event when the Extensions page gets a bad response or no response + * from the WCCOM extensions API. * - * @param WC_WCCOM_Site_Installation_State $state The state to delete. - * @return bool + * @param string $error Error message. */ - public static function delete_state(\WC_WCCOM_Site_Installation_State $state): bool + public function track_extensions_page_connection_error(string $error = '') { } /** - * Get the storage key for a product ID. - * - * @param int $product_id The product ID. - * @return string + * Send a Tracks even when a Helper connection process is initiated. */ - protected static function get_storage_key($product_id): string + public function track_helper_connection_start() { } - } - /** - * WC_WCCOM_Site_Installation_State class - */ - class WC_WCCOM_Site_Installation_State - { /** - * The product ID. - * - * @var string + * Send a Tracks even when a Helper connection process is cancelled. */ - protected $product_id; + public function track_helper_connection_cancelled() + { + } /** - * The idempotency key. - * - * @var string + * Send a Tracks even when a Helper connection process completed successfully. */ - protected $idempotency_key; + public function track_helper_connection_complete() + { + } /** - * The last step name. - * - * @var string + * Send a Tracks even when a Helper has been disconnected. */ - protected $last_step_name; + public function track_helper_disconnected() + { + } /** - * The last step status. - * - * @var string + * Send a Tracks even when Helper subscriptions are refreshed. */ - protected $last_step_status; + public function track_helper_subscriptions_refresh() + { + } /** - * The last step error. + * Send a Tracks event when addon is installed via the Extensions page. * - * @var string + * @param string $addon_id Addon slug. + * @param string $section Extensions tab. */ - protected $last_step_error; + public function track_addon_install($addon_id, $section) + { + } + } + /** + * This class adds actions to track usage of WooCommerce Imports. + */ + class WC_Importer_Tracking + { /** - * The product type. - * - * @var string + * Init tracking. */ - protected $product_type; + public function init() + { + } /** - * The product name. + * Route product importer action to the right callback. * - * @var string + * @return void */ - protected $product_name; + public function track_product_importer() + { + } /** - * The product slug. + * Send a Tracks event when the product importer is started. * - * @var string + * @return void */ - protected $download_url; + public function track_product_importer_start() + { + } /** - * The path to the downloaded file. + * Send a Tracks event when the product importer has finished. * - * @var string + * @return void */ - protected $download_path; + public function track_product_importer_complete() + { + } + } + /** + * This class adds actions to track usage of a WooCommerce Order. + */ + class WC_Order_Tracking + { /** - * The path to the unpacked file. - * - * @var string + * Init tracking. */ - protected $unpacked_path; + public function init() + { + } /** - * The path to the installed file. + * Send a Tracks event when an order is viewed. * - * @var string + * @param WC_Order $order Order. */ - protected $installed_path; + public function track_order_viewed($order) + { + } + } + /** + * This class adds actions to track usage of WooCommerce Orders. + */ + class WC_Orders_Tracking + { /** - * The plugin info for the already installed plugin. - * - * @var array + * Init tracking. */ - protected $already_installed_plugin_info; + public function init() + { + } /** - * The timestamp of the installation start. + * Send a track event when on the Order Listing page, and search results are being displayed. * - * @var int - */ - protected $started_date; - const STEP_STATUS_IN_PROGRESS = 'in-progress'; - const STEP_STATUS_FAILED = 'failed'; - const STEP_STATUS_COMPLETED = 'completed'; - /** - * Constructor. + * @deprecated 8.6.0 * - * @param string $product_id The product ID. + * @param array $order_ids Array of order_ids that are matches for the search. + * @param string $term The string that was used in the search. + * @param array $search_fields Fields that were used in the original search. */ - protected function __construct($product_id) + public function track_order_search($order_ids, $term, $search_fields) { } /** - * Initiate an existing installation state. + * Send a track event when on the Order Listing page, and search results are being displayed. * - * @param int $product_id The product ID. - * @param string $idempotency_key The idempotency key. - * @param string $last_step_name The last step name. - * @param string $last_step_status The last step status. - * @param string $last_step_error The last step error. - * @param int $started_date The timestamp of the installation start. - * @return WC_WCCOM_Site_Installation_State The instance. + * @since 8.6.0 */ - public static function initiate_existing($product_id, $idempotency_key, $last_step_name, $last_step_status, $last_step_error, $started_date) + public function track_search_in_orders_list() { } /** - * Initiate a new installation state. - * - * @param init $product_id The product ID. - * @param string $idempotency_key The idempotency key. - * @return WC_WCCOM_Site_Installation_State The instance. + * Send a Tracks event when the Orders page is viewed. */ - public static function initiate_new($product_id, $idempotency_key) + public function track_orders_view() { } /** - * Get the product ID. + * Send a Tracks event when an order status is changed. * - * @return string + * @param int $id Order id. + * @param string $previous_status the old WooCommerce order status. + * @param string $next_status the new WooCommerce order status. */ - public function get_product_id() + public function track_order_status_change($id, $previous_status, $next_status) { } /** - * Get the idempotency key. + * Send a Tracks event when an order date is changed. * - * @return string + * @param int $id Order id. */ - public function get_idempotency_key() + public function track_created_date_change($id) { } /** - * Get the timestamp of the installation start. + * Track order actions taken. * - * @return int + * @param int $order_id Order ID. */ - public function get_last_step_name() + public function track_order_action($order_id) { } /** - * Get the last step status. - * - * @return string + * Track "add order" button on the Edit Order screen. */ - public function get_last_step_status() + public function track_add_order_from_edit() { } /** - * Get the last step error. - * - * @return int + * Adds the tracking scripts for product setting pages. */ - public function get_last_step_error() + public function possibly_add_order_tracking_scripts() { } - /** - * Initiate a step. - * - * @param string $step_name Step name. - * @return void + } + /** + * This class adds actions to track usage of the Product Collection Block. + */ + class WC_Product_Collection_Block_Tracking + { + /** + * Init Tracking. */ - public function initiate_step($step_name) + public function init() { } /** - * Capture a successful installation of a step. + * Track feature usage of the Product Collection block within the site editor. * - * @param string $step_name The step name. + * @param int $post_id The post ID. + * @param \WP_Post $post The post object. + * + * @return void */ - public function complete_step($step_name) + public function track_collection_instances($post_id, $post) { } /** - * Capture an installation failure. + * Track usage of the Product Collection block within the given blocks. * - * @param string $step_name The step name. - * @param string $error_code The error code. + * @param array $blocks The parsed blocks to check. + * @param bool $is_in_single_product Whether we are in a single product container (used for keeping state in the recurring process). + * @param bool $is_in_template_part Whether we are in a template part (used for keeping state in the recurring process). + * @param bool $is_in_synced_pattern Whether we are in a synced block (used for keeping state in the recurring process). + * + * @return array Parsed instances of the Product Collection block. */ - public function capture_failure($step_name, $error_code) + private function parse_blocks_track_data($blocks, $is_in_single_product = \false, $is_in_template_part = \false, $is_in_synced_pattern = \false) { } /** - * Get the product type. + * Parse editor's location context from WP Post. * - * @return string + * Possible contexts: + * - post + * - page + * - single-product + * - product-archive + * - cart + * - checkout + * - product-catalog + * - order-confirmation + * + * @param WP_Post $post The Post instance. + * + * @return string Returns the context. */ - public function get_product_type() + private function parse_editor_location_context($post) { } /** - * Set the product type. + * Parse the collection query filters from the query attributes. * - * @param string $product_type The product type. + * @param array $block The parsed block. + * @return array The filters data for tracking. */ - public function set_product_type($product_type) + private function get_query_filters_usage_data($block) { } + } + /** + * This class adds actions to track usage of WooCommerce Products. + */ + class WC_Products_Tracking + { /** - * Get the product name. - * - * @return string + * Tracks source. */ - public function get_product_name() - { - } + const TRACKS_SOURCE = 'product-legacy-editor'; /** - * Set the product name. - * - * @param string $product_name The product name. + * Init tracking. */ - public function set_product_name($product_name) + public function init() { } /** - * Get the download URL. - * - * @return string + * Send a Tracks event when the Products page is viewed. */ - public function get_download_url() + public function track_products_view() { } /** - * Set the download URL. - * - * @param string $download_url The download URL. + * Send a Tracks event when the Products Categories and Tags page is viewed. */ - public function set_download_url($download_url) + public function track_categories_and_tags_view() { } /** - * Get the path to the downloaded file. + * Send a Tracks event when a product is updated. * - * @return string + * @param int $product_id Product id. + * @param object $post WordPress post. */ - public function get_download_path() + public function track_product_updated($product_id, $post) { } /** - * Set the path to the downloaded file. + * Track the Update button being clicked on the client side. + * This is needed because `track_product_updated` (using the `edit_post` + * hook) is called in response to a number of other triggers. * - * @param string $download_path The path to the downloaded file. + * @param WP_Post $post The post, not used. */ - public function set_download_path($download_path) + public function track_product_updated_client_side($post) { } /** - * Get the path to the unpacked file. + * Get the IDs of the possible product type options. * - * @return string + * @return array */ - public function get_unpacked_path() + private static function get_possible_product_type_options_ids() { } /** - * Set the path to the unpacked file. + * Get the product type options for a product. * - * @param string $unpacked_path The path to the unpacked file. + * @param int $post_id The ID of the product. + * + * @return array */ - public function set_unpacked_path($unpacked_path) + private static function get_product_type_options($post_id) { } /** - * Get the path to the installed file. + * Get a comma-separated string of the product type options that are enabled. + * + * @param array $product_type_options The product type options. * * @return string */ - public function get_installed_path() + private static function get_product_type_options_string($product_type_options) { } /** - * Set the path to the installed file. + * Send a Tracks event when a product is published. * - * @param string $installed_path The path to the installed file. + * @param int $post_id Post ID. + * @param WP_Post $post Post object. + * @param bool $update Whether this is an existing post being updated. + * @param null|WP_Post $post_before Null for new posts, the WP_Post object prior + * to the update for updated posts. */ - public function set_installed_path($installed_path) + public function track_product_published($post_id, $post, $update, $post_before) { } /** - * Get the plugin info for the already installed plugin. + * Send a Tracks event when a product category is created. * - * @return array + * @param int $category_id Category ID. */ - public function get_already_installed_plugin_info() + public function track_product_category_created($category_id) { } /** - * Set the plugin info for the already installed plugin. + * Send a Tracks event when a product category is updated. * - * @param array $plugin_info The plugin info. + * @param int $category_id Category ID. */ - public function set_already_installed_plugin_info($plugin_info) + public function track_product_category_updated($category_id) { } /** - * Get the timestamp of the installation start. + * Adds the tracking scripts for product filtering actions. * - * @return int + * @param string $hook Hook of the current page. + * @return string|boolean */ - public function get_started_date() + protected function get_product_screen($hook) { } - } - interface WC_WCCOM_Site_Installation_Step - { - /** - * Constructor. - * - * @param array $state The current installation state. - */ - public function __construct($state); - /** - * Run the step installation process. - */ - public function run(); - } - /** - * WC_WCCOM_Site_Installation_Step_Activate_Product Class - */ - class WC_WCCOM_Site_Installation_Step_Activate_Product implements \WC_WCCOM_Site_Installation_Step - { - /** - * The current installation state. - * - * @var WC_WCCOM_Site_Installation_State - */ - protected $state; /** - * Constructor. + * Adds the tracking scripts for product filtering actions. * - * @param array $state The current installation state. + * @param string $hook Page hook. */ - public function __construct($state) + public function possibly_add_product_tracking_scripts($hook) { } /** - * Run the step installation process. + * Adds the tracking scripts for product setting pages. + * + * @param string $hook Page hook. */ - public function run() + public function possibly_add_product_import_scripts($hook) { } /** - * Activate plugin. + * Adds the tracking scripts for product attributes filtering actions. * - * @param int $product_id Product ID. - * @return void - * @throws WC_REST_WCCOM_Site_Installer_Error If plugin activation failed. + * @param string $hook Page hook. */ - private function activate_plugin($product_id) + public function possibly_add_attribute_tracking_scripts($hook) { } /** - * Activate theme. + * Adds the tracking scripts for tags and categories filtering actions. * - * @param int $product_id Product ID. - * @return void - * @throws WC_REST_WCCOM_Site_Installer_Error If theme activation failed. + * @param string $hook Page hook. */ - private function activate_theme($product_id) + public function possibly_add_tag_tracking_scripts($hook) { } /** - * Get WP.org product directory name. + * Check if the current process is importing products. * - * @return string|false + * @return bool True if importing, false otherwise. */ - private function get_wporg_product_dir_name() + private function is_importing() { } } /** - * WC_WCCOM_Site_Installation_Step_Download_Product class + * This class adds actions to track usage of WooCommerce Settings. */ - class WC_WCCOM_Site_Installation_Step_Download_Product implements \WC_WCCOM_Site_Installation_Step + class WC_Settings_Tracking { /** - * The current installation state. + * List of allowed WooCommerce settings to potentially track updates for. * - * @var WC_WCCOM_Site_Installation_State + * @var array */ - protected $state; + protected $allowed_options = array(); /** - * Constructor. + * WooCommerce settings that have been updated (and will be tracked). * - * @param array $state The current installation state. + * @var array */ - public function __construct($state) - { - } + protected $updated_options = array(); /** - * Run the step installation process. + * List of option names that are dropdown menus. * - * @throws Installer_Error Installer Error. + * @var array */ - public function run() - { - } - } - /** - * WC_WCCOM_Site_Installation_Step_Get_Product_Info class - */ - class WC_WCCOM_Site_Installation_Step_Get_Product_Info implements \WC_WCCOM_Site_Installation_Step - { + protected $dropdown_menu_options = array(); /** - * The current installation state. + * List of options that have been modified. * - * @var WC_WCCOM_Site_Installation_State + * @var array */ - protected $state; + protected $modified_options = array(); /** - * Constructor. + * List of options that have been deleted. * - * @param array $state The current installation state. + * @var array */ - public function __construct($state) - { - } + protected $deleted_options = array(); /** - * Run the step installation process. + * List of options that have been added. * - * @throws Installer_Error Installer Error. - * @return array + * @var array */ - public function run() + protected $added_options = array(); + /** + * Toggled options. + * + * @var array + */ + protected $toggled_options = array('enabled' => array(), 'disabled' => array()); + /** + * Init tracking. + */ + public function init() { } /** - * Get download URL for wporg product. - * - * @param array $data Product data. + * Adds the option to the allowed and updated options directly. + * Currently used for settings that don't use update_option. * - * @return string|null - * @throws Installer_Error Installer Error. + * @param array $option WooCommerce option that should be updated. */ - protected function get_wporg_download_url($data) + public function add_option_to_list_and_track_setting_change($option) { } /** - * Get download URL for wccom product. + * Add a WooCommerce option name to our allowed options list and attach + * the `update_option` hook. Rather than inspecting every updated + * option and pattern matching for "woocommerce", just build a dynamic + * list for WooCommerce options that might get updated. * - * @param int $product_id Product ID. + * See `woocommerce_update_option` hook. * - * @return string - * @throws Installer_Error Installer Error. + * @param array $option WooCommerce option (config) that might get updated. */ - protected function get_wccom_download_url($product_id) + public function add_option_to_list($option) { } - } - /** - * WC_WCCOM_Site_Installation_Step_Move_Product class - */ - class WC_WCCOM_Site_Installation_Step_Move_Product implements \WC_WCCOM_Site_Installation_Step - { /** - * The current installation state. + * Add WooCommerce option to a list of updated options. * - * @var WC_WCCOM_Site_Installation_State + * @param string $option_name Option being updated. + * @param mixed $old_value Old value of option. + * @param mixed $new_value New value of option. */ - protected $state; + public function track_setting_change($option_name, $old_value, $new_value) + { + } /** - * Constructor. - * - * @param array $state The current installation state. + * Send a Tracks event for WooCommerce options that changed values. */ - public function __construct($state) + public function send_settings_change_event() { } /** - * Run the step installation process. + * Send a Tracks event for WooCommerce settings page views. */ - public function run() + public function track_settings_page_view() { } /** - * Connect to wccom if installing a theme + * Adds the tracking scripts for product setting pages. * - * @return void + * @param string $hook Page hook. */ - protected function maybe_connect_theme() + public function possibly_add_settings_tracking_scripts($hook) { } } /** - * WC_WCCOM_Site_Installation_Step_Unpack_Product class + * This class adds actions to track usage of WooCommerce Orders. */ - class WC_WCCOM_Site_Installation_Step_Unpack_Product implements \WC_WCCOM_Site_Installation_Step + class WC_Status_Tracking { /** - * The current installation state. - * - * @var WC_WCCOM_Site_Installation_State - */ - protected $state; - /** - * Constructor. - * - * @param array $state The current installation state. + * Init tracking. */ - public function __construct($state) + public function init() { } /** - * Run the step installation process. - * - * @return WC_WCCOM_Site_Installation_State - * @throws WC_REST_WCCOM_Site_Installer_Error If the package unpacked path is not returned. + * Add Tracks events to the status page. */ - public function run() + public function track_status_view() { } } /** - * WCCOM Site Installer Error Codes Class - * - * Stores data for errors, returned by installer API. - */ - class WC_REST_WCCOM_Site_Installer_Error_Codes - { - const NOT_AUTHENTICATED = 'not_authenticated'; - const NO_ACCESS_TOKEN = 'no_access_token'; - const NO_SIGNATURE = 'no_signature'; - const SITE_NOT_CONNECTED = 'site_not_connnected'; - const INVALID_TOKEN = 'invalid_token'; - const REQUEST_VERIFICATION_FAILED = 'request_verification_failed'; - const USER_NOT_FOUND = 'user_not_found'; - const NO_PERMISSION = 'forbidden'; - const IDEMPOTENCY_KEY_MISMATCH = 'idempotency_key_mismatch'; - const NO_INITIATED_INSTALLATION_FOUND = 'no_initiated_installation_found'; - const ALL_INSTALLATION_STEPS_RUN = 'all_installation_steps_run'; - const REQUESTED_STEP_ALREADY_RUN = 'requested_step_already_run'; - const PLUGIN_ALREADY_INSTALLED = 'plugin_already_installed'; - const INSTALLATION_ALREADY_RUNNING = 'installation_already_running'; - const INSTALLATION_FAILED = 'installation_failed'; - const FILESYSTEM_REQUIREMENTS_NOT_MET = 'filesystem_requirements_not_met'; - const FAILED_GETTING_PRODUCT_INFO = 'product_info_failed'; - const INVALID_PRODUCT_INFO_RESPONSE = 'invalid_product_info_response'; - const WCCOM_PRODUCT_MISSING_SUBSCRIPTION = 'wccom_product_missing_subscription'; - const WCCOM_PRODUCT_MISSING_PACKAGE = 'wccom_product_missing_package'; - const WPORG_PRODUCT_MISSING_DOWNLOAD_LINK = 'wporg_product_missing_download_link'; - const MISSING_DOWNLOAD_PATH = 'missing_download_path'; - const MISSING_UNPACKED_PATH = 'missing_unpacked_path'; - const UNKNOWN_FILENAME = 'unknown_filename'; - const PLUGIN_ACTIVATION_ERROR = 'plugin_activation_error'; - const UNEXPECTED_ERROR = 'unexpected_error'; - const FAILED_TO_RESET_INSTALLATION_STATE = 'failed_to_reset_installation_state'; - const ERROR_MESSAGES = array(self::NOT_AUTHENTICATED => 'Authentication required', self::NO_ACCESS_TOKEN => 'No access token provided', self::NO_SIGNATURE => 'No signature provided', self::SITE_NOT_CONNECTED => 'Site not connected to WooCommerce.com', self::INVALID_TOKEN => 'Invalid access token provided', self::REQUEST_VERIFICATION_FAILED => 'Request verification by signature failed', self::USER_NOT_FOUND => 'Token owning user not found', self::NO_PERMISSION => 'You do not have permission to install plugin or theme', self::IDEMPOTENCY_KEY_MISMATCH => 'Idempotency key mismatch', self::NO_INITIATED_INSTALLATION_FOUND => 'No initiated installation for the product found', self::ALL_INSTALLATION_STEPS_RUN => 'All installation steps have been run', self::REQUESTED_STEP_ALREADY_RUN => 'Requested step has already been run', self::PLUGIN_ALREADY_INSTALLED => 'The plugin has already been installed', self::INSTALLATION_ALREADY_RUNNING => 'The installation of the plugin is already running', self::INSTALLATION_FAILED => 'The installation of the plugin failed', self::FILESYSTEM_REQUIREMENTS_NOT_MET => 'The filesystem requirements are not met', self::FAILED_GETTING_PRODUCT_INFO => 'Failed to retrieve product info from WooCommerce.com', self::INVALID_PRODUCT_INFO_RESPONSE => 'Invalid product info response from WooCommerce.com', self::WCCOM_PRODUCT_MISSING_SUBSCRIPTION => 'Product subscription is missing', self::WCCOM_PRODUCT_MISSING_PACKAGE => 'Could not find product package', self::MISSING_DOWNLOAD_PATH => 'Download path is missing', self::MISSING_UNPACKED_PATH => 'Unpacked path is missing', self::UNKNOWN_FILENAME => 'Unknown product filename', self::PLUGIN_ACTIVATION_ERROR => 'Plugin activation error', self::UNEXPECTED_ERROR => 'Unexpected error', self::FAILED_TO_RESET_INSTALLATION_STATE => 'Failed to reset installation state'); - const HTTP_CODES = array(self::NOT_AUTHENTICATED => 401, self::NO_ACCESS_TOKEN => 400, self::NO_SIGNATURE => 400, self::SITE_NOT_CONNECTED => 401, self::INVALID_TOKEN => 401, self::REQUEST_VERIFICATION_FAILED => 400, self::USER_NOT_FOUND => 401, self::NO_PERMISSION => 403, self::IDEMPOTENCY_KEY_MISMATCH => 400, self::NO_INITIATED_INSTALLATION_FOUND => 400, self::ALL_INSTALLATION_STEPS_RUN => 400, self::REQUESTED_STEP_ALREADY_RUN => 400, self::UNEXPECTED_ERROR => 500); - } - /** - * WCCOM Site Installer Error Class + * This class adds actions to track usage of themes on a WooCommerce store. */ - class WC_REST_WCCOM_Site_Installer_Error extends \Exception + class WC_Theme_Tracking { /** - * Constructor for the Installer Error class. - * - * @param string $error_code Error code. - * @param string $error_message Error message. - * @param int $http_code HTTP status code. - */ - public function __construct($error_code, $error_message = \null, $http_code = \null) - { - } - /** - * Get the error code. + * Init tracking. */ - public function get_error_code() + public function init() { } /** - * Get the error message. + * Tracks the sites current theme the first time this code is run, and will only be run once. */ - public function get_error_message() + public function track_initial_theme() { } /** - * Get the HTTP status code. + * Send a Tracks event when a theme is activated so that we can track active block themes. */ - public function get_http_code() + public function track_activated_theme() { } } /** - * Brand Description Widget - * - * When viewing a brand archive, show the current brands description + image - * - * Important: For internal use only by the Automattic\WooCommerce\Internal\Brands package. - * - * @package WooCommerce\Widgets - * @version 9.4.0 + * Product category dropdown walker class. */ - class WC_Widget_Brand_Description extends \WP_Widget + class WC_Product_Cat_Dropdown_Walker extends \Walker { /** - * Widget class. + * What the class handles. * * @var string */ - public $woo_widget_cssclass; + public $tree_type = 'category'; /** - * Widget description. + * DB fields to use. * - * @var string + * @var array */ - public $woo_widget_description; + public $db_fields = array('parent' => 'parent', 'id' => 'term_id', 'slug' => 'slug'); /** - * Widget idbase. + * Starts the list before the elements are added. * - * @var string - */ - public $woo_widget_idbase; - /** - * Widget name. + * @see Walker::start_el() + * @since 2.1.0 * - * @var string + * @param string $output Passed by reference. Used to append additional content. + * @param object $cat Category. + * @param int $depth Depth of category in reference to parents. + * @param array $args Arguments. + * @param int $current_object_id Current object ID. */ - public $woo_widget_name; - /** Constructor */ - public function __construct() + public function start_el(&$output, $cat, $depth = 0, $args = array(), $current_object_id = 0) { } /** - * Echoes the widget content. - * - * @see WP_Widget + * Traverse elements to create list from elements. * - * @param array $args Display arguments including 'before_title', 'after_title', - * 'before_widget', and 'after_widget'. - * @param array $instance The settings for the particular instance of the widget. - */ - public function widget($args, $instance) - { - } - /** - * Updates widget instance. + * Display one element if the element doesn't have any children otherwise, + * display the element and its children. Will only traverse up to the max. + * depth and no ignore elements under that depth. It is possible to set the. + * max depth to include all depths, see walk() method. * - * @see WP_Widget->update + * This method shouldn't be called directly, use the walk() method instead. * - * @param array $new_instance New widget instance. - * @param array $old_instance Old widget instance. - */ - public function update($new_instance, $old_instance) - { - } - /** - * Outputs the settings update form. + * @since 2.5.0 * - * @param array $instance Current settings. + * @param object $element Data object. + * @param array $children_elements List of elements to continue traversing. + * @param int $max_depth Max depth to traverse. + * @param int $depth Depth of current element. + * @param array $args Arguments. + * @param string $output Passed by reference. Used to append additional content. + * @return null Null on failure with no changes to parameters. */ - public function form($instance) + public function display_element($element, &$children_elements, $max_depth, $depth, $args, &$output) { } } /** - * Layered Navigation Widget for brands WC 2.6 version - * - * Important: For internal use only by the Automattic\WooCommerce\Internal\Brands package. - * - * @package WooCommerce\Widgets - * @version 9.4.0 - * @extends WP_Widget + * Product cat list walker class. */ - class WC_Widget_Brand_Nav extends \WC_Widget + class WC_Product_Cat_List_Walker extends \Walker { /** - * Constructor + * What the class handles. * - * @return void + * @var string */ - public function __construct() - { - } + public $tree_type = 'product_cat'; /** - * Filter out all categories and not display them + * DB fields to use. * - * @param array $cat_args Category arguments. + * @var array */ - public function filter_out_cats($cat_args) - { - } + public $db_fields = array('parent' => 'parent', 'id' => 'term_id', 'slug' => 'slug'); /** - * Return the currently viewed taxonomy name. + * Starts the list before the elements are added. * - * @return string - */ - protected function get_current_taxonomy() - { - } - /** - * Return the currently viewed term ID. + * @see Walker::start_lvl() + * @since 2.1.0 * - * @return int + * @param string $output Passed by reference. Used to append additional content. + * @param int $depth Depth of category. Used for tab indentation. + * @param array $args Will only append content if style argument value is 'list'. */ - protected function get_current_term_id() + public function start_lvl(&$output, $depth = 0, $args = array()) { } /** - * Return the currently viewed term slug. + * Ends the list of after the elements are added. * - * @return int + * @see Walker::end_lvl() + * @since 2.1.0 + * + * @param string $output Passed by reference. Used to append additional content. + * @param int $depth Depth of category. Used for tab indentation. + * @param array $args Will only append content if style argument value is 'list'. */ - protected function get_current_term_slug() + public function end_lvl(&$output, $depth = 0, $args = array()) { } /** - * Widget function. + * Start the element output. * - * @see WP_Widget + * @see Walker::start_el() + * @since 2.1.0 * - * @param array $args Arguments. - * @param array $instance Widget instance. - * @return void + * @param string $output Passed by reference. Used to append additional content. + * @param object $cat Category. + * @param int $depth Depth of category in reference to parents. + * @param array $args Arguments. + * @param integer $current_object_id Current object ID. */ - public function widget($args, $instance) + public function start_el(&$output, $cat, $depth = 0, $args = array(), $current_object_id = 0) { } /** - * Update function. + * Ends the element output, if needed. * - * @see WP_Widget->update + * @see Walker::end_el() + * @since 2.1.0 * - * @param array $new_instance The new settings for the particular instance of the widget. - * @param array $old_instance The old settings for the particular instance of the widget. - * @return array + * @param string $output Passed by reference. Used to append additional content. + * @param object $cat Category. + * @param int $depth Depth of category. Not used. + * @param array $args Only uses 'list' for whether should append to output. */ - public function update($new_instance, $old_instance) + public function end_el(&$output, $cat, $depth = 0, $args = array()) { } /** - * Form function. + * Traverse elements to create list from elements. * - * @see WP_Widget->form + * Display one element if the element doesn't have any children otherwise, + * display the element and its children. Will only traverse up to the max. + * depth and no ignore elements under that depth. It is possible to set the. + * max depth to include all depths, see walk() method. * - * @param array $instance Widget instance. - * @return void - */ - public function form($instance) - { - } - /** - * Get current page URL for layered nav items. + * This method shouldn't be called directly, use the walk() method instead. * - * @param string $taxonomy Taxonomy. - * @return string + * @since 2.5.0 + * + * @param object $element Data object. + * @param array $children_elements List of elements to continue traversing. + * @param int $max_depth Max depth to traverse. + * @param int $depth Depth of current element. + * @param array $args Arguments. + * @param string $output Passed by reference. Used to append additional content. + * @return null Null on failure with no changes to parameters. */ - protected function get_page_base_url($taxonomy) + public function display_element($element, &$children_elements, $max_depth, $depth, $args, &$output) { } + } + /** + * WC_WCCOM_Site_Installer Class + * + * Contains functionalities to install products via WooCommerce.com helper connection. + */ + class WC_WCCOM_Site_Installer + { /** - * Gets the currently selected attributes + * An instance of the WP_Upgrader class to be used for installation. * - * @return array + * @var \WP_Upgrader $wp_upgrader */ - public function get_chosen_attributes() - { - } + private static $wp_upgrader; /** - * Show dropdown layered nav. + * Get WP.org plugin's main file. * - * @param array $terms Terms. - * @param string $taxonomy Taxonomy. - * @param int $depth Depth. - * @return bool Will nav display? + * @since 3.7.0 + * @param string $dir Directory name of the plugin. + * @return bool|string */ - protected function layered_nav_dropdown($terms, $taxonomy, $depth = 0) + public static function get_wporg_plugin_main_file($dir) { } /** - * Show list based layered nav. + * Get plugin info * - * @param array $terms Terms. - * @param string $taxonomy Taxonomy. - * @param int $depth Depth. - * @return bool Will nav display? + * @since 3.9.0 + * @param string $dir Directory name of the plugin. + * @return bool|array */ - protected function layered_nav_list($terms, $taxonomy, $depth = 0) + public static function get_plugin_info($dir) { } /** - * Count products within certain terms, taking the main WP query into consideration. + * Get an instance of WP_Upgrader to use for installing plugins. * - * @param array $term_ids Term IDs. - * @param string $taxonomy Taxonomy. - * @param string $query_type Query type. - * @return array + * @return WP_Upgrader */ - protected function get_filtered_term_product_counts($term_ids, $taxonomy, $query_type = 'and') + public static function get_wp_upgrader() { } } /** - * Brand Thumbnails Widget - * - * Show brand images as thumbnails - * - * Important: For internal use only by the Automattic\WooCommerce\Internal\Brands package. + * WC_WCCOM_Site Class * - * @package WooCommerce\Widgets - * @version 9.4.0 + * Main class for WooCommerce.com connected site. */ - class WC_Widget_Brand_Thumbnails extends \WP_Widget + class WC_WCCOM_Site { + const AUTH_ERROR_FILTER_NAME = 'wccom_auth_error'; /** - * Widget CSS class. - * - * @var string - */ - public $woo_widget_cssclass; - /** - * Widget description. - * - * @var string - */ - public $woo_widget_description; - /** - * Widget id base. + * Load the WCCOM site class. * - * @var string + * @since 3.7.0 */ - public $woo_widget_idbase; + public static function load() + { + } /** - * Widget name. + * Include support files. * - * @var string + * @since 3.7.0 */ - public $woo_widget_name; - /** Constructor */ - public function __construct() + protected static function includes() { } /** - * Echoes the widget content. - * - * @see WP_Widget + * Authenticate WooCommerce.com request. * - * @param array $args Display arguments including 'before_title', 'after_title', - * 'before_widget', and 'after_widget'. - * @param array $instance The settings for the particular instance of the widget. + * @since 3.7.0 + * @param int|false $user_id User ID. + * @return int|false */ - public function widget($args, $instance) + public static function authenticate_wccom($user_id) { } /** - * Update widget instance. + * Get the authorization header. * - * @param array $new_instance The new settings for the particular instance of the widget. - * @param array $old_instance The old settings for the particular instance of the widget. + * On certain systems and configurations, the Authorization header will be + * stripped out by the server or PHP. Typically this is then used to + * generate `PHP_AUTH_USER`/`PHP_AUTH_PASS` but not passed on. We use + * `getallheaders` here to try and grab it out instead. * - * @see WP_Widget->update + * @since 3.7.0 + * @return string Authorization header if set. */ - public function update($new_instance, $old_instance) + protected static function get_authorization_header() { } /** - * Outputs the settings update form. + * Check if this is a request to WCCOM Site REST API. * - * @param array $instance Current settings. + * @since 3.7.0 + * @return bool */ - public function form($instance) + protected static function is_request_to_wccom_site_rest_api() { } - } - /** - * Widget cart class. - */ - class WC_Widget_Cart extends \WC_Widget - { /** - * Constructor. + * Verify WooCommerce.com request from a given body and signature request. + * + * @since 3.7.0 + * @param string $body Request body. + * @param string $signature Request signature found in X-Woo-Signature header. + * @param string $access_token_secret Access token secret for this site. + * @return bool */ - public function __construct() + protected static function verify_wccom_request($body, $signature, $access_token_secret) { } /** - * Output widget. - * - * @see WP_Widget + * Register wccom-site REST namespace. * - * @param array $args Arguments. - * @param array $instance Widget instance. + * @since 3.7.0 + * @param array $namespaces List of registered namespaces. + * @return array Registered namespaces. */ - public function widget($args, $instance) + public static function register_rest_namespace($namespaces) { } } /** - * Widget layered nav filters. + * WC_WCCOM_Site_Installation_Manager class */ - class WC_Widget_Layered_Nav_Filters extends \WC_Widget + class WC_WCCOM_Site_Installation_Manager { + const STEPS = array('get_product_info', 'download_product', 'unpack_product', 'move_product', 'activate_product'); /** - * Constructor. + * The product ID. + * + * @var int */ - public function __construct() - { - } + protected $product_id; /** - * Output widget. + * The idempotency key. * - * @see WP_Widget - * @param array $args Arguments. - * @param array $instance Widget instance. + * @var string */ - public function widget($args, $instance) - { - } - } - /** - * Widget layered nav class. - */ - class WC_Widget_Layered_Nav extends \WC_Widget - { + protected $idempotency_key; /** * Constructor. + * + * @param int $product_id The product ID. + * @param string $idempotency_key The idempotency key. */ - public function __construct() + public function __construct(int $product_id, string $idempotency_key = '') { } /** - * Updates a particular instance of a widget. - * - * @see WP_Widget->update - * - * @param array $new_instance New Instance. - * @param array $old_instance Old Instance. + * Get the installation status. * - * @return array + * @return WC_WCCOM_Site_Installation_State + * @throws Installer_Error If installation status request failed. */ - public function update($new_instance, $old_instance) + public function get_installation_status(): \WC_WCCOM_Site_Installation_State { } /** - * Outputs the settings update form. - * - * @see WP_Widget->form + * Run the installation. * - * @param array $instance Instance. + * @param string $run_until_step The step to run until. + * @return bool + * @throws Installer_Error If installation failed to run. */ - public function form($instance) + public function run_installation(string $run_until_step): bool { } /** - * Init settings after post types are registered. + * Get the next step to run. + * + * @return bool + * @throws WC_REST_WCCOM_Site_Installer_Error If the installation cannot be rest. */ - public function init_settings() + public function reset_installation(): bool { } /** - * Get this widgets taxonomy. + * Check if the installation can be run. * - * @param array $instance Array of instance options. - * @return string + * @param string $run_until_step Run until this step. + * @param WC_WCCOM_Site_Installation_State $state Installation state. + * @return void + * @throws WC_REST_WCCOM_Site_Installer_Error If the installation cannot be run. */ - protected function get_instance_taxonomy($instance) + protected function can_run_installation($run_until_step, $state) { } /** - * Get this widgets query type. + * Get the next step to run. * - * @param array $instance Array of instance options. + * @param WC_WCCOM_Site_Installation_State $state Installation state. * @return string */ - protected function get_instance_query_type($instance) + protected function get_next_step($state): string { } /** - * Get this widgets display type. + * Get the steps to run. * - * @param array $instance Array of instance options. - * @return string + * @param string $start_step The step to start from. + * @param string $end_step The step to end at. + * @return string[] */ - protected function get_instance_display_type($instance) + protected function get_installation_steps(string $start_step, string $end_step) { } /** - * Output widget. - * - * @see WP_Widget + * Run the step. * - * @param array $args Arguments. - * @param array $instance Instance. + * @param string $step_name Step name. + * @param WC_WCCOM_Site_Installation_State $state Installation state. + * @return void + * @throws WC_REST_WCCOM_Site_Installer_Error If the step fails. */ - public function widget($args, $instance) + protected function run_step($step_name, $state) { } + } + /** + * WC_WCCOM_Site_Installation_State_Storage class + */ + class WC_WCCOM_Site_Installation_State_Storage + { /** - * Return the currently viewed taxonomy name. + * Get state from storage. * - * @return string + * @param int $product_id The product ID. + * @return WC_WCCOM_Site_Installation_State|null */ - protected function get_current_taxonomy() + public static function get_state($product_id): ?\WC_WCCOM_Site_Installation_State { } /** - * Return the currently viewed term ID. + * Save state to storage. * - * @return int + * @param WC_WCCOM_Site_Installation_State $state The state to save. + * @return bool */ - protected function get_current_term_id() + public static function save_state(\WC_WCCOM_Site_Installation_State $state): bool { } /** - * Return the currently viewed term slug. + * Delete state from storage. * - * @return int + * @param WC_WCCOM_Site_Installation_State $state The state to delete. + * @return bool */ - protected function get_current_term_slug() + public static function delete_state(\WC_WCCOM_Site_Installation_State $state): bool { } /** - * Show dropdown layered nav. + * Get the storage key for a product ID. * - * @param array $terms Terms. - * @param string $taxonomy Taxonomy. - * @param string $query_type Query Type. - * @return bool Will nav display? + * @param int $product_id The product ID. + * @return string */ - protected function layered_nav_dropdown($terms, $taxonomy, $query_type) + protected static function get_storage_key($product_id): string { } + } + /** + * WC_WCCOM_Site_Installation_State class + */ + class WC_WCCOM_Site_Installation_State + { /** - * Count products within certain terms, taking the main WP query into consideration. + * The product ID. * - * This query allows counts to be generated based on the viewed products, not all products. + * @var string + */ + protected $product_id; + /** + * The idempotency key. * - * @param array $term_ids Term IDs. - * @param string $taxonomy Taxonomy. - * @param string $query_type Query Type. - * @return array + * @var string */ - protected function get_filtered_term_product_counts($term_ids, $taxonomy, $query_type) - { - } + protected $idempotency_key; /** - * Wrapper for WC_Query::get_main_tax_query() to ease unit testing. + * The last step name. * - * @since 4.4.0 - * @return array + * @var string */ - protected function get_main_tax_query() - { - } + protected $last_step_name; /** - * Wrapper for WC_Query::get_main_search_query_sql() to ease unit testing. + * The last step status. * - * @since 4.4.0 - * @return string + * @var string */ - protected function get_main_search_query_sql() - { - } + protected $last_step_status; /** - * Wrapper for WC_Query::get_main_search_queryget_main_meta_query to ease unit testing. + * The last step error. * - * @since 4.4.0 - * @return array + * @var string */ - protected function get_main_meta_query() - { - } + protected $last_step_error; /** - * Show list based layered nav. + * The product type. * - * @param array $terms Terms. - * @param string $taxonomy Taxonomy. - * @param string $query_type Query Type. - * @return bool Will nav display? + * @var string */ - protected function layered_nav_list($terms, $taxonomy, $query_type) - { - } - } - /** - * Widget price filter class. - */ - class WC_Widget_Price_Filter extends \WC_Widget - { + protected $product_type; /** - * Constructor. + * The product name. + * + * @var string */ - public function __construct() - { - } + protected $product_name; /** - * Output widget. + * The product slug. * - * @see WP_Widget + * @var string + */ + protected $download_url; + /** + * The path to the downloaded file. * - * @param array $args Arguments. - * @param array $instance Widget instance. + * @var string */ - public function widget($args, $instance) - { - } + protected $download_path; /** - * Get filtered min price for current products. + * The path to the unpacked file. * - * @return int + * @var string */ - protected function get_filtered_price() - { - } - } - /** - * Product categories widget class. - * - * @extends WC_Widget - */ - class WC_Widget_Product_Categories extends \WC_Widget - { + protected $unpacked_path; /** - * Category ancestors. + * The path to the installed file. + * + * @var string + */ + protected $installed_path; + /** + * The plugin info for the already installed plugin. * * @var array */ - public $cat_ancestors; + protected $already_installed_plugin_info; /** - * Current Category. + * The timestamp of the installation start. * - * @var bool + * @var int */ - public $current_cat; + protected $started_date; + const STEP_STATUS_IN_PROGRESS = 'in-progress'; + const STEP_STATUS_FAILED = 'failed'; + const STEP_STATUS_COMPLETED = 'completed'; /** * Constructor. + * + * @param string $product_id The product ID. */ - public function __construct() + protected function __construct($product_id) { } /** - * Output widget. + * Initiate an existing installation state. * - * @see WP_Widget - * @param array $args Widget arguments. - * @param array $instance Widget instance. - */ - public function widget($args, $instance) + * @param int $product_id The product ID. + * @param string $idempotency_key The idempotency key. + * @param string $last_step_name The last step name. + * @param string $last_step_status The last step status. + * @param string $last_step_error The last step error. + * @param int $started_date The timestamp of the installation start. + * @return WC_WCCOM_Site_Installation_State The instance. + */ + public static function initiate_existing($product_id, $idempotency_key, $last_step_name, $last_step_status, $last_step_error, $started_date) { } - } - /** - * Widget product search class. - */ - class WC_Widget_Product_Search extends \WC_Widget - { /** - * Constructor. + * Initiate a new installation state. + * + * @param init $product_id The product ID. + * @param string $idempotency_key The idempotency key. + * @return WC_WCCOM_Site_Installation_State The instance. */ - public function __construct() + public static function initiate_new($product_id, $idempotency_key) { } /** - * Output widget. + * Get the product ID. * - * @see WP_Widget + * @return string + */ + public function get_product_id() + { + } + /** + * Get the idempotency key. * - * @param array $args Arguments. - * @param array $instance Widget instance. + * @return string */ - public function widget($args, $instance) + public function get_idempotency_key() { } - } - /** - * Widget product tag cloud - */ - class WC_Widget_Product_Tag_Cloud extends \WC_Widget - { /** - * Constructor. + * Get the timestamp of the installation start. + * + * @return int */ - public function __construct() + public function get_last_step_name() { } /** - * Output widget. + * Get the last step status. * - * @see WP_Widget + * @return string + */ + public function get_last_step_status() + { + } + /** + * Get the last step error. * - * @param array $args Arguments. - * @param array $instance Widget instance. + * @return int */ - public function widget($args, $instance) + public function get_last_step_error() { } /** - * Return the taxonomy being displayed. + * Initiate a step. + * + * @param string $step_name Step name. + * @return void + */ + public function initiate_step($step_name) + { + } + /** + * Capture a successful installation of a step. + * + * @param string $step_name The step name. + */ + public function complete_step($step_name) + { + } + /** + * Capture an installation failure. + * + * @param string $step_name The step name. + * @param string $error_code The error code. + */ + public function capture_failure($step_name, $error_code) + { + } + /** + * Get the product type. * - * @param object $instance Widget instance. * @return string */ - public function get_current_taxonomy($instance) + public function get_product_type() { } /** - * Returns topic count text. + * Set the product type. + * + * @param string $product_type The product type. + */ + public function set_product_type($product_type) + { + } + /** + * Get the product name. * - * @since 3.4.0 - * @param int $count Count text. * @return string */ - public function topic_count_text($count) + public function get_product_name() { } - // Ignore whole block to avoid warnings about PSR2.Methods.MethodDeclaration.Underscore violation. - // @codingStandardsIgnoreStart /** - * Return the taxonomy being displayed. + * Set the product name. + * + * @param string $product_name The product name. + */ + public function set_product_name($product_name) + { + } + /** + * Get the download URL. * - * @deprecated 3.4.0 - * @param object $instance Widget instance. * @return string */ - public function _get_current_taxonomy($instance) + public function get_download_url() { } /** - * Returns topic count text. + * Set the download URL. + * + * @param string $download_url The download URL. + */ + public function set_download_url($download_url) + { + } + /** + * Get the path to the downloaded file. * - * @deprecated 3.4.0 - * @since 2.6.0 - * @param int $count Count text. * @return string */ - public function _topic_count_text($count) + public function get_download_path() { } - // @codingStandardsIgnoreEnd + /** + * Set the path to the downloaded file. + * + * @param string $download_path The path to the downloaded file. + */ + public function set_download_path($download_path) + { + } + /** + * Get the path to the unpacked file. + * + * @return string + */ + public function get_unpacked_path() + { + } + /** + * Set the path to the unpacked file. + * + * @param string $unpacked_path The path to the unpacked file. + */ + public function set_unpacked_path($unpacked_path) + { + } + /** + * Get the path to the installed file. + * + * @return string + */ + public function get_installed_path() + { + } + /** + * Set the path to the installed file. + * + * @param string $installed_path The path to the installed file. + */ + public function set_installed_path($installed_path) + { + } + /** + * Get the plugin info for the already installed plugin. + * + * @return array + */ + public function get_already_installed_plugin_info() + { + } + /** + * Set the plugin info for the already installed plugin. + * + * @param array $plugin_info The plugin info. + */ + public function set_already_installed_plugin_info($plugin_info) + { + } + /** + * Get the timestamp of the installation start. + * + * @return int + */ + public function get_started_date() + { + } + } + interface WC_WCCOM_Site_Installation_Step + { + /** + * Constructor. + * + * @param array $state The current installation state. + */ + public function __construct($state); + /** + * Run the step installation process. + */ + public function run(); } /** - * Widget products. + * WC_WCCOM_Site_Installation_Step_Activate_Product Class */ - class WC_Widget_Products extends \WC_Widget + class WC_WCCOM_Site_Installation_Step_Activate_Product implements \WC_WCCOM_Site_Installation_Step { + /** + * The current installation state. + * + * @var WC_WCCOM_Site_Installation_State + */ + protected $state; /** * Constructor. + * + * @param array $state The current installation state. */ - public function __construct() + public function __construct($state) { } /** - * Query the products and return them. + * Run the step installation process. + */ + public function run() + { + } + /** + * Activate plugin. * - * @param array $args Arguments. - * @param array $instance Widget instance. + * @param int $product_id Product ID. + * @return void + * @throws WC_REST_WCCOM_Site_Installer_Error If plugin activation failed. + */ + private function activate_plugin($product_id) + { + } + /** + * Activate theme. * - * @return WP_Query + * @param int $product_id Product ID. + * @return void + * @throws WC_REST_WCCOM_Site_Installer_Error If theme activation failed. */ - public function get_products($args, $instance) + private function activate_theme($product_id) { } /** - * Output widget. + * Get WP.org product directory name. * - * @param array $args Arguments. - * @param array $instance Widget instance. + * @return string|false + */ + private function get_wporg_product_dir_name() + { + } + } + /** + * WC_WCCOM_Site_Installation_Step_Download_Product class + */ + class WC_WCCOM_Site_Installation_Step_Download_Product implements \WC_WCCOM_Site_Installation_Step + { + /** + * The current installation state. * - * @see WP_Widget + * @var WC_WCCOM_Site_Installation_State */ - public function widget($args, $instance) + protected $state; + /** + * Constructor. + * + * @param array $state The current installation state. + */ + public function __construct($state) + { + } + /** + * Run the step installation process. + * + * @throws Installer_Error Installer Error. + */ + public function run() { } } /** - * Widget rating filter class. + * WC_WCCOM_Site_Installation_Step_Get_Product_Info class */ - class WC_Widget_Rating_Filter extends \WC_Widget + class WC_WCCOM_Site_Installation_Step_Get_Product_Info implements \WC_WCCOM_Site_Installation_Step { + /** + * The current installation state. + * + * @var WC_WCCOM_Site_Installation_State + */ + protected $state; /** * Constructor. + * + * @param array $state The current installation state. */ - public function __construct() + public function __construct($state) { } /** - * Count products after other filters have occurred by adjusting the main query. + * Run the step installation process. * - * @param int $rating Rating. - * @return int + * @throws Installer_Error Installer Error. + * @return array */ - protected function get_filtered_product_count($rating) + public function run() { } /** - * Widget function. + * Get download URL for wporg product. * - * @see WP_Widget - * @param array $args Arguments. - * @param array $instance Widget instance. + * @param array $data Product data. + * + * @return string|null + * @throws Installer_Error Installer Error. */ - public function widget($args, $instance) + protected function get_wporg_download_url($data) + { + } + /** + * Get download URL for wccom product. + * + * @param int $product_id Product ID. + * + * @return string + * @throws Installer_Error Installer Error. + */ + protected function get_wccom_download_url($product_id) { } } /** - * Widget recent reviews class. + * WC_WCCOM_Site_Installation_Step_Move_Product class */ - class WC_Widget_Recent_Reviews extends \WC_Widget + class WC_WCCOM_Site_Installation_Step_Move_Product implements \WC_WCCOM_Site_Installation_Step { + /** + * The current installation state. + * + * @var WC_WCCOM_Site_Installation_State + */ + protected $state; /** * Constructor. + * + * @param array $state The current installation state. */ - public function __construct() + public function __construct($state) { } /** - * Output widget. + * Run the step installation process. + */ + public function run() + { + } + /** + * Connect to wccom if installing a theme * - * @see WP_Widget - * @param array $args Arguments. - * @param array $instance Widget instance. + * @return void */ - public function widget($args, $instance) + protected function maybe_connect_theme() { } } /** - * Widget recently viewed. + * WC_WCCOM_Site_Installation_Step_Unpack_Product class */ - class WC_Widget_Recently_Viewed extends \WC_Widget + class WC_WCCOM_Site_Installation_Step_Unpack_Product implements \WC_WCCOM_Site_Installation_Step { + /** + * The current installation state. + * + * @var WC_WCCOM_Site_Installation_State + */ + protected $state; /** * Constructor. + * + * @param array $state The current installation state. */ - public function __construct() + public function __construct($state) { } /** - * Output widget. + * Run the step installation process. * - * @see WP_Widget - * @param array $args Arguments. - * @param array $instance Widget instance. + * @return WC_WCCOM_Site_Installation_State + * @throws WC_REST_WCCOM_Site_Installer_Error If the package unpacked path is not returned. */ - public function widget($args, $instance) + public function run() { } } /** - * Widget top rated products class. + * WCCOM Site Installer Error Codes Class + * + * Stores data for errors, returned by installer API. */ - class WC_Widget_Top_Rated_Products extends \WC_Widget + class WC_REST_WCCOM_Site_Installer_Error_Codes + { + const NOT_AUTHENTICATED = 'not_authenticated'; + const NO_ACCESS_TOKEN = 'no_access_token'; + const NO_SIGNATURE = 'no_signature'; + const SITE_NOT_CONNECTED = 'site_not_connnected'; + const INVALID_TOKEN = 'invalid_token'; + const REQUEST_VERIFICATION_FAILED = 'request_verification_failed'; + const USER_NOT_FOUND = 'user_not_found'; + const NO_PERMISSION = 'forbidden'; + const IDEMPOTENCY_KEY_MISMATCH = 'idempotency_key_mismatch'; + const NO_INITIATED_INSTALLATION_FOUND = 'no_initiated_installation_found'; + const ALL_INSTALLATION_STEPS_RUN = 'all_installation_steps_run'; + const REQUESTED_STEP_ALREADY_RUN = 'requested_step_already_run'; + const PLUGIN_ALREADY_INSTALLED = 'plugin_already_installed'; + const INSTALLATION_ALREADY_RUNNING = 'installation_already_running'; + const INSTALLATION_FAILED = 'installation_failed'; + const FILESYSTEM_REQUIREMENTS_NOT_MET = 'filesystem_requirements_not_met'; + const FAILED_GETTING_PRODUCT_INFO = 'product_info_failed'; + const INVALID_PRODUCT_INFO_RESPONSE = 'invalid_product_info_response'; + const WCCOM_PRODUCT_MISSING_SUBSCRIPTION = 'wccom_product_missing_subscription'; + const WCCOM_PRODUCT_MISSING_PACKAGE = 'wccom_product_missing_package'; + const WPORG_PRODUCT_MISSING_DOWNLOAD_LINK = 'wporg_product_missing_download_link'; + const MISSING_DOWNLOAD_PATH = 'missing_download_path'; + const MISSING_UNPACKED_PATH = 'missing_unpacked_path'; + const UNKNOWN_FILENAME = 'unknown_filename'; + const PLUGIN_ACTIVATION_ERROR = 'plugin_activation_error'; + const UNEXPECTED_ERROR = 'unexpected_error'; + const FAILED_TO_RESET_INSTALLATION_STATE = 'failed_to_reset_installation_state'; + const ERROR_MESSAGES = array(self::NOT_AUTHENTICATED => 'Authentication required', self::NO_ACCESS_TOKEN => 'No access token provided', self::NO_SIGNATURE => 'No signature provided', self::SITE_NOT_CONNECTED => 'Site not connected to WooCommerce.com', self::INVALID_TOKEN => 'Invalid access token provided', self::REQUEST_VERIFICATION_FAILED => 'Request verification by signature failed', self::USER_NOT_FOUND => 'Token owning user not found', self::NO_PERMISSION => 'You do not have permission to install plugin or theme', self::IDEMPOTENCY_KEY_MISMATCH => 'Idempotency key mismatch', self::NO_INITIATED_INSTALLATION_FOUND => 'No initiated installation for the product found', self::ALL_INSTALLATION_STEPS_RUN => 'All installation steps have been run', self::REQUESTED_STEP_ALREADY_RUN => 'Requested step has already been run', self::PLUGIN_ALREADY_INSTALLED => 'The plugin has already been installed', self::INSTALLATION_ALREADY_RUNNING => 'The installation of the plugin is already running', self::INSTALLATION_FAILED => 'The installation of the plugin failed', self::FILESYSTEM_REQUIREMENTS_NOT_MET => 'The filesystem requirements are not met', self::FAILED_GETTING_PRODUCT_INFO => 'Failed to retrieve product info from WooCommerce.com', self::INVALID_PRODUCT_INFO_RESPONSE => 'Invalid product info response from WooCommerce.com', self::WCCOM_PRODUCT_MISSING_SUBSCRIPTION => 'Product subscription is missing', self::WCCOM_PRODUCT_MISSING_PACKAGE => 'Could not find product package', self::MISSING_DOWNLOAD_PATH => 'Download path is missing', self::MISSING_UNPACKED_PATH => 'Unpacked path is missing', self::UNKNOWN_FILENAME => 'Unknown product filename', self::PLUGIN_ACTIVATION_ERROR => 'Plugin activation error', self::UNEXPECTED_ERROR => 'Unexpected error', self::FAILED_TO_RESET_INSTALLATION_STATE => 'Failed to reset installation state'); + const HTTP_CODES = array(self::NOT_AUTHENTICATED => 401, self::NO_ACCESS_TOKEN => 400, self::NO_SIGNATURE => 400, self::SITE_NOT_CONNECTED => 401, self::INVALID_TOKEN => 401, self::REQUEST_VERIFICATION_FAILED => 400, self::USER_NOT_FOUND => 401, self::NO_PERMISSION => 403, self::IDEMPOTENCY_KEY_MISMATCH => 400, self::NO_INITIATED_INSTALLATION_FOUND => 400, self::ALL_INSTALLATION_STEPS_RUN => 400, self::REQUESTED_STEP_ALREADY_RUN => 400, self::UNEXPECTED_ERROR => 500); + } + /** + * WCCOM Site Installer Error Class + */ + class WC_REST_WCCOM_Site_Installer_Error extends \Exception { /** - * Constructor. + * Constructor for the Installer Error class. + * + * @param string $error_code Error code. + * @param string $error_message Error message. + * @param int $http_code HTTP status code. + */ + public function __construct($error_code, $error_message = \null, $http_code = \null) + { + } + /** + * Get the error code. + */ + public function get_error_code() + { + } + /** + * Get the error message. */ + public function get_error_message() + { + } + /** + * Get the HTTP status code. + */ + public function get_http_code() + { + } + } + /** + * Brand Description Widget + * + * When viewing a brand archive, show the current brands description + image + * + * Important: For internal use only by the Automattic\WooCommerce\Internal\Brands package. + * + * @package WooCommerce\Widgets + * @version 9.4.0 + */ + class WC_Widget_Brand_Description extends \WP_Widget + { + /** + * Widget class. + * + * @var string + */ + public $woo_widget_cssclass; + /** + * Widget description. + * + * @var string + */ + public $woo_widget_description; + /** + * Widget idbase. + * + * @var string + */ + public $woo_widget_idbase; + /** + * Widget name. + * + * @var string + */ + public $woo_widget_name; + /** Constructor */ public function __construct() { } /** - * Output widget. + * Echoes the widget content. * * @see WP_Widget - * @param array $args Arguments. - * @param array $instance Widget instance. + * + * @param array $args Display arguments including 'before_title', 'after_title', + * 'before_widget', and 'after_widget'. + * @param array $instance The settings for the particular instance of the widget. */ public function widget($args, $instance) { } - } -} -namespace Automattic\WooCommerce\Vendor\Detection { - /** - * Auto-generated isXXXX() magic methods. - * php export/dump_magic_methods.php - * - * @method bool isiPhone() - * @method bool isBlackBerry() + /** + * Updates widget instance. + * + * @see WP_Widget->update + * + * @param array $new_instance New widget instance. + * @param array $old_instance Old widget instance. + */ + public function update($new_instance, $old_instance) + { + } + /** + * Outputs the settings update form. + * + * @param array $instance Current settings. + */ + public function form($instance) + { + } + } + /** + * Layered Navigation Widget for brands WC 2.6 version + * + * Important: For internal use only by the Automattic\WooCommerce\Internal\Brands package. + * + * @package WooCommerce\Widgets + * @version 9.4.0 + * @extends WP_Widget + */ + class WC_Widget_Brand_Nav extends \WC_Widget + { + /** + * Constructor + * + * @return void + */ + public function __construct() + { + } + /** + * Filter out all categories and not display them + * + * @param array $cat_args Category arguments. + */ + public function filter_out_cats($cat_args) + { + } + /** + * Return the currently viewed taxonomy name. + * + * @return string + */ + protected function get_current_taxonomy() + { + } + /** + * Return the currently viewed term ID. + * + * @return int + */ + protected function get_current_term_id() + { + } + /** + * Return the currently viewed term slug. + * + * @return int + */ + protected function get_current_term_slug() + { + } + /** + * Widget function. + * + * @see WP_Widget + * + * @param array $args Arguments. + * @param array $instance Widget instance. + * @return void + */ + public function widget($args, $instance) + { + } + /** + * Update function. + * + * @see WP_Widget->update + * + * @param array $new_instance The new settings for the particular instance of the widget. + * @param array $old_instance The old settings for the particular instance of the widget. + * @return array + */ + public function update($new_instance, $old_instance) + { + } + /** + * Form function. + * + * @see WP_Widget->form + * + * @param array $instance Widget instance. + * @return void + */ + public function form($instance) + { + } + /** + * Get current page URL for layered nav items. + * + * @param string $taxonomy Taxonomy. + * @return string + */ + protected function get_page_base_url($taxonomy) + { + } + /** + * Gets the currently selected attributes + * + * @return array + */ + public function get_chosen_attributes() + { + } + /** + * Show dropdown layered nav. + * + * @param array $terms Terms. + * @param string $taxonomy Taxonomy. + * @param int $depth Depth. + * @return bool Will nav display? + */ + protected function layered_nav_dropdown($terms, $taxonomy, $depth = 0) + { + } + /** + * Show list based layered nav. + * + * @param array $terms Terms. + * @param string $taxonomy Taxonomy. + * @param int $depth Depth. + * @return bool Will nav display? + */ + protected function layered_nav_list($terms, $taxonomy, $depth = 0) + { + } + /** + * Count products within certain terms, taking the main WP query into consideration. + * + * @param array $term_ids Term IDs. + * @param string $taxonomy Taxonomy. + * @param string $query_type Query type. + * @return array + */ + protected function get_filtered_term_product_counts($term_ids, $taxonomy, $query_type = 'and') + { + } + } + /** + * Brand Thumbnails Widget + * + * Show brand images as thumbnails + * + * Important: For internal use only by the Automattic\WooCommerce\Internal\Brands package. + * + * @package WooCommerce\Widgets + * @version 9.4.0 + */ + class WC_Widget_Brand_Thumbnails extends \WP_Widget + { + /** + * Widget CSS class. + * + * @var string + */ + public $woo_widget_cssclass; + /** + * Widget description. + * + * @var string + */ + public $woo_widget_description; + /** + * Widget id base. + * + * @var string + */ + public $woo_widget_idbase; + /** + * Widget name. + * + * @var string + */ + public $woo_widget_name; + /** Constructor */ + public function __construct() + { + } + /** + * Echoes the widget content. + * + * @see WP_Widget + * + * @param array $args Display arguments including 'before_title', 'after_title', + * 'before_widget', and 'after_widget'. + * @param array $instance The settings for the particular instance of the widget. + */ + public function widget($args, $instance) + { + } + /** + * Update widget instance. + * + * @param array $new_instance The new settings for the particular instance of the widget. + * @param array $old_instance The old settings for the particular instance of the widget. + * + * @see WP_Widget->update + */ + public function update($new_instance, $old_instance) + { + } + /** + * Outputs the settings update form. + * + * @param array $instance Current settings. + */ + public function form($instance) + { + } + } + /** + * Widget cart class. + */ + class WC_Widget_Cart extends \WC_Widget + { + /** + * Constructor. + */ + public function __construct() + { + } + /** + * Output widget. + * + * @see WP_Widget + * + * @param array $args Arguments. + * @param array $instance Widget instance. + */ + public function widget($args, $instance) + { + } + } + /** + * Widget layered nav filters. + */ + class WC_Widget_Layered_Nav_Filters extends \WC_Widget + { + /** + * Constructor. + */ + public function __construct() + { + } + /** + * Output widget. + * + * @see WP_Widget + * @param array $args Arguments. + * @param array $instance Widget instance. + */ + public function widget($args, $instance) + { + } + } + /** + * Widget layered nav class. + */ + class WC_Widget_Layered_Nav extends \WC_Widget + { + /** + * Constructor. + */ + public function __construct() + { + } + /** + * Updates a particular instance of a widget. + * + * @see WP_Widget->update + * + * @param array $new_instance New Instance. + * @param array $old_instance Old Instance. + * + * @return array + */ + public function update($new_instance, $old_instance) + { + } + /** + * Outputs the settings update form. + * + * @see WP_Widget->form + * + * @param array $instance Instance. + */ + public function form($instance) + { + } + /** + * Init settings after post types are registered. + */ + public function init_settings() + { + } + /** + * Get this widgets taxonomy. + * + * @param array $instance Array of instance options. + * @return string + */ + protected function get_instance_taxonomy($instance) + { + } + /** + * Get this widgets query type. + * + * @param array $instance Array of instance options. + * @return string + */ + protected function get_instance_query_type($instance) + { + } + /** + * Get this widgets display type. + * + * @param array $instance Array of instance options. + * @return string + */ + protected function get_instance_display_type($instance) + { + } + /** + * Output widget. + * + * @see WP_Widget + * + * @param array $args Arguments. + * @param array $instance Instance. + */ + public function widget($args, $instance) + { + } + /** + * Return the currently viewed taxonomy name. + * + * @return string + */ + protected function get_current_taxonomy() + { + } + /** + * Return the currently viewed term ID. + * + * @return int + */ + protected function get_current_term_id() + { + } + /** + * Return the currently viewed term slug. + * + * @return int + */ + protected function get_current_term_slug() + { + } + /** + * Show dropdown layered nav. + * + * @param array $terms Terms. + * @param string $taxonomy Taxonomy. + * @param string $query_type Query Type. + * @return bool Will nav display? + */ + protected function layered_nav_dropdown($terms, $taxonomy, $query_type) + { + } + /** + * Count products within certain terms, taking the main WP query into consideration. + * + * This query allows counts to be generated based on the viewed products, not all products. + * + * @param array $term_ids Term IDs. + * @param string $taxonomy Taxonomy. + * @param string $query_type Query Type. + * @return array + */ + protected function get_filtered_term_product_counts($term_ids, $taxonomy, $query_type) + { + } + /** + * Wrapper for WC_Query::get_main_tax_query() to ease unit testing. + * + * @since 4.4.0 + * @return array + */ + protected function get_main_tax_query() + { + } + /** + * Wrapper for WC_Query::get_main_search_query_sql() to ease unit testing. + * + * @since 4.4.0 + * @return string + */ + protected function get_main_search_query_sql() + { + } + /** + * Wrapper for WC_Query::get_main_search_queryget_main_meta_query to ease unit testing. + * + * @since 4.4.0 + * @return array + */ + protected function get_main_meta_query() + { + } + /** + * Show list based layered nav. + * + * @param array $terms Terms. + * @param string $taxonomy Taxonomy. + * @param string $query_type Query Type. + * @return bool Will nav display? + */ + protected function layered_nav_list($terms, $taxonomy, $query_type) + { + } + } + /** + * Widget price filter class. + */ + class WC_Widget_Price_Filter extends \WC_Widget + { + /** + * Constructor. + */ + public function __construct() + { + } + /** + * Output widget. + * + * @see WP_Widget + * + * @param array $args Arguments. + * @param array $instance Widget instance. + */ + public function widget($args, $instance) + { + } + /** + * Get filtered min price for current products. + * + * @return int + */ + protected function get_filtered_price() + { + } + } + /** + * Product categories widget class. + * + * @extends WC_Widget + */ + class WC_Widget_Product_Categories extends \WC_Widget + { + /** + * Category ancestors. + * + * @var array + */ + public $cat_ancestors; + /** + * Current Category. + * + * @var bool + */ + public $current_cat; + /** + * Constructor. + */ + public function __construct() + { + } + /** + * Output widget. + * + * @see WP_Widget + * @param array $args Widget arguments. + * @param array $instance Widget instance. + */ + public function widget($args, $instance) + { + } + } + /** + * Widget product search class. + */ + class WC_Widget_Product_Search extends \WC_Widget + { + /** + * Constructor. + */ + public function __construct() + { + } + /** + * Output widget. + * + * @see WP_Widget + * + * @param array $args Arguments. + * @param array $instance Widget instance. + */ + public function widget($args, $instance) + { + } + } + /** + * Widget product tag cloud + */ + class WC_Widget_Product_Tag_Cloud extends \WC_Widget + { + /** + * Constructor. + */ + public function __construct() + { + } + /** + * Output widget. + * + * @see WP_Widget + * + * @param array $args Arguments. + * @param array $instance Widget instance. + */ + public function widget($args, $instance) + { + } + /** + * Return the taxonomy being displayed. + * + * @param object $instance Widget instance. + * @return string + */ + public function get_current_taxonomy($instance) + { + } + /** + * Returns topic count text. + * + * @since 3.4.0 + * @param int $count Count text. + * @return string + */ + public function topic_count_text($count) + { + } + // Ignore whole block to avoid warnings about PSR2.Methods.MethodDeclaration.Underscore violation. + // @codingStandardsIgnoreStart + /** + * Return the taxonomy being displayed. + * + * @deprecated 3.4.0 + * @param object $instance Widget instance. + * @return string + */ + public function _get_current_taxonomy($instance) + { + } + /** + * Returns topic count text. + * + * @deprecated 3.4.0 + * @since 2.6.0 + * @param int $count Count text. + * @return string + */ + public function _topic_count_text($count) + { + } + // @codingStandardsIgnoreEnd + } + /** + * Widget products. + */ + class WC_Widget_Products extends \WC_Widget + { + /** + * Constructor. + */ + public function __construct() + { + } + /** + * Query the products and return them. + * + * @param array $args Arguments. + * @param array $instance Widget instance. + * + * @return WP_Query + */ + public function get_products($args, $instance) + { + } + /** + * Output widget. + * + * @param array $args Arguments. + * @param array $instance Widget instance. + * + * @see WP_Widget + */ + public function widget($args, $instance) + { + } + } + /** + * Widget rating filter class. + */ + class WC_Widget_Rating_Filter extends \WC_Widget + { + /** + * Constructor. + */ + public function __construct() + { + } + /** + * Count products after other filters have occurred by adjusting the main query. + * + * @param int $rating Rating. + * @return int + */ + protected function get_filtered_product_count($rating) + { + } + /** + * Widget function. + * + * @see WP_Widget + * @param array $args Arguments. + * @param array $instance Widget instance. + */ + public function widget($args, $instance) + { + } + } + /** + * Widget recent reviews class. + */ + class WC_Widget_Recent_Reviews extends \WC_Widget + { + /** + * Constructor. + */ + public function __construct() + { + } + /** + * Output widget. + * + * @see WP_Widget + * @param array $args Arguments. + * @param array $instance Widget instance. + */ + public function widget($args, $instance) + { + } + } + /** + * Widget recently viewed. + */ + class WC_Widget_Recently_Viewed extends \WC_Widget + { + /** + * Constructor. + */ + public function __construct() + { + } + /** + * Output widget. + * + * @see WP_Widget + * @param array $args Arguments. + * @param array $instance Widget instance. + */ + public function widget($args, $instance) + { + } + } + /** + * Widget top rated products class. + */ + class WC_Widget_Top_Rated_Products extends \WC_Widget + { + /** + * Constructor. + */ + public function __construct() + { + } + /** + * Output widget. + * + * @see WP_Widget + * @param array $args Arguments. + * @param array $instance Widget instance. + */ + public function widget($args, $instance) + { + } + } +} +namespace Automattic\WooCommerce\Vendor\Detection { + /** + * Auto-generated isXXXX() magic methods. + * php export/dump_magic_methods.php + * + * @method bool isiPhone() + * @method bool isBlackBerry() * @method bool isPixel() * @method bool isHTC() * @method bool isNexus() @@ -67941,15 +70070,6 @@ public function install_theme($request) public function activate_theme($request) { } - /** - * Get recommended themes. - * - * @param WP_REST_Request $request Full details about the request. - * @return WP_Error|array Theme activation status. - */ - public function get_recommended_themes($request) - { - } /** * Get the schema, conforming to JSON Schema. * @@ -67958,14 +70078,6 @@ public function get_recommended_themes($request) public function get_item_schema() { } - /** - * Get the recommended themes schema, conforming to JSON Schema. - * - * @return array - */ - public function get_recommended_item_schema() - { - } } /** * Options Controller. @@ -72942,9 +75054,9 @@ class DataStore extends \Automattic\WooCommerce\Admin\API\Reports\DataStore impl { use \Automattic\WooCommerce\Internal\Traits\OrderAttributionMeta; /** - * The transient name. + * The cache key for order statuses. */ - const ORDERS_STATUSES_ALL_TRANSIENT = 'woocommerce_analytics_orders_statuses_all'; + const ORDERS_STATUSES_ALL_CACHE_KEY = 'woocommerce_analytics_orders_statuses_all'; /** * Dynamically sets the date column name based on configuration * @@ -73111,7 +75223,7 @@ protected function get_order_attributions_by_order_ids($order_ids) /** * Get all statuses that have been synced. * - * @return array Unique order statuses. + * @return string[] Unique order statuses. */ public static function get_all_statuses() { @@ -73121,6 +75233,17 @@ public static function get_all_statuses() * * @internal * @param int $order_id Order ID. + * @return void + */ + public static function maybe_update_order_statuses_cache($order_id) + { + } + /** + * Ensure the order status will present in `get_all_statuses` call result. + * + * @deprecated 10.3.0 Use maybe_update_order_statuses_cache(). + * @param int $order_id Order ID. + * @return void */ public static function maybe_update_order_statuses_transient($order_id) { @@ -88399,6 +90522,22 @@ private function get_block_asset_resource_hints($filename = '') private function get_script_dependency_src_array(array $dependencies) { } + /** + * Recursively gather all unique script dependency handles from a starting list. + * + * Traverses the dependency graph for each input handle, collecting any found handles + * and their nested dependencies in the provided array. Used internally to build a + * complete, deduplicated set of handles for further processing (e.g., mapping to src URLs). + * + * @param array $dependencies Array of initial script handles to process. + * @param \WP_Scripts $wp_scripts WP_Scripts instance containing all registered scripts. + * @param array $found_dependencies Reference to array in which discovered handles are stored. + * + * @return void + */ + private function gather_script_dependency_handles(array $dependencies, \WP_Scripts $wp_scripts, &$found_dependencies = array()) + { + } /** * Returns an absolute url to relative links for WordPress core scripts. * @@ -89542,7 +91681,7 @@ class ActiveFilters extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBl protected $block_name = 'active-filters'; } /** - * CatalogSorting class. + * AddToCartForm class. */ class AddToCartForm extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { @@ -89586,9 +91725,9 @@ protected function enqueue_data(array $attributes = []) /** * Add increment and decrement buttons to the quantity input field. * - * @param string $product_html add-to-cart form HTML. + * @param string $product_html Add to Cart form HTML. * @param string $product_name Product name. - * @return stringa add-to-cart form HTML with increment and decrement buttons. + * @return string Add to Cart form HTML with increment and decrement buttons. */ private function add_steppers($product_html, $product_name) { @@ -89677,6 +91816,15 @@ protected function get_template_part_ids() public function set_is_descendant_of_add_to_cart_with_options_context($context, $block) { } + /** + * Check if HTML content has form elements. + * + * @param string $html_content The HTML content. + * @return bool True if the HTML content has form elements, false otherwise. + */ + public function has_form_elements($html_content) + { + } /** * Check if a child product is purchasable. * @@ -89932,15 +92080,16 @@ public static function add_quantity_stepper_classes($quantity_html) { } /** - * Make the quantity input interactive by wrapping it with the necessary data attribute and adding an input event listener. + * Make the quantity input interactive by wrapping it with the necessary data attribute and adding a blur event listener. * * @param string $quantity_html The quantity HTML. - * @param string $wrapper_attributes Optional wrapper attributes. + * @param array $wrapper_attributes Optional wrapper attributes. + * @param array $input_attributes Optional input attributes. * @param int|null $child_product_id Optional child product ID. * * @return string The quantity HTML with interactive wrapper. */ - public static function make_quantity_input_interactive($quantity_html, $wrapper_attributes = '', $child_product_id = null) + public static function make_quantity_input_interactive($quantity_html, $wrapper_attributes = array(), $input_attributes = array(), $child_product_id = null) { } /** @@ -89991,6 +92140,31 @@ public static function get_product_quantity_constraints($product) { } } + /** + * VariationDescription class. + */ + class VariationDescription extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + { + use \Automattic\WooCommerce\Blocks\BlockTypes\EnableBlockJsonAssetsTrait; + /** + * Block name. + * + * @var string + */ + protected $block_name = 'add-to-cart-with-options-variation-description'; + /** + * Render the block. + * + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * + * @return string Rendered block output. + */ + protected function render($attributes, $content, $block) + { + } + } /** * Block type for variation selector in add to cart with options. */ @@ -90104,15 +92278,6 @@ class VariationSelectorAttributeOptions extends \Automattic\WooCommerce\Blocks\B * @var string */ protected $block_name = 'add-to-cart-with-options-variation-selector-attribute-options'; - /** - * Get the block's attributes. - * - * @param array $attributes Block attributes. Default empty array. - * @return array Block attributes merged with defaults. - */ - private function parse_attributes($attributes) - { - } /** * Render the block. * @@ -90137,10 +92302,11 @@ public static function get_normalized_attributes($attributes, $default_attribute /** * Get the default selected attribute. * - * @param array $attribute_terms The attribute's. + * @param string $attribute_slug The attribute's slug. + * @param array $attribute_terms The attribute's terms. * @return string|null The default selected attribute. */ - protected function get_default_selected_attribute($attribute_terms) + protected function get_default_selected_attribute($attribute_slug, $attribute_terms) { } /** @@ -90273,46 +92439,474 @@ protected function get_block_type_style() /** * AttributeFilter class. */ - class AttributeFilter extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class AttributeFilter extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + { + /** + * Block name. + * + * @var string + */ + protected $block_name = 'attribute-filter'; + const FILTER_QUERY_VAR_PREFIX = 'filter_'; + const QUERY_TYPE_QUERY_VAR_PREFIX = 'query_type_'; + /** + * Extra data passed through from server to client for block. + * + * @param array $attributes Any attributes that currently are available from the block. + * Note, this will be empty in the editor context when the block is + * not in the post content on editor load. + */ + protected function enqueue_data(array $attributes = []) + { + } + /** + * Get the frontend style handle for this block type. + * + * @return string[] + */ + protected function get_block_type_style() + { + } + } + /** + * Breadcrumbs class. + */ + class Breadcrumbs extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + { + /** + * Block name. + * + * @var string + */ + protected $block_name = 'breadcrumbs'; + /** + * Render the block. + * + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * + * @return string | void Rendered block output. + */ + protected function render($attributes, $content, $block) + { + } + /** + * Get the frontend script handle for this block type. + * + * @param string $key Data to get, or default to everything. + */ + protected function get_block_type_script($key = null) + { + } + /** + * Gets font size classes and styles for the breadcrumbs block. + * + * Note: This implementation intentionally avoids using StyleAttributesUtils::get_font_size_class_and_style() + * and get_block_wrapper_attributes() to ensure style attributes take precedence over the class attribute fontSize. + * This is needed because the block.json defines a default fontSize, which is considered an anti-pattern + * since styles should be defined by themes and plugins instead. + * + * @param array $attributes The block attributes. + * @return array The font size classes and styles. + */ + private function get_font_size_classes_and_styles($attributes) + { + } + } + /** + * Cart class. + * + * @internal + */ + class Cart extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + { + /** + * Block name. + * + * @var string + */ + protected $block_name = 'cart'; + /** + * Chunks build folder. + * + * @var string + */ + protected $chunks_folder = 'cart-blocks'; + /** + * Initialize this block type. + * + * - Hook into WP lifecycle. + * - Register the block with WordPress. + */ + protected function initialize() + { + } + /** + * Dequeues the scripts added by WC Core to the Cart page. + * + * @return void + */ + public function dequeue_woocommerce_core_scripts() + { + } + /** + * Register block pattern for Empty Cart Message to make it translatable. + */ + public function register_patterns() + { + } + /** + * Get the editor script handle for this block type. + * + * @param string $key Data to get, or default to everything. + * @return array|string; + */ + protected function get_block_type_editor_script($key = null) + { + } + /** + * Get the frontend script handle for this block type. + * + * @see $this->register_block_type() + * @param string $key Data to get, or default to everything. + * @return array|string + */ + protected function get_block_type_script($key = null) + { + } + /** + * Get the frontend style handle for this block type. + * + * @return string[] + */ + protected function get_block_type_style() + { + } + /** + * Enqueue frontend assets for this block, just in time for rendering. + * + * @param array $attributes Any attributes that currently are available from the block. + * @param string $content The block content. + * @param WP_Block $block The block object. + */ + protected function enqueue_assets(array $attributes, $content, $block) + { + } + /** + * Append frontend scripts when rendering the Cart block. + * + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. + */ + protected function render($attributes, $content, $block) + { + } + /** + * Extra data passed through from server to client for block. + * + * @param array $attributes Any attributes that currently are available from the block. + * Note, this will be empty in the editor context when the block is + * not in the post content on editor load. + */ + protected function enqueue_data(array $attributes = []) + { + } + /** + * Register script and style assets for the block type before it is registered. + * + * This registers the scripts; it does not enqueue them. + */ + protected function register_block_type_assets() + { + } + /** + * Get list of Cart block & its inner-block types. + * + * @return array; + */ + public static function get_cart_block_types() + { + } + } + /** + * CartAcceptedPaymentMethodsBlock class. + */ + class CartAcceptedPaymentMethodsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + { + /** + * Block name. + * + * @var string + */ + protected $block_name = 'cart-accepted-payment-methods-block'; + } + /** + * CartCrossSellsBlock class. + */ + class CartCrossSellsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + { + /** + * Block name. + * + * @var string + */ + protected $block_name = 'cart-cross-sells-block'; + } + /** + * CartCrossSellsProductsBlock class. + */ + class CartCrossSellsProductsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + { + /** + * Block name. + * + * @var string + */ + protected $block_name = 'cart-cross-sells-products-block'; + } + /** + * CartExpressPaymentBlock class. + */ + class CartExpressPaymentBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + { + /** + * Block name. + * + * @var string + */ + protected $block_name = 'cart-express-payment-block'; + /** + * Uniform default_styles for the express payment buttons + * + * @var boolean + */ + protected $default_styles = null; + /** + * Current styles for the express payment buttons + * + * @var boolean + */ + protected $current_styles = null; + } + /** + * CartItemsBlock class. + */ + class CartItemsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + { + /** + * Block name. + * + * @var string + */ + protected $block_name = 'cart-items-block'; + } + /** + * CartLineItemsBlock class. + */ + class CartLineItemsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + { + /** + * Block name. + * + * @var string + */ + protected $block_name = 'cart-line-items-block'; + } + /** + * CartLink class. + */ + class CartLink extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + { + /** + * Block name. + * + * @var string + */ + protected $block_name = 'cart-link'; + /** + * Render the block. + * + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param \WP_Block $block Block instance. + * @return string | void Rendered block output. + */ + protected function render($attributes, $content, $block) + { + } + /** + * Get the frontend script handle for this block type. + * + * @param string $key Data to get, or default to everything. + */ + protected function get_block_type_script($key = null) + { + } + } + /** + * CartOrderSummaryBlock class. + */ + class CartOrderSummaryBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + { + /** + * Block name. + * + * @var string + */ + protected $block_name = 'cart-order-summary-block'; + /** + * Get the contents of the given inner block. + * + * @param string $block_name Name of the order summary inner block. + * @param string $content The content to search. + * @return array|bool + */ + private function get_inner_block_content($block_name, $content) + { + } + /** + * Get the regex that will return an inner block. + * + * @param string $block_name Name of the order summary inner block. + * @return string Regex pattern. + */ + private function inner_block_regex($block_name) + { + } + /** + * Render the Cart Order Summary block. + * + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param object $block Block object. + * @return string Rendered block. + */ + protected function render($attributes, $content, $block) + { + } + } + /** + * CartOrderSummaryCouponFormBlock class. + */ + class CartOrderSummaryCouponFormBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + { + /** + * Block name. + * + * @var string + */ + protected $block_name = 'cart-order-summary-coupon-form-block'; + } + /** + * CartOrderSummaryDiscountBlock class. + */ + class CartOrderSummaryDiscountBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + { + /** + * Block name. + * + * @var string + */ + protected $block_name = 'cart-order-summary-discount-block'; + } + /** + * CartOrderSummaryFeeBlock class. + */ + class CartOrderSummaryFeeBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + { + /** + * Block name. + * + * @var string + */ + protected $block_name = 'cart-order-summary-fee-block'; + } + /** + * CartOrderSummaryHeadingBlock class. + */ + class CartOrderSummaryHeadingBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + { + /** + * Block name. + * + * @var string + */ + protected $block_name = 'cart-order-summary-heading-block'; + } + /** + * CartOrderSummaryShippingBlock class. + */ + class CartOrderSummaryShippingBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + { + /** + * Block name. + * + * @var string + */ + protected $block_name = 'cart-order-summary-shipping-block'; + } + /** + * CartOrderSummarySubtotalBlock class. + */ + class CartOrderSummarySubtotalBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + { + /** + * Block name. + * + * @var string + */ + protected $block_name = 'cart-order-summary-subtotal-block'; + } + /** + * CartOrderSummaryTaxesBlock class. + */ + class CartOrderSummaryTaxesBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + { + /** + * Block name. + * + * @var string + */ + protected $block_name = 'cart-order-summary-taxes-block'; + } + /** + * CartOrderSummaryTotalsBlock class. + */ + class CartOrderSummaryTotalsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + { + /** + * Block name. + * + * @var string + */ + protected $block_name = 'cart-order-summary-totals-block'; + } + /** + * CartTotalsBlock class. + */ + class CartTotalsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock { /** * Block name. * * @var string */ - protected $block_name = 'attribute-filter'; - const FILTER_QUERY_VAR_PREFIX = 'filter_'; - const QUERY_TYPE_QUERY_VAR_PREFIX = 'query_type_'; - /** - * Extra data passed through from server to client for block. - * - * @param array $attributes Any attributes that currently are available from the block. - * Note, this will be empty in the editor context when the block is - * not in the post content on editor load. - */ - protected function enqueue_data(array $attributes = []) - { - } - /** - * Get the frontend style handle for this block type. - * - * @return string[] - */ - protected function get_block_type_style() - { - } + protected $block_name = 'cart-totals-block'; } /** - * Breadcrumbs class. + * CatalogSorting class. */ - class Breadcrumbs extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class CatalogSorting extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { /** * Block name. * * @var string */ - protected $block_name = 'breadcrumbs'; + protected $block_name = 'catalog-sorting'; /** * Render the block. * @@ -90333,40 +92927,26 @@ protected function render($attributes, $content, $block) protected function get_block_type_script($key = null) { } - /** - * Gets font size classes and styles for the breadcrumbs block. - * - * Note: This implementation intentionally avoids using StyleAttributesUtils::get_font_size_class_and_style() - * and get_block_wrapper_attributes() to ensure style attributes take precedence over the class attribute fontSize. - * This is needed because the block.json defines a default fontSize, which is considered an anti-pattern - * since styles should be defined by themes and plugins instead. - * - * @param array $attributes The block attributes. - * @return array The font size classes and styles. - */ - private function get_font_size_classes_and_styles($attributes) - { - } } /** - * Cart class. + * Checkout class. * * @internal */ - class Cart extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class Checkout extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { /** * Block name. * * @var string */ - protected $block_name = 'cart'; + protected $block_name = 'checkout'; /** * Chunks build folder. * * @var string */ - protected $chunks_folder = 'cart-blocks'; + protected $chunks_folder = 'checkout-blocks'; /** * Initialize this block type. * @@ -90377,13 +92957,19 @@ protected function initialize() { } /** - * Dequeues the scripts added by WC Core to the Cart page. + * Dequeues the scripts added by WC Core to the Checkout page. * * @return void */ public function dequeue_woocommerce_core_scripts() { } + /** + * Exposes settings exposed by the checkout block. + */ + public function register_settings() + { + } /** * Register block pattern for Empty Cart Message to make it translatable. */ @@ -90428,16 +93014,43 @@ protected function enqueue_assets(array $attributes, $content, $block) { } /** - * Append frontend scripts when rendering the Cart block. + * Append frontend scripts when rendering the block. * * @param array $attributes Block attributes. * @param string $content Block content. - * @param WP_Block $block Block instance. + * @param WP_Block $block Block instance. * @return string Rendered block type output. */ protected function render($attributes, $content, $block) { } + /** + * Check if we're viewing a checkout page endpoint, rather than the main checkout page itself. + * + * @return boolean + */ + protected function is_checkout_endpoint() + { + } + /** + * Update the local pickup title in WooCommerce Settings when the checkout page containing a Checkout block is saved. + * + * @param int $post_id The post ID. + * @param \WP_Post $post The post object. + * @return void + */ + public function update_local_pickup_title($post_id, $post) + { + } + /** + * Find the shipping methods block, then get the value of the localPickupText attribute from it. + * + * @param string $post_content The post content to search through. + * @return null|string The local pickup text if found, otherwise null. + */ + private function find_local_pickup_text_in_checkout_block($post_content) + { + } /** * Extra data passed through from server to client for block. * @@ -90448,6 +93061,12 @@ protected function render($attributes, $content, $block) protected function enqueue_data(array $attributes = []) { } + /** + * Get saved customer payment methods for use in checkout. + */ + protected function hydrate_customer_payment_methods() + { + } /** * Register script and style assets for the block type before it is registered. * @@ -90457,63 +93076,90 @@ protected function register_block_type_assets() { } /** - * Get list of Cart block & its inner-block types. + * Get list of Checkout block & its inner-block types. * * @return array; */ - public static function get_cart_block_types() + public static function get_checkout_block_types() { } } /** - * CartAcceptedPaymentMethodsBlock class. + * CheckoutActionsBlock class. */ - class CartAcceptedPaymentMethodsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + class CheckoutActionsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock { /** * Block name. * * @var string */ - protected $block_name = 'cart-accepted-payment-methods-block'; + protected $block_name = 'checkout-actions-block'; + /** + * Initialize this block type. + * + * - Hook into WP lifecycle. + * - Register the block with WordPress. + */ + protected function initialize() + { + } + /** + * Register style variations for the block. + */ + public function register_style_variations() + { + } } /** - * CartCrossSellsBlock class. + * CheckoutAdditionalInformationBlock class. */ - class CartCrossSellsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + class CheckoutAdditionalInformationBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock { /** * Block name. * * @var string */ - protected $block_name = 'cart-cross-sells-block'; + protected $block_name = 'checkout-additional-information-block'; } /** - * CartCrossSellsProductsBlock class. + * CheckoutBillingAddressBlock class. */ - class CartCrossSellsProductsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + class CheckoutBillingAddressBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock { /** * Block name. * * @var string */ - protected $block_name = 'cart-cross-sells-products-block'; + protected $block_name = 'checkout-billing-address-block'; } /** - * CartExpressPaymentBlock class. + * CheckoutContactInformationBlock class. */ - class CartExpressPaymentBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + class CheckoutContactInformationBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock { /** * Block name. * * @var string */ - protected $block_name = 'cart-express-payment-block'; + protected $block_name = 'checkout-contact-information-block'; + } + /** + * CheckoutExpressPaymentBlock class. + */ + class CheckoutExpressPaymentBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + { /** - * Uniform default_styles for the express payment buttons + * Block name. + * + * @var string + */ + protected $block_name = 'checkout-express-payment-block'; + /** + * Default styles for the express payment buttons * * @var boolean */ @@ -90524,73 +93170,66 @@ class CartExpressPaymentBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\ * @var boolean */ protected $current_styles = null; - } - /** - * CartItemsBlock class. - */ - class CartItemsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock - { /** - * Block name. + * Initialise the block + */ + protected function initialize() + { + } + /** + * Synchorize the express payment attributes between the Cart and Checkout pages. * - * @var string + * @param int $post_id Post ID. + * @param WP_Post $post Post object. */ - protected $block_name = 'cart-items-block'; + public function sync_express_payment_attrs($post_id, $post) + { + } + /** + * Update the express payment attributes in the other page (Cart or Checkout). + * + * @param string $cart_or_checkout The page to update. + * @param array $updated_attrs The updated attributes. + */ + private function update_other_page_with_express_payment_attrs($cart_or_checkout, $updated_attrs) + { + } } /** - * CartLineItemsBlock class. + * CheckoutFieldsBlock class. */ - class CartLineItemsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + class CheckoutFieldsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock { /** * Block name. * * @var string */ - protected $block_name = 'cart-line-items-block'; + protected $block_name = 'checkout-fields-block'; } /** - * CartLink class. + * CheckoutOrderNoteBlock class. */ - class CartLink extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class CheckoutOrderNoteBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock { /** * Block name. * * @var string */ - protected $block_name = 'cart-link'; - /** - * Render the block. - * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param \WP_Block $block Block instance. - * @return string | void Rendered block output. - */ - protected function render($attributes, $content, $block) - { - } - /** - * Get the frontend script handle for this block type. - * - * @param string $key Data to get, or default to everything. - */ - protected function get_block_type_script($key = null) - { - } + protected $block_name = 'checkout-order-note-block'; } /** - * CartOrderSummaryBlock class. + * CheckoutOrderSummaryBlock class. */ - class CartOrderSummaryBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + class CheckoutOrderSummaryBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock { /** * Block name. * * @var string */ - protected $block_name = 'cart-order-summary-block'; + protected $block_name = 'checkout-order-summary-block'; /** * Get the contents of the given inner block. * @@ -90611,7 +93250,7 @@ private function inner_block_regex($block_name) { } /** - * Render the Cart Order Summary block. + * Render the Checkout Order Summary block. * * @param array $attributes Block attributes. * @param string $content Block content. @@ -90623,223 +93262,392 @@ protected function render($attributes, $content, $block) } } /** - * CartOrderSummaryCouponFormBlock class. + * CheckoutOrderSummaryCartItemsBlock class. */ - class CartOrderSummaryCouponFormBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + class CheckoutOrderSummaryCartItemsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock { /** * Block name. * * @var string */ - protected $block_name = 'cart-order-summary-coupon-form-block'; + protected $block_name = 'checkout-order-summary-cart-items-block'; } /** - * CartOrderSummaryDiscountBlock class. + * CheckoutOrderSummaryCouponFormBlock class. */ - class CartOrderSummaryDiscountBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + class CheckoutOrderSummaryCouponFormBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock { /** * Block name. * * @var string */ - protected $block_name = 'cart-order-summary-discount-block'; + protected $block_name = 'checkout-order-summary-coupon-form-block'; } /** - * CartOrderSummaryFeeBlock class. + * CheckoutOrderSummaryDiscountBlock class. */ - class CartOrderSummaryFeeBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + class CheckoutOrderSummaryDiscountBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock { /** * Block name. * * @var string */ - protected $block_name = 'cart-order-summary-fee-block'; + protected $block_name = 'checkout-order-summary-discount-block'; } /** - * CartOrderSummaryHeadingBlock class. + * CheckoutOrderSummaryFeeBlock class. */ - class CartOrderSummaryHeadingBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + class CheckoutOrderSummaryFeeBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock { /** * Block name. * * @var string */ - protected $block_name = 'cart-order-summary-heading-block'; + protected $block_name = 'checkout-order-summary-fee-block'; } /** - * CartOrderSummaryShippingBlock class. + * CheckoutOrderSummaryShippingBlock class. */ - class CartOrderSummaryShippingBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + class CheckoutOrderSummaryShippingBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock { /** * Block name. * * @var string */ - protected $block_name = 'cart-order-summary-shipping-block'; + protected $block_name = 'checkout-order-summary-shipping-block'; } /** - * CartOrderSummarySubtotalBlock class. + * CheckoutOrderSummarySubtotalBlock class. */ - class CartOrderSummarySubtotalBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + class CheckoutOrderSummarySubtotalBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock { /** * Block name. * * @var string */ - protected $block_name = 'cart-order-summary-subtotal-block'; + protected $block_name = 'checkout-order-summary-subtotal-block'; } /** - * CartOrderSummaryTaxesBlock class. + * CheckoutOrderSummaryTaxesBlock class. */ - class CartOrderSummaryTaxesBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + class CheckoutOrderSummaryTaxesBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock { /** * Block name. * * @var string */ - protected $block_name = 'cart-order-summary-taxes-block'; + protected $block_name = 'checkout-order-summary-taxes-block'; } /** - * CartOrderSummaryTotalsBlock class. + * CheckoutOrderSummaryTotalsBlock class. */ - class CartOrderSummaryTotalsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + class CheckoutOrderSummaryTotalsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock { /** * Block name. * * @var string */ - protected $block_name = 'cart-order-summary-totals-block'; + protected $block_name = 'checkout-order-summary-totals-block'; } /** - * CartTotalsBlock class. + * CheckoutPaymentBlock class. */ - class CartTotalsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + class CheckoutPaymentBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock { /** * Block name. * * @var string */ - protected $block_name = 'cart-totals-block'; + protected $block_name = 'checkout-payment-block'; } /** - * CatalogSorting class. + * CheckoutPickupOptionsBlock class. */ - class CatalogSorting extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class CheckoutPickupOptionsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock { /** * Block name. * * @var string */ - protected $block_name = 'catalog-sorting'; + protected $block_name = 'checkout-pickup-options-block'; + } + /** + * CheckoutShippingAddressBlock class. + */ + class CheckoutShippingAddressBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + { /** - * Render the block. + * Block name. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. + * @var string + */ + protected $block_name = 'checkout-shipping-address-block'; + } + /** + * CheckoutShippingMethodBlock class. + */ + class CheckoutShippingMethodBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + { + /** + * Block name. * - * @return string | void Rendered block output. + * @var string + */ + protected $block_name = 'checkout-shipping-method-block'; + } + /** + * CheckoutShippingMethodsBlock class. + */ + class CheckoutShippingMethodsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + { + /** + * Block name. + * + * @var string + */ + protected $block_name = 'checkout-shipping-methods-block'; + } + /** + * CheckoutTermsBlock class. + */ + class CheckoutTermsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + { + /** + * Block name. + * + * @var string + */ + protected $block_name = 'checkout-terms-block'; + } + /** + * CheckoutTotalsBlock class. + */ + class CheckoutTotalsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + { + /** + * Block name. + * + * @var string + */ + protected $block_name = 'checkout-totals-block'; + } + /** + * Classic Shortcode class + * + * @internal + */ + class ClassicShortcode extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractDynamicBlock + { + /** + * Block name. + * + * @var string + */ + protected $block_name = 'classic-shortcode'; + /** + * API version. + * + * @var string + */ + protected $api_version = '3'; + /** + * Render method for the Classic Template block. This method will determine which template to render. + * + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string | void Rendered block type output. */ protected function render($attributes, $content, $block) { } /** - * Get the frontend script handle for this block type. + * Get the list of classes to apply to this block. * - * @param string $key Data to get, or default to everything. + * @param array $attributes Block attributes. Default empty array. + * @return string space-separated list of classes. */ - protected function get_block_type_script($key = null) + protected function get_container_classes($attributes = array()) + { + } + /** + * Render method for rendering the cart shortcode. + * + * @param array $attributes Block attributes. + * @return string Rendered block type output. + */ + protected function render_cart($attributes) + { + } + /** + * Render method for rendering the checkout shortcode. + * + * @param array $attributes Block attributes. + * @return string Rendered block type output. + */ + protected function render_checkout($attributes) + { + } + /** + * Get the frontend style handle for this block type. + * + * @return null + */ + protected function get_block_type_style() { } } /** - * Checkout class. + * Classic Template class * * @internal */ - class Checkout extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class ClassicTemplate extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractDynamicBlock { /** * Block name. * * @var string */ - protected $block_name = 'checkout'; + protected $block_name = 'legacy-template'; /** - * Chunks build folder. + * API version. * * @var string */ - protected $chunks_folder = 'checkout-blocks'; + protected $api_version = '3'; /** - * Initialize this block type. - * - * - Hook into WP lifecycle. - * - Register the block with WordPress. + * Initialize this block. */ protected function initialize() { } /** - * Dequeues the scripts added by WC Core to the Checkout page. + * Extra data passed through from server to client for block. * - * @return void + * @param array $attributes Any attributes that currently are available from the block. + * Note, this will be empty in the editor context when the block is + * not in the post content on editor load. */ - public function dequeue_woocommerce_core_scripts() + protected function enqueue_data(array $attributes = array()) { } /** - * Exposes settings exposed by the checkout block. + * Enqueue assets used for rendering the block in editor context. + * + * This is needed if a block is not yet within the post content--`render` and `enqueue_assets` may not have ran. */ - public function register_settings() + public function enqueue_block_assets() { } /** - * Register block pattern for Empty Cart Message to make it translatable. + * Enqueue assets specific to this block. + * + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. */ - public function register_patterns() + protected function enqueue_assets($attributes, $content, $block) { } /** - * Get the editor script handle for this block type. + * Enqueue legacy assets when this block is used as we don't enqueue them for block themes anymore. * - * @param string $key Data to get, or default to everything. - * @return array|string; + * Note: This enqueue logic is intentionally duplicated in ProductImageGallery.php + * to keep legacy blocks independent and allow for separate deprecation paths. + * + * @see https://github.com/woocommerce/woocommerce/pull/60223 */ - protected function get_block_type_editor_script($key = null) + public function enqueue_legacy_assets() { } /** - * Get the frontend script handle for this block type. + * Render method for the Classic Template block. This method will determine which template to render. * - * @see $this->register_block_type() - * @param string $key Data to get, or default to everything. - * @return array|string + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string | void Rendered block type output. */ - protected function get_block_type_script($key = null) + protected function render($attributes, $content, $block) { } /** - * Get the frontend style handle for this block type. + * Render method for rendering the order confirmation template. * - * @return string[] + * @return string Rendered block type output. + */ + protected function render_order_received() + { + } + /** + * Render method for the single product template and parts. + * + * @return string Rendered block type output. + */ + protected function render_single_product() + { + } + /** + * Render method for the archive product template and parts. + * + * @return string Rendered block type output. + */ + protected function render_archive_product() + { + } + /** + * Get HTML markup with the right classes by attributes. + * This function appends the classname at the first element that have the class attribute. + * Based on the experience, all the wrapper elements have a class attribute. + * + * @param string $content Block content. + * @param array $block Parsed block data. + * @return string Rendered block type output. + */ + public function add_alignment_class_to_wrapper(string $content, array $block) + { + } + } + /** + * ComingSoon class. + */ + class ComingSoon extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + { + /** + * Block name. + * + * @var string + */ + protected $block_name = 'coming-soon'; + /** + * It is necessary to register and enqueue assets during the render phase because we want to load assets only if the block has the content. + */ + protected function register_block_type_assets() + { + } + /** + * Initialize. */ - protected function get_block_type_style() + public function initialize() { } /** * Enqueue frontend assets for this block, just in time for rendering. * + * @internal This prevents the block script being enqueued on all pages. It is only enqueued as needed. Note that + * we intentionally do not pass 'script' to register_block_type. + * * @param array $attributes Any attributes that currently are available from the block. * @param string $content The block content. * @param WP_Block $block The block object. @@ -90848,862 +93656,865 @@ protected function enqueue_assets(array $attributes, $content, $block) { } /** - * Append frontend scripts when rendering the block. - * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * Enqueue coming soon deprecated styles in site editor to support + * coming soon templates created before WooCommerce 9.8.0. */ - protected function render($attributes, $content, $block) + public function enqueue_block_assets() { } /** - * Check if we're viewing a checkout page endpoint, rather than the main checkout page itself. + * Get the frontend script handle for this block type. * - * @return boolean + * @see $this->register_block_type() + * @param string $key Data to get, or default to everything. + * @return array|string|null */ - protected function is_checkout_endpoint() + protected function get_block_type_script($key = null) { } + } +} +namespace Automattic\WooCommerce\Blocks\Utils { + /** + * BlockHooksTrait + * + * Shared functionality for using the Block Hooks API with WooCommerce Blocks. + */ + trait BlockHooksTrait + { /** - * Update the local pickup title in WooCommerce Settings when the checkout page containing a Checkout block is saved. + * Callback for `hooked_block_types` to auto-inject the mini-cart block into headers after navigation. * - * @param int $post_id The post ID. - * @param \WP_Post $post The post object. - * @return void + * @param array $hooked_blocks An array of block slugs hooked into a given context. + * @param string $position Position of the block insertion point. + * @param string $anchor_block The block acting as the anchor for the inserted block. + * @param array|\WP_Post|\WP_Block_Template $context Where the block is embedded. + * @since 8.5.0 + * @return array An array of block slugs hooked into a given context. */ - public function update_local_pickup_title($post_id, $post) + public function register_hooked_block($hooked_blocks, $position, $anchor_block, $context) { } /** - * Recurse through the blocks to find the shipping methods block, then get the value of the localPickupText attribute from it. + * Checks if the provided context contains a the block already. * - * @param array $blocks The block(s) to search for the local pickup text. - * @return null|string The local pickup text if found, otherwise void. + * @param array|\WP_Block_Template $context Where the block is embedded. + * @return boolean */ - private function find_local_pickup_text_in_checkout_block($blocks) + protected function has_block_in_content($context) { } /** - * Extra data passed through from server to client for block. + * Given a provided context, returns the content of the context. * - * @param array $attributes Any attributes that currently are available from the block. - * Note, this will be empty in the editor context when the block is - * not in the post content on editor load. + * @param array|\WP_Post|\WP_Block_Template $context Where the block is embedded. + * @since 8.5.0 + * @return string */ - protected function enqueue_data(array $attributes = []) + protected function get_context_content($context) { } /** - * Get saved customer payment methods for use in checkout. + * Given a provided context, returns whether the context refers to header content. + * + * @param array|\WP_Post|\WP_Block_Template $context Where the block is embedded. + * @param string $area The area to check against before inserting. + * @since 8.5.0 + * @return boolean */ - protected function hydrate_customer_payment_methods() + protected function is_template_part_or_pattern($context, $area) { } /** - * Register script and style assets for the block type before it is registered. + * Given a provided context, returns whether the context refers to the target area and isn't marked as excluded. * - * This registers the scripts; it does not enqueue them. + * @param array|\WP_Post|\WP_Block_Template $context the context to check. + * @param string $area The area to check against before inserting. + * @since 8.5.0 + * @return boolean */ - protected function register_block_type_assets() + protected function is_target_area($context, $area) { } /** - * Get list of Checkout block & its inner-block types. + * Returns whether the pattern is excluded or not * - * @return array; + * @since 8.5.0 + * + * @param array|\WP_Block_Template $context Where the block is embedded. + * @return boolean */ - public static function get_checkout_block_types() + protected function pattern_is_excluded($context) { } } +} +namespace Automattic\WooCommerce\Blocks\BlockTypes { /** - * CheckoutActionsBlock class. + * CustomerAccount class. */ - class CheckoutActionsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + class CustomerAccount extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { + use \Automattic\WooCommerce\Blocks\Utils\BlockHooksTrait; + const TEXT_ONLY = 'text_only'; + const ICON_ONLY = 'icon_only'; + const DISPLAY_ALT = 'alt'; + const DISPLAY_LINE = 'line'; /** * Block name. * * @var string */ - protected $block_name = 'checkout-actions-block'; + protected $block_name = 'customer-account'; /** - * Initialize this block type. + * Block Hook API placements. * - * - Hook into WP lifecycle. - * - Register the block with WordPress. + * @var array + */ + protected $hooked_block_placements = array(array('position' => 'after', 'anchor' => 'core/navigation', 'area' => 'header', 'callback' => 'should_unhook_block', 'version' => '8.4.0')); + /** + * Initialize this block type. */ protected function initialize() { } /** - * Register style variations for the block. + * Callback for the Block Hooks API to modify the attributes of the hooked block. + * + * @param array|null $parsed_hooked_block The parsed block array for the given hooked block type, or null to suppress the block. + * @param string $hooked_block_type The hooked block type name. + * @param string $relative_position The relative position of the hooked block. + * @param array $parsed_anchor_block The anchor block, in parsed block array format. + * @param WP_Block_Template|WP_Post|array $context The block template, template part, `wp_navigation` post type, + * or pattern that the anchor block belongs to. + * @return array|null */ - public function register_style_variations() + public function modify_hooked_block_attributes($parsed_hooked_block, $hooked_block_type, $relative_position, $parsed_anchor_block, $context) { } - } - /** - * CheckoutAdditionalInformationBlock class. - */ - class CheckoutAdditionalInformationBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock - { /** - * Block name. + * Callback for the Block Hooks API to determine if the block should be auto-inserted. * - * @var string - */ - protected $block_name = 'checkout-additional-information-block'; - } - /** - * CheckoutBillingAddressBlock class. - */ - class CheckoutBillingAddressBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock - { - /** - * Block name. + * @param array $hooked_blocks An array of block slugs hooked into a given context. + * @param string $position Position of the block insertion point. + * @param string $anchor_block The block acting as the anchor for the inserted block. + * @param array|\WP_Post|\WP_Block_Template $context Where the block is embedded. * - * @var string + * @return array */ - protected $block_name = 'checkout-billing-address-block'; - } - /** - * CheckoutContactInformationBlock class. - */ - class CheckoutContactInformationBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock - { + protected function should_unhook_block($hooked_blocks, $position, $anchor_block, $context) + { + } /** - * Block name. + * Render the block. * - * @var string - */ - protected $block_name = 'checkout-contact-information-block'; - } - /** - * CheckoutExpressPaymentBlock class. - */ - class CheckoutExpressPaymentBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock - { - /** - * Block name. + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. * - * @var string + * @return string Rendered block output. */ - protected $block_name = 'checkout-express-payment-block'; + protected function render($attributes, $content, $block) + { + } /** - * Default styles for the express payment buttons + * Gets the icon to render depending on the iconStyle and displayStyle. * - * @var boolean - */ - protected $default_styles = null; - /** - * Current styles for the express payment buttons + * @param array $attributes Block attributes. * - * @var boolean - */ - protected $current_styles = null; - /** - * Initialise the block + * @return string Label to render on the block */ - protected function initialize() + private function render_icon($attributes) { } /** - * Synchorize the express payment attributes between the Cart and Checkout pages. + * Gets the label to render depending on the displayStyle. * - * @param int $post_id Post ID. - * @param WP_Post $post Post object. + * @return string Label to render on the block. */ - public function sync_express_payment_attrs($post_id, $post) + private function render_label() { } /** - * Update the express payment attributes in the other page (Cart or Checkout). + * Get the frontend script handle for this block type. * - * @param string $cart_or_checkout The page to update. - * @param array $updated_attrs The updated attributes. + * @param string $key Data to get, or default to everything. + * + * @return null This block has no frontend script. */ - private function update_other_page_with_express_payment_attrs($cart_or_checkout, $updated_attrs) + protected function get_block_type_script($key = null) { } } /** - * CheckoutFieldsBlock class. + * EmailContent class. */ - class CheckoutFieldsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + class EmailContent extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { /** * Block name. * * @var string */ - protected $block_name = 'checkout-fields-block'; - } - /** - * CheckoutOrderNoteBlock class. - */ - class CheckoutOrderNoteBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock - { + protected $block_name = 'email-content'; /** - * Block name. + * Get the frontend style handle for this block type. * - * @var string + * @return null */ - protected $block_name = 'checkout-order-note-block'; - } - /** - * CheckoutOrderSummaryBlock class. - */ - class CheckoutOrderSummaryBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock - { + protected function get_block_type_style() + { + } /** - * Block name. + * Get the editor script handle for this block type. * - * @var string + * @param string $key Data to get, or default to everything. + * @return array|string */ - protected $block_name = 'checkout-order-summary-block'; + protected function get_block_type_editor_script($key = null) + { + } /** - * Get the contents of the given inner block. + * Get the frontend script handle for this block type. * - * @param string $block_name Name of the order summary inner block. - * @param string $content The content to search. - * @return array|bool + * @param string $key Data to get, or default to everything. */ - private function get_inner_block_content($block_name, $content) + protected function get_block_type_script($key = null) { } /** - * Get the regex that will return an inner block. + * Renders the block preview for the editor. * - * @param string $block_name Name of the order summary inner block. - * @return string Regex pattern. + * @param array $attributes Block attributes. + * @return string Rendered block output. */ - private function inner_block_regex($block_name) + protected function render_preview($attributes) { } /** - * Render the Checkout Order Summary block. + * Renders Woo content placeholder to be replaced by content during sending. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param object $block Block object. - * @return string Rendered block. + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param \WP_Block $block Block instance. + * @return string Rendered block output. */ protected function render($attributes, $content, $block) { } } /** - * CheckoutOrderSummaryCartItemsBlock class. + * EmptyCartBlock class. */ - class CheckoutOrderSummaryCartItemsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + class EmptyCartBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock { /** * Block name. * * @var string */ - protected $block_name = 'checkout-order-summary-cart-items-block'; + protected $block_name = 'empty-cart-block'; } /** - * CheckoutOrderSummaryCouponFormBlock class. + * EmptyMiniCartContentsBlock class. */ - class CheckoutOrderSummaryCouponFormBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + class EmptyMiniCartContentsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock { /** * Block name. * * @var string */ - protected $block_name = 'checkout-order-summary-coupon-form-block'; - } - /** - * CheckoutOrderSummaryDiscountBlock class. - */ - class CheckoutOrderSummaryDiscountBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock - { + protected $block_name = 'empty-mini-cart-contents-block'; /** - * Block name. + * Render the markup for the Filled Mini-Cart Contents block. * - * @var string + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - protected $block_name = 'checkout-order-summary-discount-block'; - } - /** - * CheckoutOrderSummaryFeeBlock class. - */ - class CheckoutOrderSummaryFeeBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock - { + protected function render($attributes, $content, $block) + { + } /** - * Block name. + * Render the experimental interactivity API powered Filled Mini-Cart Contents block. * - * @var string + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - protected $block_name = 'checkout-order-summary-fee-block'; + protected function render_experimental_empty_mini_cart_contents($attributes, $content, $block) + { + } } /** - * CheckoutOrderSummaryShippingBlock class. + * FeaturedItem class. */ - class CheckoutOrderSummaryShippingBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + abstract class FeaturedItem extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractDynamicBlock { /** * Block name. * * @var string */ - protected $block_name = 'checkout-order-summary-shipping-block'; - } - /** - * CheckoutOrderSummarySubtotalBlock class. - */ - class CheckoutOrderSummarySubtotalBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock - { + protected $block_name; /** - * Block name. + * Default attribute values. * - * @var string + * @var array */ - protected $block_name = 'checkout-order-summary-subtotal-block'; - } - /** - * CheckoutOrderSummaryTaxesBlock class. - */ - class CheckoutOrderSummaryTaxesBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock - { + protected $defaults = array('align' => 'none'); /** - * Block name. + * Global style enabled for this block. * - * @var string + * @var array */ - protected $block_name = 'checkout-order-summary-taxes-block'; - } - /** - * CheckoutOrderSummaryTotalsBlock class. - */ - class CheckoutOrderSummaryTotalsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock - { + protected $global_style_wrapper = array('background_color', 'border_color', 'border_radius', 'border_width', 'font_size', 'padding', 'text_color', 'extra_classes'); /** - * Block name. + * Returns the featured item. * - * @var string + * @param array $attributes Block attributes. Default empty array. + * @return \WP_Term|\WC_Product|null */ - protected $block_name = 'checkout-order-summary-totals-block'; - } - /** - * CheckoutPaymentBlock class. - */ - class CheckoutPaymentBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock - { + abstract protected function get_item($attributes); /** - * Block name. + * Returns the name of the featured item. * - * @var string + * @param \WP_Term|\WC_Product $item Item object. + * @return string */ - protected $block_name = 'checkout-payment-block'; - } - /** - * CheckoutPickupOptionsBlock class. - */ - class CheckoutPickupOptionsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock - { + abstract protected function get_item_title($item); /** - * Block name. + * Returns the featured item image URL. * - * @var string + * @param \WP_Term|\WC_Product $item Item object. + * @param string $size Image size, defaults to 'full'. + * @return string */ - protected $block_name = 'checkout-pickup-options-block'; - } - /** - * CheckoutShippingAddressBlock class. - */ - class CheckoutShippingAddressBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock - { + abstract protected function get_item_image($item, $size = 'full'); /** - * Block name. + * Renders the featured item attributes. * - * @var string + * @param \WP_Term|\WC_Product $item Item object. + * @param array $attributes Block attributes. Default empty array. + * @return string */ - protected $block_name = 'checkout-shipping-address-block'; - } - /** - * CheckoutShippingMethodBlock class. - */ - class CheckoutShippingMethodBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock - { + abstract protected function render_attributes($item, $attributes); /** - * Block name. + * Render the featured item block. * - * @var string + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - protected $block_name = 'checkout-shipping-method-block'; - } - /** - * CheckoutShippingMethodsBlock class. - */ - class CheckoutShippingMethodsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock - { + protected function render($attributes, $content, $block) + { + } /** - * Block name. + * Returns the url the item's image * - * @var string + * @param array $attributes Block attributes. Default empty array. + * @param \WP_Term|\WC_Product $item Item object. + * + * @return string */ - protected $block_name = 'checkout-shipping-methods-block'; - } - /** - * CheckoutTermsBlock class. - */ - class CheckoutTermsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock - { + private function get_image_url($attributes, $item) + { + } /** - * Block name. + * Renders the featured image as a div background. * - * @var string + * @param array $attributes Block attributes. Default empty array. + * @param string $image_url Item image url. + * + * @return string */ - protected $block_name = 'checkout-terms-block'; - } - /** - * CheckoutTotalsBlock class. - */ - class CheckoutTotalsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock - { + private function render_bg_image($attributes, $image_url) + { + } + /** + * Get the styles for the wrapper element (background image, color). + * + * @param array $attributes Block attributes. Default empty array. + * @param string $image_url Item image url. + * + * @return string + */ + public function get_bg_styles($attributes, $image_url) + { + } + /** + * Renders the featured image + * + * @param array $attributes Block attributes. Default empty array. + * @param \WC_Product|\WP_Term $item Item object. + * @param string $image_url Item image url. + * + * @return string + */ + private function render_image($attributes, $item, string $image_url) + { + } + /** + * Get the styles for the wrapper element (background image, color). + * + * @param array $attributes Block attributes. Default empty array. + * @return string + */ + public function get_styles($attributes) + { + } + /** + * Get class names for the block container. + * + * @param array $attributes Block attributes. Default empty array. + * @return string + */ + public function get_classes($attributes) + { + } + /** + * Renders the block overlay + * + * @param array $attributes Block attributes. Default empty array. + * + * @return string + */ + private function render_overlay($attributes) + { + } + /** + * Returns whether the focal point is defined for the block. + * + * @param array $attributes Block attributes. Default empty array. + * + * @return bool + */ + private function hasFocalPoint($attributes): bool + { + } /** - * Block name. + * Extra data passed through from server to client for block. * - * @var string + * @param array $attributes Any attributes that currently are available from the block. + * Note, this will be empty in the editor context when the block is + * not in the post content on editor load. */ - protected $block_name = 'checkout-totals-block'; + protected function enqueue_data(array $attributes = []) + { + } } /** - * Classic Shortcode class - * - * @internal + * FeaturedCategory class. */ - class ClassicShortcode extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractDynamicBlock + class FeaturedCategory extends \Automattic\WooCommerce\Blocks\BlockTypes\FeaturedItem { /** * Block name. * * @var string */ - protected $block_name = 'classic-shortcode'; - /** - * API version. - * - * @var string - */ - protected $api_version = '3'; + protected $block_name = 'featured-category'; /** - * Render method for the Classic Template block. This method will determine which template to render. + * Get block attributes. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string | void Rendered block type output. + * @return array */ - protected function render($attributes, $content, $block) + protected function get_block_type_attributes() { } /** - * Get the list of classes to apply to this block. + * Returns the featured category. * * @param array $attributes Block attributes. Default empty array. - * @return string space-separated list of classes. + * @return \WP_Term|null */ - protected function get_container_classes($attributes = array()) + protected function get_item($attributes) { } /** - * Render method for rendering the cart shortcode. + * Returns the name of the featured category. * - * @param array $attributes Block attributes. - * @return string Rendered block type output. + * @param \WP_Term $category Featured category. + * @return string */ - protected function render_cart($attributes) + protected function get_item_title($category) { } /** - * Render method for rendering the checkout shortcode. + * Returns the featured category image URL. * - * @param array $attributes Block attributes. - * @return string Rendered block type output. + * @param \WP_Term $category Term object. + * @param string $size Image size, defaults to 'full'. + * @return string */ - protected function render_checkout($attributes) + protected function get_item_image($category, $size = 'full') { } /** - * Get the frontend style handle for this block type. + * Renders the featured category attributes. * - * @return null + * @param \WP_Term $category Term object. + * @param array $attributes Block attributes. Default empty array. + * @return string */ - protected function get_block_type_style() + protected function render_attributes($category, $attributes) { } } /** - * Classic Template class - * - * @internal + * FeaturedProduct class. */ - class ClassicTemplate extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractDynamicBlock + class FeaturedProduct extends \Automattic\WooCommerce\Blocks\BlockTypes\FeaturedItem { /** * Block name. * * @var string */ - protected $block_name = 'legacy-template'; + protected $block_name = 'featured-product'; /** - * API version. + * Returns the featured product. * - * @var string - */ - protected $api_version = '3'; - /** - * Initialize this block. + * @param array $attributes Block attributes. Default empty array. + * @return \WP_Term|null */ - protected function initialize() + protected function get_item($attributes) { } /** - * Extra data passed through from server to client for block. + * Returns the name of the featured product. * - * @param array $attributes Any attributes that currently are available from the block. - * Note, this will be empty in the editor context when the block is - * not in the post content on editor load. + * @param \WC_Product $product Product object. + * @return string */ - protected function enqueue_data(array $attributes = array()) + protected function get_item_title($product) { } /** - * Enqueue assets used for rendering the block in editor context. + * Returns the featured product image URL. * - * This is needed if a block is not yet within the post content--`render` and `enqueue_assets` may not have ran. + * @param \WC_Product $product Product object. + * @param string $size Image size, defaults to 'full'. + * @return string */ - public function enqueue_block_assets() + protected function get_item_image($product, $size = 'full') { } /** - * Enqueue assets specific to this block. + * Renders the featured product attributes. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. + * @param \WC_Product $product Product object. + * @param array $attributes Block attributes. Default empty array. + * @return string */ - protected function enqueue_assets($attributes, $content, $block) + protected function render_attributes($product, $attributes) { } + } + /** + * FilledCartBlock class. + */ + class FilledCartBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + { /** - * Enqueue legacy assets when this block is used as we don't enqueue them for block themes anymore. + * Block name. * - * Note: This enqueue logic is intentionally duplicated in ProductImageGallery.php - * to keep legacy blocks independent and allow for separate deprecation paths. + * @var string + */ + protected $block_name = 'filled-cart-block'; + } + /** + * FilledMiniCartContentsBlock class. + */ + class FilledMiniCartContentsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + { + /** + * Block name. * - * @see https://github.com/woocommerce/woocommerce/pull/60223 + * @var string */ - public function enqueue_legacy_assets() - { - } + protected $block_name = 'filled-mini-cart-contents-block'; /** - * Render method for the Classic Template block. This method will determine which template to render. + * Render the markup for the Filled Mini-Cart Contents block. * * @param array $attributes Block attributes. * @param string $content Block content. * @param WP_Block $block Block instance. - * @return string | void Rendered block type output. + * @return string Rendered block type output. */ protected function render($attributes, $content, $block) { } /** - * Render method for rendering the order confirmation template. + * Render the experimental interactivity API powered Filled Mini-Cart Contents block. * + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. * @return string Rendered block type output. */ - protected function render_order_received() + protected function render_experimental_filled_mini_cart_contents($attributes, $content, $block) { } + } + /** + * FilterWrapper class. + */ + class FilterWrapper extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + { /** - * Render method for the single product template and parts. + * Block name. * - * @return string Rendered block type output. + * @var string */ - protected function render_single_product() + protected $block_name = 'filter-wrapper'; + /** + * Get the frontend style handle for this block type. + * + * @return null + */ + protected function get_block_type_style() { } + } + /** + * HandpickedProducts class. + */ + class HandpickedProducts extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractProductGrid + { /** - * Render method for the archive product template and parts. + * Block name. * - * @return string Rendered block type output. + * @var string */ - protected function render_archive_product() + protected $block_name = 'handpicked-products'; + /** + * Set args specific to this block + * + * @param array $query_args Query args. + */ + protected function set_block_query_args(&$query_args) { } /** - * Get HTML markup with the right classes by attributes. - * This function appends the classname at the first element that have the class attribute. - * Based on the experience, all the wrapper elements have a class attribute. + * Set visibility query args. Handpicked products will show hidden products if chosen. * - * @param string $content Block content. - * @param array $block Parsed block data. - * @return string Rendered block type output. + * @param array $query_args Query args. */ - public function add_alignment_class_to_wrapper(string $content, array $block) + protected function set_visibility_query_args(&$query_args) { } /** - * Get the frontend style handle for this block type. + * Get block attributes. * - * @return null + * @return array */ - protected function get_block_type_style() + protected function get_block_type_attributes() { } } +} +namespace Automattic\WooCommerce\Blocks\Utils { /** - * ComingSoon class. + * Manages the registration of interactivity config and state that is commonly shared by WooCommerce blocks. + * Initialization only happens on the first call to initialize_shared_config. + * Intended to be used as a singleton. */ - class ComingSoon extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + trait BlocksSharedState { /** - * Block name. + * The consent statement for using private APIs of this class. * * @var string */ - protected $block_name = 'coming-soon'; + private static $consent_statement = 'I acknowledge that using private APIs means my theme or plugin will inevitably break in the next version of WooCommerce'; /** - * It is necessary to register and enqueue assets during the render phase because we want to load assets only if the block has the content. + * The namespace for the config. + * + * @var string */ - protected function register_block_type_assets() - { - } + private static $settings_namespace = 'woocommerce'; /** - * Initialize. + * Whether the core config has been registered. + * + * @var boolean */ - public function initialize() - { - } + private static $core_config_registered = false; /** - * Enqueue frontend assets for this block, just in time for rendering. - * - * @internal This prevents the block script being enqueued on all pages. It is only enqueued as needed. Note that - * we intentionally do not pass 'script' to register_block_type. + * Cart state. * - * @param array $attributes Any attributes that currently are available from the block. - * @param string $content The block content. - * @param WP_Block $block The block object. + * @var mixed */ - protected function enqueue_assets(array $attributes, $content, $block) - { - } + private static $blocks_shared_cart_state; /** - * Enqueue coming soon deprecated styles in site editor to support - * coming soon templates created before WooCommerce 9.8.0. + * Prevent caching on certain pages */ - public function enqueue_block_assets() + private static function prevent_cache() { } /** - * Get the frontend script handle for this block type. + * Check that the consent statement was passed. * - * @see $this->register_block_type() - * @param string $key Data to get, or default to everything. - * @return array|string|null + * @param string $consent_statement - The consent statement string. + * @return true + * @throws \InvalidArgumentException - If the statement does not match the class consent statement string. */ - protected function get_block_type_script($key = null) + private static function check_consent($consent_statement) { } - } -} -namespace Automattic\WooCommerce\Blocks\Utils { - /** - * BlockHooksTrait - * - * Shared functionality for using the Block Hooks API with WooCommerce Blocks. - */ - trait BlockHooksTrait - { /** - * Callback for `hooked_block_types` to auto-inject the mini-cart block into headers after navigation. + * Initialize the shared core config. * - * @param array $hooked_blocks An array of block slugs hooked into a given context. - * @param string $position Position of the block insertion point. - * @param string $anchor_block The block acting as the anchor for the inserted block. - * @param array|\WP_Post|\WP_Block_Template $context Where the block is embedded. - * @since 8.5.0 - * @return array An array of block slugs hooked into a given context. + * @param string $consent_statement - The consent statement string. */ - public function register_hooked_block($hooked_blocks, $position, $anchor_block, $context) + public function initialize_shared_config($consent_statement) { } /** - * Checks if the provided context contains a the block already. + * Initialize interactivity state for cart that is needed by multiple blocks. * - * @param array|\WP_Block_Template $context Where the block is embedded. - * @return boolean + * @param string $consent_statement - The consent statement string. + * @return void */ - protected function has_block_in_content($context) + public function register_cart_interactivity($consent_statement) { } /** - * Given a provided context, returns the content of the context. + * Get core data to include in settings. * - * @param array|\WP_Post|\WP_Block_Template $context Where the block is embedded. - * @since 8.5.0 - * @return string + * @return array */ - protected function get_context_content($context) + private static function get_core_data() { } /** - * Given a provided context, returns whether the context refers to header content. + * Get currency data to include in settings. * - * @param array|\WP_Post|\WP_Block_Template $context Where the block is embedded. - * @param string $area The area to check against before inserting. - * @since 8.5.0 - * @return boolean + * @return array */ - protected function is_template_part_or_pattern($context, $area) + private static function get_currency_data() { } /** - * Given a provided context, returns whether the context refers to the target area and isn't marked as excluded. + * Get locale data to include in settings. * - * @param array|\WP_Post|\WP_Block_Template $context the context to check. - * @param string $area The area to check against before inserting. - * @since 8.5.0 - * @return boolean + * @return array */ - protected function is_target_area($context, $area) + private static function get_locale_data() { } /** - * Returns whether the pattern is excluded or not - * - * @since 8.5.0 + * Add placeholder image. * - * @param array|\WP_Block_Template $context Where the block is embedded. - * @return boolean + * @param string $consent_statement - The consent statement string. */ - protected function pattern_is_excluded($context) + public function placeholder_image($consent_statement) { } } } namespace Automattic\WooCommerce\Blocks\BlockTypes { /** - * CustomerAccount class. + * Mini-Cart class. + * + * @internal */ - class CustomerAccount extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class MiniCart extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { use \Automattic\WooCommerce\Blocks\Utils\BlockHooksTrait; - const TEXT_ONLY = 'text_only'; - const ICON_ONLY = 'icon_only'; - const DISPLAY_ALT = 'alt'; - const DISPLAY_LINE = 'line'; + use \Automattic\WooCommerce\Blocks\Utils\BlocksSharedState; /** * Block name. * * @var string */ - protected $block_name = 'customer-account'; + protected $block_name = 'mini-cart'; /** - * Block Hook API placements. + * Chunks build folder. * - * @var array + * @var string */ - protected $hooked_block_placements = array(array('position' => 'after', 'anchor' => 'core/navigation', 'area' => 'header', 'callback' => 'should_unhook_block', 'version' => '8.4.0')); + protected $chunks_folder = 'mini-cart-contents-block'; /** - * Initialize this block type. + * Array of scripts that will be lazy loaded when interacting with the block. + * + * @var string[] */ - protected function initialize() - { - } + protected $scripts_to_lazy_load = array(); /** - * Callback for the Block Hooks API to modify the attributes of the hooked block. + * Inc Tax label. * - * @param array|null $parsed_hooked_block The parsed block array for the given hooked block type, or null to suppress the block. - * @param string $hooked_block_type The hooked block type name. - * @param string $relative_position The relative position of the hooked block. - * @param array $parsed_anchor_block The anchor block, in parsed block array format. - * @param WP_Block_Template|WP_Post|array $context The block template, template part, `wp_navigation` post type, - * or pattern that the anchor block belongs to. - * @return array|null + * @var string */ - public function modify_hooked_block_attributes($parsed_hooked_block, $hooked_block_type, $relative_position, $parsed_anchor_block, $context) - { - } + protected $tax_label = ''; /** - * Callback for the Block Hooks API to determine if the block should be auto-inserted. - * - * @param array $hooked_blocks An array of block slugs hooked into a given context. - * @param string $position Position of the block insertion point. - * @param string $anchor_block The block acting as the anchor for the inserted block. - * @param array|\WP_Post|\WP_Block_Template $context Where the block is embedded. + * Visibility of price including tax. * - * @return array + * @var string */ - protected function should_unhook_block($hooked_blocks, $position, $anchor_block, $context) - { - } + protected $display_cart_prices_including_tax = false; /** - * Render the block. - * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. + * Block Hook API placements. * - * @return string Rendered block output. + * @var array */ - protected function render($attributes, $content, $block) - { - } + protected $hooked_block_placements = array(array('position' => 'after', 'anchor' => 'core/navigation', 'area' => 'header', 'version' => '8.4.0')); /** - * Gets the icon to render depending on the iconStyle and displayStyle. + * WooCommerce mini-cart template blocks. * - * @param array $attributes Block attributes. + * @var array + */ + const MINI_CART_TEMPLATE_BLOCKS = array('woocommerce/mini-cart-contents', 'woocommerce/filled-mini-cart-contents-block', 'woocommerce/mini-cart-title-block', 'woocommerce/mini-cart-title-label-block', 'woocommerce/mini-cart-title-items-counter-block', 'woocommerce/mini-cart-items-block', 'woocommerce/mini-cart-products-table-block', 'woocommerce/mini-cart-footer-block', 'woocommerce/mini-cart-cart-button-block', 'woocommerce/mini-cart-checkout-button-block', 'woocommerce/empty-mini-cart-contents-block', 'woocommerce/mini-cart-shopping-button-block'); + /** + * Constructor. * - * @return string Label to render on the block + * @param AssetApi $asset_api Instance of the asset API. + * @param AssetDataRegistry $asset_data_registry Instance of the asset data registry. + * @param IntegrationRegistry $integration_registry Instance of the integration registry. */ - private function render_icon($attributes) + public function __construct(\Automattic\WooCommerce\Blocks\Assets\Api $asset_api, \Automattic\WooCommerce\Blocks\Assets\AssetDataRegistry $asset_data_registry, \Automattic\WooCommerce\Blocks\Integrations\IntegrationRegistry $integration_registry) { } /** - * Gets the label to render depending on the displayStyle. + * Initialize this block type. * - * @return string Label to render on the block. + * - Hook into WP lifecycle. + * - Register the block with WordPress. */ - private function render_label() + protected function initialize() { } /** - * Get the frontend script handle for this block type. - * - * @param string $key Data to get, or default to everything. - * - * @return null This block has no frontend script. + * Enable interactivity through Block Supports API. We're using WP_Block_Type_Registry instead + * of get_block_type_supports method available in AbstractBlock as the latter works only for + * blocks without static block.json metadata. */ - protected function get_block_type_script($key = null) + public function enable_interactivity_support() { } - } - /** - * EmailContent class. - */ - class EmailContent extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock - { /** - * Block name. + * Callback for the Block Hooks API to modify the attributes of the hooked block. * - * @var string + * @param array|null $parsed_hooked_block The parsed block array for the given hooked block type, or null to suppress the block. + * @param string $hooked_block_type The hooked block type name. + * @param string $relative_position The relative position of the hooked block. + * @param array $parsed_anchor_block The anchor block, in parsed block array format. + * @param WP_Block_Template|WP_Post|array $context The block template, template part, `wp_navigation` post type, + * or pattern that the anchor block belongs to. + * @return array|null */ - protected $block_name = 'email-content'; + public function modify_hooked_block_attributes($parsed_hooked_block, $hooked_block_type, $relative_position, $parsed_anchor_block, $context) + { + } /** * Get the editor script handle for this block type. * * @param string $key Data to get, or default to everything. - * @return array|string + * @return array|string; */ protected function get_block_type_editor_script($key = null) { @@ -91711,124 +94522,77 @@ protected function get_block_type_editor_script($key = null) /** * Get the frontend script handle for this block type. * + * @see $this->register_block_type() * @param string $key Data to get, or default to everything. + * @return array|string */ protected function get_block_type_script($key = null) { } /** - * Renders Woo content placeholder to be replaced by content during sending. - * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param \WP_Block $block Block instance. - * @return string Rendered block output. - */ - protected function render($attributes, $content, $block) - { - } - } - /** - * EmptyCartBlock class. - */ - class EmptyCartBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock - { - /** - * Block name. - * - * @var string - */ - protected $block_name = 'empty-cart-block'; - } - /** - * EmptyMiniCartContentsBlock class. - */ - class EmptyMiniCartContentsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock - { - /** - * Block name. - * - * @var string - */ - protected $block_name = 'empty-mini-cart-contents-block'; - /** - * Render the markup for the Filled Mini-Cart Contents block. - * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. - */ - protected function render($attributes, $content, $block) - { - } - /** - * Render the experimental interactivity API powered Filled Mini-Cart Contents block. - * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. - */ - protected function render_experimental_empty_mini_cart_contents($attributes, $content, $block) - { - } - } - /** - * FeaturedItem class. - */ - abstract class FeaturedItem extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractDynamicBlock - { - /** - * Block name. + * Get the frontend style handle for this block type. * - * @var string + * @return string[] */ - protected $block_name; + protected function get_block_type_style() + { + } /** - * Default attribute values. + * Extra data passed through from server to client for block. * - * @var array + * @param array $attributes Any attributes that currently are available from the block. + * Note, this will be empty in the editor context when the block is + * not in the post content on editor load. */ - protected $defaults = array('align' => 'none'); + protected function enqueue_data(array $attributes = array()) + { + } /** - * Global style enabled for this block. - * - * @var array + * Prints the variable containing information about the scripts to lazy load. */ - protected $global_style_wrapper = array('background_color', 'border_color', 'border_radius', 'border_width', 'font_size', 'padding', 'text_color', 'extra_classes'); + public function print_lazy_load_scripts() + { + } /** - * Returns the featured item. + * Returns the script data given its handle. * - * @param array $attributes Block attributes. Default empty array. - * @return \WP_Term|\WC_Product|null + * @param string $handle Handle of the script. + * + * @return \_WP_Dependency|null Object containing the script data if found, or null. */ - abstract protected function get_item($attributes); + protected function get_script_from_handle($handle) + { + } /** - * Returns the name of the featured item. + * Recursively appends a scripts and its dependencies into the scripts_to_lazy_load array. * - * @param \WP_Term|\WC_Product $item Item object. - * @return string + * @param \_WP_Dependency $script Object containing script data. */ - abstract protected function get_item_title($item); + protected function append_script_and_deps_src($script) + { + } /** - * Returns the featured item image URL. + * Returns the markup for the cart price. + * + * @param array $attributes Block attributes. * - * @param \WP_Term|\WC_Product $item Item object. - * @param string $size Image size, defaults to 'full'. * @return string */ - abstract protected function get_item_image($item, $size = 'full'); + protected function get_cart_price_markup($attributes) + { + } /** - * Renders the featured item attributes. + * Returns the markup for render the tax label. + * + * @param array $attributes Block attributes. * - * @param \WP_Term|\WC_Product $item Item object. - * @param array $attributes Block attributes. Default empty array. * @return string */ - abstract protected function render_attributes($item, $attributes); + protected function get_include_tax_label_markup($attributes) + { + } /** - * Render the featured item block. + * Render the Mini-Cart block. * * @param array $attributes Block attributes. * @param string $content Block content. @@ -91839,1150 +94603,1148 @@ protected function render($attributes, $content, $block) { } /** - * Returns the url the item's image + * Render an experimental interactivity API powered Mini-Cart block. * - * @param array $attributes Block attributes. Default empty array. - * @param \WP_Term|\WC_Product $item Item object. + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. + */ + protected function render_experimental_iapi_mini_cart($attributes, $content, $block) + { + } + /** + * Echoes the Interactivity API Mini Cart overlay markup. * - * @return string + * @return void */ - private function get_image_url($attributes, $item) + public function render_experimental_iapi_mini_cart_overlay() { } /** - * Renders the featured image as a div background. + * Process template contents to remove unwanted div wrappers. * - * @param array $attributes Block attributes. Default empty array. - * @param string $image_url Item image url. + * The old Mini Cart template had extra divs nested within the block tags + * that are no longer necessary since we don't render the Mini Cart with + * React anymore. To maintain compatibility with user saved templates that + * have these wrapper divs, we must remove them. * - * @return string + * @param string $template_contents The template contents to process. + * @return string The processed template contents. */ - private function render_bg_image($attributes, $image_url) + protected function process_template_contents($template_contents) { } /** - * Get the styles for the wrapper element (background image, color). - * - * @param array $attributes Block attributes. Default empty array. - * @param string $image_url Item image url. + * Get the mini cart template part contents to render inside the drawer. * - * @return string + * @param bool $do_blocks Whether to apply do_blocks() to the template part contents. + * @return string The contents of the template part. */ - public function get_bg_styles($attributes, $image_url) + protected function get_template_part_contents($do_blocks = true) { } /** - * Renders the featured image + * Render the markup for the Mini-Cart block. * - * @param array $attributes Block attributes. Default empty array. - * @param \WC_Product|\WP_Term $item Item object. - * @param string $image_url Item image url. + * @param array $attributes Block attributes. * - * @return string + * @return string The HTML markup. */ - private function render_image($attributes, $item, string $image_url) + protected function get_markup($attributes) { } /** - * Get the styles for the wrapper element (background image, color). + * Return the main instance of WC_Cart class. * - * @param array $attributes Block attributes. Default empty array. - * @return string + * @return \WC_Cart CartController class instance. */ - public function get_styles($attributes) + protected function get_cart_instance() { } /** - * Get class names for the block container. + * Get array with data for handle the tax label. + * the entire logic of this function is was taken from: + * https://github.com/woocommerce/woocommerce/blob/e730f7463c25b50258e97bf56e31e9d7d3bc7ae7/includes/class-wc-cart.php#L1582 * - * @param array $attributes Block attributes. Default empty array. - * @return string + * @return array; */ - public function get_classes($attributes) + protected function get_tax_label() { } /** - * Renders the block overlay - * - * @param array $attributes Block attributes. Default empty array. - * - * @return string + * Prepare translations for inner blocks and dependencies. */ - private function render_overlay($attributes) + protected function get_inner_blocks_translations() { } /** - * Returns whether the focal point is defined for the block. - * - * @param array $attributes Block attributes. Default empty array. - * - * @return bool + * Register block pattern for Empty Cart Message to make it translatable. */ - private function hasFocalPoint($attributes): bool + public function register_empty_cart_message_block_pattern() { } /** - * Extra data passed through from server to client for block. + * Returns whether the Mini-Cart should be rendered or not. * - * @param array $attributes Any attributes that currently are available from the block. - * Note, this will be empty in the editor context when the block is - * not in the post content on editor load. + * @param array $attributes Block attributes. + * + * @return bool */ - protected function enqueue_data(array $attributes = []) + public function should_not_render_mini_cart(array $attributes) { } } /** - * FeaturedCategory class. + * MiniCartCartButtonBlock class. */ - class FeaturedCategory extends \Automattic\WooCommerce\Blocks\BlockTypes\FeaturedItem + class MiniCartCartButtonBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock { /** * Block name. * * @var string */ - protected $block_name = 'featured-category'; + protected $block_name = 'mini-cart-cart-button-block'; /** - * Get block attributes. + * Render experimental iAPI block markup. * - * @return array + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - protected function get_block_type_attributes() + protected function render_experimental_iapi_markup($attributes, $content, $block) { } /** - * Returns the featured category. + * Render the markup for the Mini-Cart Contents block. * - * @param array $attributes Block attributes. Default empty array. - * @return \WP_Term|null + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - protected function get_item($attributes) + protected function render($attributes, $content, $block) { } + } + /** + * MiniCartCheckoutButtonBlock class. + */ + class MiniCartCheckoutButtonBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + { /** - * Returns the name of the featured category. + * Block name. * - * @param \WP_Term $category Featured category. - * @return string + * @var string */ - protected function get_item_title($category) - { - } + protected $block_name = 'mini-cart-checkout-button-block'; /** - * Returns the featured category image URL. + * Render experimental iAPI block markup. * - * @param \WP_Term $category Term object. - * @param string $size Image size, defaults to 'full'. - * @return string + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - protected function get_item_image($category, $size = 'full') + protected function render_experimental_iapi_markup($attributes, $content, $block) { } /** - * Renders the featured category attributes. + * Render the markup for the Mini-Cart Contents block. * - * @param \WP_Term $category Term object. - * @param array $attributes Block attributes. Default empty array. - * @return string + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - protected function render_attributes($category, $attributes) + protected function render($attributes, $content, $block) { } } /** - * FeaturedProduct class. + * Mini-Cart Contents class. + * + * @internal */ - class FeaturedProduct extends \Automattic\WooCommerce\Blocks\BlockTypes\FeaturedItem + class MiniCartContents extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { /** * Block name. * * @var string */ - protected $block_name = 'featured-product'; + protected $block_name = 'mini-cart-contents'; /** - * Returns the featured product. + * Get the editor script handle for this block type. * - * @param array $attributes Block attributes. Default empty array. - * @return \WP_Term|null - */ - protected function get_item($attributes) - { - } - /** - * Returns the name of the featured product. + * @param string $key Data to get, or default to everything. * - * @param \WC_Product $product Product object. - * @return string + * @return array|string; */ - protected function get_item_title($product) + protected function get_block_type_editor_script($key = null) { } /** - * Returns the featured product image URL. + * Get the frontend script handle for this block type. * - * @param \WC_Product $product Product object. - * @param string $size Image size, defaults to 'full'. - * @return string + * @param string $key Data to get, or default to everything. + * + * @return null */ - protected function get_item_image($product, $size = 'full') + protected function get_block_type_script($key = null) { } /** - * Renders the featured product attributes. + * Get the frontend style handle for this block type. * - * @param \WC_Product $product Product object. - * @param array $attributes Block attributes. Default empty array. - * @return string + * @return string[] */ - protected function render_attributes($product, $attributes) + protected function get_block_type_style() { } - } - /** - * FilledCartBlock class. - */ - class FilledCartBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock - { - /** - * Block name. - * - * @var string - */ - protected $block_name = 'filled-cart-block'; - } - /** - * FilledMiniCartContentsBlock class. - */ - class FilledMiniCartContentsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock - { - /** - * Block name. - * - * @var string - */ - protected $block_name = 'filled-mini-cart-contents-block'; /** - * Render the markup for the Filled Mini-Cart Contents block. + * Render experimental iAPI powered Mini-Cart Contents block. * * @param array $attributes Block attributes. * @param string $content Block content. * @param WP_Block $block Block instance. * @return string Rendered block type output. */ - protected function render($attributes, $content, $block) + protected function render_experimental_iapi_mini_cart_contents($attributes, $content, $block) { } /** - * Render the experimental interactivity API powered Filled Mini-Cart Contents block. + * Render the markup for the Mini-Cart Contents block. * * @param array $attributes Block attributes. * @param string $content Block content. * @param WP_Block $block Block instance. * @return string Rendered block type output. */ - protected function render_experimental_filled_mini_cart_contents($attributes, $content, $block) + protected function render($attributes, $content, $block) { } - } - /** - * FilterWrapper class. - */ - class FilterWrapper extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock - { /** - * Block name. + * Enqueue frontend assets for this block, just in time for rendering. * - * @var string + * @param array $attributes Any attributes that currently are available from the block. + * @param string $content The block content. + * @param WP_Block $block The block object. */ - protected $block_name = 'filter-wrapper'; + protected function enqueue_assets(array $attributes, $content, $block) + { + } /** - * Get the frontend style handle for this block type. + * Get list of Mini-Cart Contents block & its inner-block types. * - * @return null + * @return array; */ - protected function get_block_type_style() + public static function get_mini_cart_block_types() { } } /** - * HandpickedProducts class. + * MiniCartFooterBlock class. */ - class HandpickedProducts extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractProductGrid + class MiniCartFooterBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock { /** * Block name. * * @var string */ - protected $block_name = 'handpicked-products'; + protected $block_name = 'mini-cart-footer-block'; /** - * Set args specific to this block + * Render experimental iAPI powered Mini-Cart Footer block. * - * @param array $query_args Query args. + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - protected function set_block_query_args(&$query_args) + protected function render_experimental_iapi_mini_cart_footer($attributes, $content, $block) { } /** - * Set visibility query args. Handpicked products will show hidden products if chosen. + * Return the main instance of WC_Cart class. * - * @param array $query_args Query args. + * @return \WC_Cart CartController class instance. */ - protected function set_visibility_query_args(&$query_args) + protected function get_cart_instance() { } /** - * Get block attributes. + * Render the markup for the Mini-Cart Contents block. * - * @return array + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - protected function get_block_type_attributes() + protected function render($attributes, $content, $block) { } } -} -namespace Automattic\WooCommerce\Blocks\Utils { /** - * Manages the registration of interactivity config and state that is commonly shared by WooCommerce blocks. - * Initialization only happens on the first call to initialize_shared_config. - * Intended to be used as a singleton. + * MiniCartItemsBlock class. */ - trait BlocksSharedState + class MiniCartItemsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock { /** - * The consent statement for using private APIs of this class. - * - * @var string - */ - private static $consent_statement = 'I acknowledge that using private APIs means my theme or plugin will inevitably break in the next version of WooCommerce'; - /** - * The namespace for the config. + * Block name. * * @var string */ - private static $settings_namespace = 'woocommerce'; - /** - * Whether the core config has been registered. - * - * @var boolean - */ - private static $core_config_registered = false; - /** - * Cart state. - * - * @var mixed - */ - private static $blocks_shared_cart_state; - /** - * Prevent caching on certain pages - */ - private static function prevent_cache() - { - } + protected $block_name = 'mini-cart-items-block'; /** - * Check that the consent statement was passed. + * Render the markup for the Mini-Cart Contents block. * - * @param string $consent_statement - The consent statement string. - * @return true - * @throws \InvalidArgumentException - If the statement does not match the class consent statement string. + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - private static function check_consent($consent_statement) + protected function render($attributes, $content, $block) { } /** - * Initialize the shared core config. + * Render experimental iAPI block markup. * - * @param string $consent_statement - The consent statement string. + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - public function initialize_shared_config($consent_statement) + protected function render_experimental_iapi_markup($attributes, $content, $block) { } + } + /** + * MiniCartProductsTableBlock class. + */ + class MiniCartProductsTableBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + { /** - * Initialize interactivity state for cart that is needed by multiple blocks. + * Block name. * - * @param string $consent_statement - The consent statement string. - * @return void + * @var string */ - public function register_cart_interactivity($consent_statement) - { - } + protected $block_name = 'mini-cart-products-table-block'; /** - * Get core data to include in settings. + * Render the markup for the Mini-Cart Products Table block. * - * @return array + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - private static function get_core_data() + protected function render($attributes, $content, $block) { } /** - * Get currency data to include in settings. + * Render experimental iAPI block markup. * - * @return array + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - private static function get_currency_data() + protected function render_experimental_iapi_markup($attributes, $content, $block) { } /** - * Get locale data to include in settings. + * Render markup for product details. * - * @return array + * @param string $property The property to render in the product details markup. + * @return string Rendered product details output. */ - private static function get_locale_data() + protected function render_experimental_iapi_product_details_markup($property) { } /** - * Add placeholder image. + * Render markup for a single product detail item. * - * @param string $consent_statement - The consent statement string. + * @param string $tag_name The HTML tag to use for the item. + * @return string Rendered product detail item output. */ - public function placeholder_image($consent_statement) + private function render_experimental_iapi_product_details_item_markup($tag_name) { } } -} -namespace Automattic\WooCommerce\Blocks\BlockTypes { /** - * Mini-Cart class. - * - * @internal + * MiniCartShoppingButtonBlock class. */ - class MiniCart extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class MiniCartShoppingButtonBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock { - use \Automattic\WooCommerce\Blocks\Utils\BlockHooksTrait; - use \Automattic\WooCommerce\Blocks\Utils\BlocksSharedState; /** * Block name. * * @var string */ - protected $block_name = 'mini-cart'; - /** - * Chunks build folder. - * - * @var string - */ - protected $chunks_folder = 'mini-cart-contents-block'; + protected $block_name = 'mini-cart-shopping-button-block'; /** - * Array of scripts that will be lazy loaded when interacting with the block. + * Render the markup for the Mini-Cart Shopping Button block. * - * @var string[] + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - protected $scripts_to_lazy_load = array(); + protected function render($attributes, $content, $block) + { + } /** - * Inc Tax label. + * Render experimental iAPI powered markup for the Mini-Cart Contents block. * - * @var string + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - protected $tax_label = ''; + protected function render_experimental_iapi_markup($attributes, $content, $block) + { + } + } + /** + * MiniCartTitleBlock class. + */ + class MiniCartTitleBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + { /** - * Visibility of price including tax. + * Block name. * * @var string */ - protected $display_cart_prices_including_tax = false; - /** - * Block Hook API placements. - * - * @var array - */ - protected $hooked_block_placements = array(array('position' => 'after', 'anchor' => 'core/navigation', 'area' => 'header', 'version' => '8.4.0')); - /** - * WooCommerce mini-cart template blocks. - * - * @var array - */ - const MINI_CART_TEMPLATE_BLOCKS = array('woocommerce/mini-cart-contents', 'woocommerce/filled-mini-cart-contents-block', 'woocommerce/mini-cart-title-block', 'woocommerce/mini-cart-title-label-block', 'woocommerce/mini-cart-title-items-counter-block', 'woocommerce/mini-cart-items-block', 'woocommerce/mini-cart-products-table-block', 'woocommerce/mini-cart-footer-block', 'woocommerce/mini-cart-cart-button-block', 'woocommerce/mini-cart-checkout-button-block', 'woocommerce/empty-mini-cart-contents-block', 'woocommerce/mini-cart-shopping-button-block'); + protected $block_name = 'mini-cart-title-block'; /** - * Constructor. + * Render the block. * - * @param AssetApi $asset_api Instance of the asset API. - * @param AssetDataRegistry $asset_data_registry Instance of the asset data registry. - * @param IntegrationRegistry $integration_registry Instance of the integration registry. + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - public function __construct(\Automattic\WooCommerce\Blocks\Assets\Api $asset_api, \Automattic\WooCommerce\Blocks\Assets\AssetDataRegistry $asset_data_registry, \Automattic\WooCommerce\Blocks\Integrations\IntegrationRegistry $integration_registry) + protected function render($attributes, $content, $block) { } /** - * Initialize this block type. + * Render the interactivity API powered experimental title block. * - * - Hook into WP lifecycle. - * - Register the block with WordPress. + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - protected function initialize() + protected function render_experimental_iapi_title_block($attributes, $content, $block) { } + } + /** + * MiniCartTitleItemsCounterBlock class. + */ + class MiniCartTitleItemsCounterBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + { /** - * Enable interactivity through Block Supports API. We're using WP_Block_Type_Registry instead - * of get_block_type_supports method available in AbstractBlock as the latter works only for - * blocks without static block.json metadata. + * Block name. + * + * @var string */ - public function enable_interactivity_support() - { - } + protected $block_name = 'mini-cart-title-items-counter-block'; /** - * Callback for the Block Hooks API to modify the attributes of the hooked block. + * Render the block. * - * @param array|null $parsed_hooked_block The parsed block array for the given hooked block type, or null to suppress the block. - * @param string $hooked_block_type The hooked block type name. - * @param string $relative_position The relative position of the hooked block. - * @param array $parsed_anchor_block The anchor block, in parsed block array format. - * @param WP_Block_Template|WP_Post|array $context The block template, template part, `wp_navigation` post type, - * or pattern that the anchor block belongs to. - * @return array|null + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - public function modify_hooked_block_attributes($parsed_hooked_block, $hooked_block_type, $relative_position, $parsed_anchor_block, $context) + protected function render($attributes, $content, $block) { } /** - * Get the editor script handle for this block type. + * Render the interactivity API powered experimental title block. * - * @param string $key Data to get, or default to everything. - * @return array|string; + * @return string Rendered block type output. */ - protected function get_block_type_editor_script($key = null) + protected function render_experimental_iapi_title_label_block() { } /** - * Get the frontend script handle for this block type. + * Return the main instance of WC_Cart class. * - * @see $this->register_block_type() - * @param string $key Data to get, or default to everything. - * @return array|string + * @return \WC_Cart CartController class instance. */ - protected function get_block_type_script($key = null) + protected function get_cart_instance() { } + } + /** + * MiniCartTitleLabelBlock class. + */ + class MiniCartTitleLabelBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + { /** - * Get the frontend style handle for this block type. + * Block name. * - * @return string[] + * @var string */ - protected function get_block_type_style() - { - } + protected $block_name = 'mini-cart-title-label-block'; /** - * Extra data passed through from server to client for block. + * Render the block. * - * @param array $attributes Any attributes that currently are available from the block. - * Note, this will be empty in the editor context when the block is - * not in the post content on editor load. + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - protected function enqueue_data(array $attributes = array()) + protected function render($attributes, $content, $block) { } /** - * Prints the variable containing information about the scripts to lazy load. + * Render the interactivity API powered experimental title block. + * + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - public function print_lazy_load_scripts() + protected function render_experimental_iapi_title_label_block($attributes, $content, $block) { } + } + /** + * ProductGalleryLargeImage class. + */ + class NextPreviousButtons extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + { + use \Automattic\WooCommerce\Blocks\BlockTypes\EnableBlockJsonAssetsTrait; /** - * Returns the script data given its handle. + * Block name. Block has been initially created for Product Gallery Large Image block + * hence the slug is related to this block. But it can be used for other blocks as well. * - * @param string $handle Handle of the script. + * @var string + */ + protected $block_name = 'product-gallery-large-image-next-previous'; + /** + * Include and render the block. * - * @return \_WP_Dependency|null Object containing the script data if found, or null. + * @param array $attributes Block attributes. Default empty array. + * @param string $content Block content. Default empty string. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - protected function get_script_from_handle($handle) + protected function render($attributes, $content, $block) { } + } +} +namespace Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation { + /** + * AbstractOrderConfirmationBlock class. + */ + abstract class AbstractOrderConfirmationBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + { /** - * Recursively appends a scripts and its dependencies into the scripts_to_lazy_load array. + * Get the content from a hook and return it. * - * @param \_WP_Dependency $script Object containing script data. + * @param string $hook Hook name. + * @param array $args Array of args to pass to the hook. + * @return string */ - protected function append_script_and_deps_src($script) + protected function get_hook_content($hook, $args) { } /** - * Returns the markup for the cart price. + * Render the block. * - * @param array $attributes Block attributes. + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. * - * @return string + * @return string | void Rendered block output. */ - protected function get_cart_price_markup($attributes) + protected function render($attributes, $content, $block) { } /** - * Returns the markup for render the tax label. + * This renders the content of the block within the wrapper. The permission determines what data can be shown under + * the given context. * - * @param array $attributes Block attributes. + * @param \WC_Order $order Order object. + * @param string|false $permission If the current user can view the order details or not. + * @param array $attributes Block attributes. + * @param string $content Original block content. + * @return string + */ + abstract protected function render_content($order, $permission = false, $attributes = [], $content = ''); + /** + * This is what gets rendered when the order does not exist. Renders nothing by default, but can be overridden by + * child classes. * * @return string */ - protected function get_include_tax_label_markup($attributes) + protected function render_content_fallback() { } /** - * Render the Mini-Cart block. + * Get current order. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @return \WC_Order|null */ - protected function render($attributes, $content, $block) + protected function get_order() { } /** - * Render an experimental interactivity API powered Mini-Cart block. + * View mode for order details based on the order, current user, and settings. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @param \WC_Order|null $order Order object. + * @return string|false Returns "full" if the user can view all order details. False if they can view no details. */ - protected function render_experimental_iapi_mini_cart($attributes, $content, $block) + protected function get_view_order_permissions($order) { } /** - * Echoes the Interactivity API Mini Cart overlay markup. + * See if guest checkout is enabled. * - * @return void + * @return boolean */ - public function render_experimental_iapi_mini_cart_overlay() + protected function allow_guest_checkout() { } /** - * Process template contents to remove unwanted div wrappers. - * - * The old Mini Cart template had extra divs nested within the block tags - * that are no longer necessary since we don't render the Mini Cart with - * React anymore. To maintain compatibility with user saved templates that - * have these wrapper divs, we must remove them. + * Guest users without an active session can provide their email address to view order details. This however can only + * be permitted if the user also provided the correct order key, and guest checkout is actually enabled. * - * @param string $template_contents The template contents to process. - * @return string The processed template contents. + * @param \WC_Order $order Order object. + * @return boolean */ - protected function process_template_contents($template_contents) + protected function email_verification_permitted($order) { } /** - * Get the mini cart template part contents to render inside the drawer. + * See if the order was created within the grace period for viewing details. * - * @param bool $do_blocks Whether to apply do_blocks() to the template part contents. - * @return string The contents of the template part. + * @param \WC_Order $order Order object. + * @return boolean */ - protected function get_template_part_contents($do_blocks = true) + protected function is_within_grace_period($order) { } /** - * Render the markup for the Mini-Cart block. + * Returns true if the email has been verified (posted email matches given order email). * - * @param array $attributes Block attributes. + * @param \WC_Order $order Order object. + * @return boolean + */ + protected function is_email_verified($order) + { + } + /** + * See if we need to verify the email address before showing the order details. * - * @return string The HTML markup. + * @param \WC_Order $order Order object. + * @return boolean */ - protected function get_markup($attributes) + protected function email_verification_required($order) { } /** - * Return the main instance of WC_Cart class. + * See if the order key is valid. * - * @return \WC_Cart CartController class instance. + * @param \WC_Order $order Order object. + * @return boolean */ - protected function get_cart_instance() + protected function has_valid_order_key($order) { } /** - * Get array with data for handle the tax label. - * the entire logic of this function is was taken from: - * https://github.com/woocommerce/woocommerce/blob/e730f7463c25b50258e97bf56e31e9d7d3bc7ae7/includes/class-wc-cart.php#L1582 + * See if the current order came from a guest or a logged in customer. * - * @return array; + * @param \WC_Order $order Order object. + * @return boolean */ - protected function get_tax_label() + protected function is_customer_order($order) { } /** - * Prepare translations for inner blocks and dependencies. + * See if the current logged in user ID matches the given order customer ID. + * + * Returns false for logged-out customers. + * + * @param \WC_Order $order Order object. + * @return boolean */ - protected function get_inner_blocks_translations() + protected function is_current_customer_order($order) { } /** - * Register block pattern for Empty Cart Message to make it translatable. + * Get the frontend script handle for this block type. + * + * @param string $key Data to get, or default to everything. */ - public function register_empty_cart_message_block_pattern() + protected function get_block_type_script($key = null) { } /** - * Returns whether the Mini-Cart should be rendered or not. + * Render custom fields for the order. * - * @param array $attributes Block attributes. + * @param array $fields List of additional fields with values. + * @return string + */ + protected function render_additional_fields($fields) + { + } + /** + * Render custom field row. * - * @return bool + * @param array $field An additional field and value. + * @return string */ - public function should_not_render_mini_cart(array $attributes) + protected function render_additional_field($field) { } } /** - * MiniCartCartButtonBlock class. + * AdditionalFields class. */ - class MiniCartCartButtonBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + class AdditionalFields extends \Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation\AbstractOrderConfirmationBlock { /** * Block name. * * @var string */ - protected $block_name = 'mini-cart-cart-button-block'; - /** - * Render experimental iAPI block markup. - * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. - */ - protected function render_experimental_iapi_markup($attributes, $content, $block) - { - } + protected $block_name = 'order-confirmation-additional-fields'; /** - * Render the markup for the Mini-Cart Contents block. + * This renders the content of the block within the wrapper. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @param \WC_Order $order Order object. + * @param string|false $permission If the current user can view the order details or not. + * @param array $attributes Block attributes. + * @param string $content Original block content. + * @return string */ - protected function render($attributes, $content, $block) + protected function render_content($order, $permission = false, $attributes = [], $content = '') { } } /** - * MiniCartCheckoutButtonBlock class. + * AdditionalFieldsWrapper class. */ - class MiniCartCheckoutButtonBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + class AdditionalFieldsWrapper extends \Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation\AbstractOrderConfirmationBlock { /** * Block name. * * @var string */ - protected $block_name = 'mini-cart-checkout-button-block'; + protected $block_name = 'order-confirmation-additional-fields-wrapper'; /** - * Render experimental iAPI block markup. + * This renders the content of the downloads wrapper. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @param \WC_Order $order Order object. + * @param string|false $permission If the current user can view the order details or not. + * @param array $attributes Block attributes. + * @param string $content Original block content. */ - protected function render_experimental_iapi_markup($attributes, $content, $block) + protected function render_content($order, $permission = false, $attributes = [], $content = '') { } /** - * Render the markup for the Mini-Cart Contents block. + * Extra data passed through from server to client for block. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @param array $attributes Any attributes that currently are available from the block. + * Note, this will be empty in the editor context when the block is + * not in the post content on editor load. */ - protected function render($attributes, $content, $block) + protected function enqueue_data(array $attributes = []) { } } /** - * Mini-Cart Contents class. - * - * @internal + * AdditionalInformation class. */ - class MiniCartContents extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class AdditionalInformation extends \Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation\AbstractOrderConfirmationBlock { /** * Block name. * * @var string */ - protected $block_name = 'mini-cart-contents'; - /** - * Get the editor script handle for this block type. - * - * @param string $key Data to get, or default to everything. - * - * @return array|string; - */ - protected function get_block_type_editor_script($key = null) - { - } + protected $block_name = 'order-confirmation-additional-information'; /** - * Get the frontend script handle for this block type. - * - * @param string $key Data to get, or default to everything. + * This renders the content of the block within the wrapper. * - * @return null + * @param \WC_Order $order Order object. + * @param string|false $permission If the current user can view the order details or not. + * @param array $attributes Block attributes. + * @param string $content Original block content. + * @return string */ - protected function get_block_type_script($key = null) + protected function render_content($order, $permission = false, $attributes = [], $content = '') { } /** - * Get the frontend style handle for this block type. - * - * @return string[] + * Remove core hooks from the thankyou page. */ - protected function get_block_type_style() + protected function remove_core_hooks() { } /** - * Render experimental iAPI powered Mini-Cart Contents block. - * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * Restore core hooks from the thankyou page. */ - protected function render_experimental_iapi_mini_cart_contents($attributes, $content, $block) + protected function restore_core_hooks() { } + } + /** + * BillingAddress class. + */ + class BillingAddress extends \Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation\AbstractOrderConfirmationBlock + { /** - * Render the markup for the Mini-Cart Contents block. + * Block name. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @var string */ - protected function render($attributes, $content, $block) - { - } + protected $block_name = 'order-confirmation-billing-address'; /** - * Enqueue frontend assets for this block, just in time for rendering. + * This renders the content of the block within the wrapper. * - * @param array $attributes Any attributes that currently are available from the block. - * @param string $content The block content. - * @param WP_Block $block The block object. + * @param \WC_Order $order Order object. + * @param string|false $permission If the current user can view the order details or not. + * @param array $attributes Block attributes. + * @param string $content Original block content. + * @return string */ - protected function enqueue_assets(array $attributes, $content, $block) + protected function render_content($order, $permission = false, $attributes = [], $content = '') { } /** - * Get list of Mini-Cart Contents block & its inner-block types. + * Extra data passed through from server to client for block. * - * @return array; + * @param array $attributes Any attributes that currently are available from the block. + * Note, this will be empty in the editor context when the block is + * not in the post content on editor load. */ - public static function get_mini_cart_block_types() + protected function enqueue_data(array $attributes = []) { } } /** - * MiniCartFooterBlock class. + * BillingWrapper class. */ - class MiniCartFooterBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + class BillingWrapper extends \Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation\AbstractOrderConfirmationBlock { /** * Block name. * * @var string */ - protected $block_name = 'mini-cart-footer-block'; - /** - * Render experimental iAPI powered Mini-Cart Footer block. - * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. - */ - protected function render_experimental_iapi_mini_cart_footer($attributes, $content, $block) - { - } + protected $block_name = 'order-confirmation-billing-wrapper'; /** - * Return the main instance of WC_Cart class. + * This renders the content of the billing wrapper. * - * @return \WC_Cart CartController class instance. + * @param \WC_Order $order Order object. + * @param string|false $permission If the current user can view the order details or not. + * @param array $attributes Block attributes. + * @param string $content Original block content. */ - protected function get_cart_instance() + protected function render_content($order, $permission = false, $attributes = [], $content = '') { } /** - * Render the markup for the Mini-Cart Contents block. + * Get the frontend style handle for this block type. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @return null */ - protected function render($attributes, $content, $block) + protected function get_block_type_style() { } } /** - * MiniCartItemsBlock class. + * CreateAccount class. */ - class MiniCartItemsBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + class CreateAccount extends \Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation\AbstractOrderConfirmationBlock { /** * Block name. * * @var string */ - protected $block_name = 'mini-cart-items-block'; + protected $block_name = 'order-confirmation-create-account'; /** - * Render the markup for the Mini-Cart Contents block. + * Initialize this block type. + */ + protected function initialize() + { + } + /** + * Initialize hooks. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @see https://developer.wordpress.org/reference/hooks/hooked_block/ */ - protected function render($attributes, $content, $block) + protected function initialize_hooks() { } /** - * Render experimental iAPI block markup. + * Get the frontend script handle for this block type. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @see $this->register_block_type() + * @param string $key Data to get, or default to everything. + * @return array|string */ - protected function render_experimental_iapi_markup($attributes, $content, $block) + protected function get_block_type_script($key = null) { } - } - /** - * MiniCartProductsTableBlock class. - */ - class MiniCartProductsTableBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock - { /** - * Block name. + * Returns if delayed account creation is enabled. * - * @var string + * @return bool */ - protected $block_name = 'mini-cart-products-table-block'; + protected function is_feature_enabled() + { + } /** - * Render the markup for the Mini-Cart Products Table block. + * Process posted account form. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @param \WC_Order $order Order object. + * @return \WP_Error|int */ - protected function render($attributes, $content, $block) + protected function process_form_post($order) { } /** - * Render experimental iAPI block markup. + * This renders the content of the block within the wrapper. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @param \WC_Order $order Order object. + * @param string|false $permission If the current user can view the order details or not. + * @param array $attributes Block attributes. + * @param string $content Original block content. + * @return string */ - protected function render_experimental_iapi_markup($attributes, $content, $block) + protected function render_content($order, $permission = false, $attributes = [], $content = '') { } /** - * Render markup for product details. + * Render the block when an account has been registered. * - * @param string $property The property to render in the product details markup. - * @return string Rendered product details output. + * @return string */ - protected function render_experimental_iapi_product_details_markup($property) + protected function render_confirmation() { } /** - * Render markup for a single product detail item. + * Extra data passed through from server to client for block. * - * @param string $tag_name The HTML tag to use for the item. - * @return string Rendered product detail item output. + * @param array $attributes Any attributes that currently are available from the block. + * Note, this will be empty in the editor context when the block is + * not in the post content on editor load. */ - private function render_experimental_iapi_product_details_item_markup($tag_name) + protected function enqueue_data(array $attributes = []) { } } /** - * MiniCartShoppingButtonBlock class. + * Downloads class. */ - class MiniCartShoppingButtonBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + class Downloads extends \Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation\AbstractOrderConfirmationBlock { /** * Block name. * * @var string */ - protected $block_name = 'mini-cart-shopping-button-block'; + protected $block_name = 'order-confirmation-downloads'; /** - * Render the markup for the Mini-Cart Shopping Button block. + * This renders the content of the block within the wrapper. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @param \WC_Order $order Order object. + * @param string|false $permission If the current user can view the order details or not. + * @param array $attributes Block attributes. + * @param string $content Original block content. + * @return string */ - protected function render($attributes, $content, $block) + protected function render_content($order, $permission = false, $attributes = [], $content = '') { } /** - * Render experimental iAPI powered markup for the Mini-Cart Contents block. + * Enqueue frontend assets for this block, just in time for rendering. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @param array $attributes Any attributes that currently are available from the block. + * @return string */ - protected function render_experimental_iapi_markup($attributes, $content, $block) + protected function get_inline_styles(array $attributes) { } - } - /** - * MiniCartTitleBlock class. - */ - class MiniCartTitleBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock - { /** - * Block name. + * Enqueue frontend assets for this block, just in time for rendering. * - * @var string + * @param array $attributes Any attributes that currently are available from the block. + * @param string $content The block content. + * @param \WP_Block $block The block object. */ - protected $block_name = 'mini-cart-title-block'; + protected function enqueue_assets(array $attributes, $content, $block) + { + } /** - * Render the block. + * Render column headers for downloads table. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @return string */ - protected function render($attributes, $content, $block) + protected function render_order_downloads_column_headers() { } /** - * Render the interactivity API powered experimental title block. + * Render downloads. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @param \WC_Order $order Order object. + * @param array $downloads Array of downloads. + * @return string */ - protected function render_experimental_iapi_title_block($attributes, $content, $block) + protected function render_order_downloads($order, $downloads) + { + } + /** + * Render a download row in the table. + * + * @param array $download Download data. + * @return string + */ + protected function render_order_download_row($download) { } } /** - * MiniCartTitleItemsCounterBlock class. + * DownloadsWrapper class. */ - class MiniCartTitleItemsCounterBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + class DownloadsWrapper extends \Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation\AbstractOrderConfirmationBlock { /** * Block name. * * @var string */ - protected $block_name = 'mini-cart-title-items-counter-block'; + protected $block_name = 'order-confirmation-downloads-wrapper'; /** - * Render the block. + * See if the store has a downloadable product. This controls if we bother to show a preview in the editor. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @return boolean */ - protected function render($attributes, $content, $block) + protected function store_has_downloadable_products() { } /** - * Render the interactivity API powered experimental title block. + * Extra data passed through from server to client for block. * - * @return string Rendered block type output. + * @param array $attributes Any attributes that currently are available from the block. + * Note, this will be empty in the editor context when the block is + * not in the post content on editor load. */ - protected function render_experimental_iapi_title_label_block() + protected function enqueue_data(array $attributes = []) { } /** - * Return the main instance of WC_Cart class. + * This renders the content of the downloads wrapper. * - * @return \WC_Cart CartController class instance. + * @param \WC_Order $order Order object. + * @param string|false $permission If the current user can view the order details or not. + * @param array $attributes Block attributes. + * @param string $content Original block content. */ - protected function get_cart_instance() + protected function render_content($order, $permission = false, $attributes = [], $content = '') + { + } + /** + * Get the frontend style handle for this block type. + * + * @return null + */ + protected function get_block_type_style() { } } /** - * MiniCartTitleLabelBlock class. + * ShippingAddress class. */ - class MiniCartTitleLabelBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock + class ShippingAddress extends \Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation\AbstractOrderConfirmationBlock { /** * Block name. * * @var string */ - protected $block_name = 'mini-cart-title-label-block'; + protected $block_name = 'order-confirmation-shipping-address'; /** - * Render the block. + * This renders the content of the block within the wrapper. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @param \WC_Order $order Order object. + * @param string|false $permission If the current user can view the order details or not. + * @param array $attributes Block attributes. + * @param string $content Original block content. + * @return string */ - protected function render($attributes, $content, $block) + protected function render_content($order, $permission = false, $attributes = [], $content = '') { } /** - * Render the interactivity API powered experimental title block. + * Extra data passed through from server to client for block. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @param array $attributes Any attributes that currently are available from the block. + * Note, this will be empty in the editor context when the block is + * not in the post content on editor load. */ - protected function render_experimental_iapi_title_label_block($attributes, $content, $block) + protected function enqueue_data(array $attributes = []) { } } /** - * ProductGalleryLargeImage class. + * ShippingWrapper class. */ - class NextPreviousButtons extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class ShippingWrapper extends \Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation\AbstractOrderConfirmationBlock { - use \Automattic\WooCommerce\Blocks\BlockTypes\EnableBlockJsonAssetsTrait; /** - * Block name. Block has been initially created for Product Gallery Large Image block - * hence the slug is related to this block. But it can be used for other blocks as well. + * Block name. * * @var string */ - protected $block_name = 'product-gallery-large-image-next-previous'; + protected $block_name = 'order-confirmation-shipping-wrapper'; /** - * Include and render the block. + * This renders the content of the shipping wrapper. * - * @param array $attributes Block attributes. Default empty array. - * @param string $content Block content. Default empty string. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @param \WC_Order $order Order object. + * @param string|false $permission If the current user can view the order details or not. + * @param array $attributes Block attributes. + * @param string $content Original block content. */ - protected function render($attributes, $content, $block) + protected function render_content($order, $permission = false, $attributes = [], $content = '') + { + } + /** + * Get the frontend style handle for this block type. + * + * @return null + */ + protected function get_block_type_style() { } } -} -namespace Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation { /** - * AbstractOrderConfirmationBlock class. + * Status class. */ - abstract class AbstractOrderConfirmationBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class Status extends \Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation\AbstractOrderConfirmationBlock { /** - * Get the content from a hook and return it. + * Block name. * - * @param string $hook Hook name. - * @param array $args Array of args to pass to the hook. - * @return string + * @var string */ - protected function get_hook_content($hook, $args) - { - } + protected $block_name = 'order-confirmation-status'; /** - * Render the block. + * This block uses a custom render method so that the email verification form can be appended to the block. This does + * not inherit styles from the parent block. * * @param array $attributes Block attributes. * @param string $content Block content. @@ -92994,8 +95756,7 @@ protected function render($attributes, $content, $block) { } /** - * This renders the content of the block within the wrapper. The permission determines what data can be shown under - * the given context. + * This renders the content of the block within the wrapper. * * @param \WC_Order $order Order object. * @param string|false $permission If the current user can view the order details or not. @@ -93003,10 +95764,11 @@ protected function render($attributes, $content, $block) * @param string $content Original block content. * @return string */ - abstract protected function render_content($order, $permission = false, $attributes = [], $content = ''); + protected function render_content($order, $permission = false, $attributes = [], $content = '') + { + } /** - * This is what gets rendered when the order does not exist. Renders nothing by default, but can be overridden by - * child classes. + * This is what gets rendered when the order does not exist. * * @return string */ @@ -93014,239 +95776,350 @@ protected function render_content_fallback() { } /** - * Get current order. + * If the order is invalid or there is no permission to view the details, tell the user to check email or log-in. * - * @return \WC_Order|null + * @param \WC_Order|null $order Order object. + * @return string */ - protected function get_order() + protected function render_confirmation_notice($order = null) { } /** - * View mode for order details based on the order, current user, and settings. + * Email verification for guest users. * - * @param \WC_Order|null $order Order object. - * @return string|false Returns "full" if the user can view all order details. False if they can view no details. + * @return string */ - protected function get_view_order_permissions($order) + protected function render_verification_form() { } + } + /** + * Summary class. + */ + class Summary extends \Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation\AbstractOrderConfirmationBlock + { /** - * See if guest checkout is enabled. + * Block name. * - * @return boolean + * @var string */ - protected function allow_guest_checkout() - { - } + protected $block_name = 'order-confirmation-summary'; /** - * Guest users without an active session can provide their email address to view order details. This however can only - * be permitted if the user also provided the correct order key, and guest checkout is actually enabled. + * This renders the content of the block within the wrapper. * - * @param \WC_Order $order Order object. - * @return boolean + * @param \WC_Order $order Order object. + * @param string|false $permission If the current user can view the order details or not. + * @param array $attributes Block attributes. + * @param string $content Original block content. + * @return string */ - protected function email_verification_permitted($order) + protected function render_content($order, $permission = false, $attributes = [], $content = '') { } /** - * See if the order was created within the grace period for viewing details. + * Render row in the order summary. * - * @param \WC_Order $order Order object. - * @return boolean + * @param string $name name of row. + * @param string $value value of row. + * @return string */ - protected function is_within_grace_period($order) + protected function render_summary_row($name, $value) { } + } + /** + * Totals class. + */ + class Totals extends \Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation\AbstractOrderConfirmationBlock + { /** - * Returns true if the email has been verified (posted email matches given order email). + * Block name. * - * @param \WC_Order $order Order object. - * @return boolean + * @var string */ - protected function is_email_verified($order) + protected $block_name = 'order-confirmation-totals'; + /** + * This renders the content of the block within the wrapper. + * + * @param \WC_Order $order Order object. + * @param string|false $permission If the current user can view the order details or not. + * @param array $attributes Block attributes. + * @param string $content Original block content. + * @return string + */ + protected function render_content($order, $permission = false, $attributes = [], $content = '') { } /** - * See if we need to verify the email address before showing the order details. + * Enqueue frontend assets for this block, just in time for rendering. * - * @param \WC_Order $order Order object. - * @return boolean + * @param array $attributes Any attributes that currently are available from the block. + * @return string */ - protected function email_verification_required($order) + protected function get_inline_styles(array $attributes) { } /** - * See if the order key is valid. + * Enqueue frontend assets for this block, just in time for rendering. * - * @param \WC_Order $order Order object. - * @return boolean + * @param array $attributes Any attributes that currently are available from the block. + * @param string $content The block content. + * @param \WP_Block $block The block object. */ - protected function has_valid_order_key($order) + protected function enqueue_assets(array $attributes, $content, $block) { } /** - * See if the current order came from a guest or a logged in customer. + * Render order details table items. + * + * Loosely based on the templates order-details.php and order-details-item.php from core. * * @param \WC_Order $order Order object. - * @return boolean + * @return string */ - protected function is_customer_order($order) + protected function render_order_details_table_items($order) { } /** - * See if the current logged in user ID matches the given order customer ID. - * - * Returns false for logged-out customers. + * Render an item in the order details table. * - * @param \WC_Order $order Order object. - * @return boolean + * @param \WC_Order $order Order object. + * @param integer $item_id Item ID. + * @param \WC_Order_Item $item Item object. + * @param \WC_Product|false $product Product object if it exists. + * @return string */ - protected function is_current_customer_order($order) + protected function render_order_details_table_item($order, $item_id, $item, $product) { } /** - * Get the frontend script handle for this block type. + * Render an item purchase note. * - * @param string $key Data to get, or default to everything. + * @param \WC_Order $order Order object. + * @param \WC_Product|false $product Product object if it exists. + * @return string */ - protected function get_block_type_script($key = null) + protected function render_order_details_table_item_purchase_note($order, $product) { } /** - * Render custom fields for the order. + * Render order details table totals. * - * @param array $fields List of additional fields with values. + * @param \WC_Order $order Order object. * @return string */ - protected function render_additional_fields($fields) + protected function render_order_details_table_totals($order) { } /** - * Render custom field row. + * Render customer note. * - * @param array $field An additional field and value. + * @param \WC_Order $order Order object. * @return string */ - protected function render_additional_field($field) + protected function render_order_details_customer_note($order) { } } /** - * AdditionalFields class. + * TotalsWrapper class. */ - class AdditionalFields extends \Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation\AbstractOrderConfirmationBlock + class TotalsWrapper extends \Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation\AbstractOrderConfirmationBlock { /** * Block name. * * @var string */ - protected $block_name = 'order-confirmation-additional-fields'; + protected $block_name = 'order-confirmation-totals-wrapper'; /** - * This renders the content of the block within the wrapper. + * This renders the content of the totals wrapper. * * @param \WC_Order $order Order object. * @param string|false $permission If the current user can view the order details or not. * @param array $attributes Block attributes. * @param string $content Original block content. - * @return string */ protected function render_content($order, $permission = false, $attributes = [], $content = '') { } + /** + * Get the frontend style handle for this block type. + * + * @return null + */ + protected function get_block_type_style() + { + } } +} +namespace Automattic\WooCommerce\Blocks\BlockTypes { /** - * AdditionalFieldsWrapper class. + * Used in templates to wrap page content. Allows content to be populated at template level. + * + * @internal */ - class AdditionalFieldsWrapper extends \Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation\AbstractOrderConfirmationBlock + class PageContentWrapper extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { /** * Block name. * * @var string */ - protected $block_name = 'order-confirmation-additional-fields-wrapper'; + protected $block_name = 'page-content-wrapper'; /** - * This renders the content of the downloads wrapper. + * It isn't necessary to register block assets. * - * @param \WC_Order $order Order object. - * @param string|false $permission If the current user can view the order details or not. - * @param array $attributes Block attributes. - * @param string $content Original block content. + * @param string $key Data to get, or default to everything. + * @return array|string|null */ - protected function render_content($order, $permission = false, $attributes = [], $content = '') + protected function get_block_type_script($key = null) { } /** - * Extra data passed through from server to client for block. + * Get the frontend style handle for this block type. * - * @param array $attributes Any attributes that currently are available from the block. - * Note, this will be empty in the editor context when the block is - * not in the post content on editor load. + * @return null */ - protected function enqueue_data(array $attributes = []) + protected function get_block_type_style() { } } /** - * AdditionalInformation class. + * PaymentMethodIcons class. */ - class AdditionalInformation extends \Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation\AbstractOrderConfirmationBlock + class PaymentMethodIcons extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { /** * Block name. * * @var string */ - protected $block_name = 'order-confirmation-additional-information'; + protected $block_name = 'payment-method-icons'; /** - * This renders the content of the block within the wrapper. + * Get the frontend script handle for this block type. * - * @param \WC_Order $order Order object. - * @param string|false $permission If the current user can view the order details or not. - * @param array $attributes Block attributes. - * @param string $content Original block content. - * @return string + * @param string $key Data to get, or default to everything. + * @return array|string */ - protected function render_content($order, $permission = false, $attributes = [], $content = '') + protected function get_block_type_script($key = null) { } /** - * Remove core hooks from the thankyou page. + * Get the frontend style handle for this block type. + * + * @return string[] */ - protected function remove_core_hooks() + protected function get_block_type_style() + { + } + /** + * Extra data passed through from server to client for block. + * + * @param array $attributes Any attributes that currently are available from the block. + */ + protected function enqueue_data(array $attributes = []) + { + } + /** + * Render the block. + * + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. + */ + protected function render($attributes, $content, $block) + { + } + /** + * Render payment method icons. + * + * @param array $attributes Block attributes. + * @return string Rendered block type output. + */ + private function render_payment_method_icons($attributes) + { + } + /** + * Check if WooPayments is enabled. + * + * @return bool WooPayments enabled. + */ + private function is_woopayments_enabled() + { + } + /** + * Get the enabled card types for WooPayments. + * + * Note: This uses hardcoded cards based on the default card types provided by WooPayments. This should be updated when these icons can be accessed via an API. + * + * @return array Enabled card types. + */ + private function get_enabled_card_types() + { + } + /** + * Get the card type icon URL. + * + * @param string $card_type Card type. + * @return string Card type icon URL. + */ + private function get_card_type_icon_url($card_type) + { + } + /** + * Get other payment method icons from available gateways. + * + * @return array Other payment method icons. + */ + private function get_other_payment_method_icons() + { + } + /** + * Get the available payment methods. + * + * @return array Available payment methods. + */ + private function get_available_payment_methods() { } + } + /** + * PriceFilter class. + */ + class PriceFilter extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + { + /** + * Block name. + * + * @var string + */ + protected $block_name = 'price-filter'; + const MIN_PRICE_QUERY_VAR = 'min_price'; + const MAX_PRICE_QUERY_VAR = 'max_price'; /** - * Restore core hooks from the thankyou page. + * Extra data passed through from server to client for block. + * + * @param array $attributes Any attributes that currently are available from the block. + * Note, this will be empty in the editor context when the block is + * not in the post content on editor load. */ - protected function restore_core_hooks() + protected function enqueue_data(array $attributes = []) { } } /** - * BillingAddress class. + * ProceedToCheckoutBlock class. */ - class BillingAddress extends \Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation\AbstractOrderConfirmationBlock + class ProceedToCheckoutBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock { /** * Block name. * * @var string */ - protected $block_name = 'order-confirmation-billing-address'; - /** - * This renders the content of the block within the wrapper. - * - * @param \WC_Order $order Order object. - * @param string|false $permission If the current user can view the order details or not. - * @param array $attributes Block attributes. - * @param string $content Original block content. - * @return string - */ - protected function render_content($order, $permission = false, $attributes = [], $content = '') - { - } + protected $block_name = 'proceed-to-checkout-block'; /** * Extra data passed through from server to client for block. * @@ -93259,25 +96132,29 @@ protected function enqueue_data(array $attributes = []) } } /** - * BillingWrapper class. + * ProductAverageRating class. */ - class BillingWrapper extends \Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation\AbstractOrderConfirmationBlock + class ProductAverageRating extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { /** * Block name. * * @var string */ - protected $block_name = 'order-confirmation-billing-wrapper'; + protected $block_name = 'product-average-rating'; /** - * This renders the content of the billing wrapper. + * API version name. * - * @param \WC_Order $order Order object. - * @param string|false $permission If the current user can view the order details or not. - * @param array $attributes Block attributes. - * @param string $content Original block content. + * @var string */ - protected function render_content($order, $permission = false, $attributes = [], $content = '') + protected $api_version = '3'; + /** + * Overwrite parent method to prevent script registration. + * + * It is necessary to register and enqueues assets during the render + * phase because we want to load assets only if the block has the content. + */ + protected function register_block_type_assets() { } /** @@ -93288,1232 +96165,1487 @@ protected function render_content($order, $permission = false, $attributes = [], protected function get_block_type_style() { } + /** + * Include and render the block. + * + * @param array $attributes Block attributes. Default empty array. + * @param string $content Block content. Default empty string. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. + */ + protected function render($attributes, $content, $block) + { + } } /** - * CreateAccount class. + * ProductBestSellers class. */ - class CreateAccount extends \Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation\AbstractOrderConfirmationBlock + class ProductBestSellers extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractProductGrid { /** * Block name. * * @var string */ - protected $block_name = 'order-confirmation-create-account'; + protected $block_name = 'product-best-sellers'; /** - * Initialize this block type. + * Set args specific to this block + * + * @param array $query_args Query args. */ - protected function initialize() + protected function set_block_query_args(&$query_args) { } + } + /** + * ProductButton class. + */ + class ProductButton extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + { + use \Automattic\WooCommerce\Blocks\BlockTypes\EnableBlockJsonAssetsTrait; + use \Automattic\WooCommerce\Blocks\Utils\BlocksSharedState; /** - * Initialize hooks. + * Block name. * - * @see https://developer.wordpress.org/reference/hooks/hooked_block/ + * @var string */ - protected function initialize_hooks() + protected $block_name = 'product-button'; + /** + * Cart. + * + * @var array + */ + private static $cart = null; + /** + * Register the context. + */ + protected function get_block_type_uses_context() { } /** - * Get the frontend script handle for this block type. + * Enqueue frontend assets for this block, just in time for rendering. * - * @see $this->register_block_type() - * @param string $key Data to get, or default to everything. - * @return array|string + * @param array $attributes Any attributes that currently are available from the block. + * @param string $content The block content. + * @param WP_Block $block The block object. */ - protected function get_block_type_script($key = null) + protected function enqueue_assets(array $attributes, $content, $block) { } /** - * Returns if delayed account creation is enabled. + * Dequeue the add-to-cart script. + * The block uses Interactivity API, it isn't necessary enqueue the add-to-cart script. + */ + public function dequeue_add_to_cart_scripts() + { + } + /** + * Include and render the block. * - * @return bool + * @param array $attributes Block attributes. Default empty array. + * @param string $content Block content. Default empty string. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - protected function is_feature_enabled() + protected function render($attributes, $content, $block) { } /** - * Process posted account form. + * Get the number of items in the cart for a given product id. * - * @param \WC_Order $order Order object. - * @return \WP_Error|int + * @param number $product_id The product id. + * @return number The number of items in the cart. */ - protected function process_form_post($order) + private function get_cart_item_quantities_by_product_id($product_id) { } /** - * This renders the content of the block within the wrapper. + * Check if a product is purchasable. * - * @param \WC_Order $order Order object. - * @param string|false $permission If the current user can view the order details or not. - * @param array $attributes Block attributes. - * @param string $content Original block content. - * @return string + * @param \WC_Product $product The product. + * @return boolean The product is purchasable. */ - protected function render_content($order, $permission = false, $attributes = [], $content = '') + private function is_product_purchasable($product) { } /** - * Render the block when an account has been registered. + * Get the inTheCartText text for a given product. * - * @return string + * @param \WC_Product $product The product. + * @return string The inTheCartText string. */ - protected function render_confirmation() + private function get_in_the_cart_text($product) { } /** - * Extra data passed through from server to client for block. + * Get the view cart link html. * - * @param array $attributes Any attributes that currently are available from the block. - * Note, this will be empty in the editor context when the block is - * not in the post content on editor load. + * @return string The view cart html. */ - protected function enqueue_data(array $attributes = []) + private function get_view_cart_html() { } } /** - * Downloads class. + * ProductCategories class. */ - class Downloads extends \Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation\AbstractOrderConfirmationBlock + class ProductCategories extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractDynamicBlock { /** * Block name. * * @var string */ - protected $block_name = 'order-confirmation-downloads'; + protected $block_name = 'product-categories'; /** - * This renders the content of the block within the wrapper. + * Default attribute values, should match what's set in JS `registerBlockType`. * - * @param \WC_Order $order Order object. - * @param string|false $permission If the current user can view the order details or not. - * @param array $attributes Block attributes. - * @param string $content Original block content. - * @return string + * @var array */ - protected function render_content($order, $permission = false, $attributes = [], $content = '') + protected $defaults = array('hasCount' => true, 'hasImage' => false, 'hasEmpty' => false, 'isDropdown' => false, 'isHierarchical' => true, 'showChildrenOnly' => false); + /** + * Get block attributes. + * + * @return array + */ + protected function get_block_type_attributes() { } /** - * Enqueue frontend assets for this block, just in time for rendering. + * Render the Product Categories List block. * - * @param array $attributes Any attributes that currently are available from the block. - * @return string + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - protected function get_inline_styles(array $attributes) + protected function render($attributes, $content, $block) { } /** - * Enqueue frontend assets for this block, just in time for rendering. + * Get the list of classes to apply to this block. * - * @param array $attributes Any attributes that currently are available from the block. - * @param string $content The block content. - * @param \WP_Block $block The block object. + * @param array $attributes Block attributes. Default empty array. + * @return string space-separated list of classes. */ - protected function enqueue_assets(array $attributes, $content, $block) + protected function get_container_classes($attributes = array()) { } /** - * Render column headers for downloads table. + * Get categories (terms) from the db. * - * @return string + * @param array $attributes Block attributes. Default empty array. + * @return array */ - protected function render_order_downloads_column_headers() + protected function get_categories($attributes) { } /** - * Render downloads. + * Build hierarchical tree of categories. * - * @param \WC_Order $order Order object. - * @param array $downloads Array of downloads. - * @return string + * @param array $categories List of terms. + * @param bool $children_only Is the block rendering only the children of the current category. + * @return array */ - protected function render_order_downloads($order, $downloads) + protected function build_category_tree($categories, $children_only) { } /** - * Render a download row in the table. + * Build hierarchical tree of categories by appending children in the tree. * - * @param array $download Download data. - * @return string + * @param array $categories List of terms. + * @param array $categories_by_parent List of terms grouped by parent. + * @return array */ - protected function render_order_download_row($download) + protected function fill_category_children($categories, $categories_by_parent) { } - } - /** - * DownloadsWrapper class. - */ - class DownloadsWrapper extends \Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation\AbstractOrderConfirmationBlock - { /** - * Block name. + * Render the category list as a dropdown. * - * @var string + * @param array $categories List of terms. + * @param array $attributes Block attributes. Default empty array. + * @param int $uid Unique ID for the rendered block, used for HTML IDs. + * @return string Rendered output. */ - protected $block_name = 'order-confirmation-downloads-wrapper'; + protected function renderDropdown($categories, $attributes, $uid) + { + } /** - * See if the store has a downloadable product. This controls if we bother to show a preview in the editor. + * Render dropdown options list. * - * @return boolean + * @param array $categories List of terms. + * @param array $attributes Block attributes. Default empty array. + * @param int $uid Unique ID for the rendered block, used for HTML IDs. + * @param int $depth Current depth. + * @return string Rendered output. */ - protected function store_has_downloadable_products() + protected function renderDropdownOptions($categories, $attributes, $uid, $depth = 0) { } /** - * Extra data passed through from server to client for block. + * Render the category list as a list. * - * @param array $attributes Any attributes that currently are available from the block. - * Note, this will be empty in the editor context when the block is - * not in the post content on editor load. + * @param array $categories List of terms. + * @param array $attributes Block attributes. Default empty array. + * @param int $uid Unique ID for the rendered block, used for HTML IDs. + * @param int $depth Current depth. + * @return string Rendered output. */ - protected function enqueue_data(array $attributes = []) + protected function renderList($categories, $attributes, $uid, $depth = 0) { } /** - * This renders the content of the downloads wrapper. + * Render a list of terms. * - * @param \WC_Order $order Order object. - * @param string|false $permission If the current user can view the order details or not. - * @param array $attributes Block attributes. - * @param string $content Original block content. + * @param array $categories List of terms. + * @param array $attributes Block attributes. Default empty array. + * @param int $uid Unique ID for the rendered block, used for HTML IDs. + * @param int $depth Current depth. + * @return string Rendered output. */ - protected function render_content($order, $permission = false, $attributes = [], $content = '') + protected function renderListItems($categories, $attributes, $uid, $depth = 0) { } /** - * Get the frontend style handle for this block type. + * Returns the category image html * - * @return null + * @param \WP_Term $category Term object. + * @param array $attributes Block attributes. Default empty array. + * @param string $size Image size, defaults to 'woocommerce_thumbnail'. + * @return string */ - protected function get_block_type_style() + public function get_image_html($category, $attributes, $size = 'woocommerce_thumbnail') + { + } + /** + * Get the count, if displaying. + * + * @param object $category Term object. + * @param array $attributes Block attributes. Default empty array. + * @return string + */ + protected function getCount($category, $attributes) { } } /** - * ShippingAddress class. + * ProductCategory class. */ - class ShippingAddress extends \Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation\AbstractOrderConfirmationBlock + class ProductCategory extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractProductGrid { /** * Block name. * * @var string */ - protected $block_name = 'order-confirmation-shipping-address'; + protected $block_name = 'product-category'; /** - * This renders the content of the block within the wrapper. + * Set args specific to this block * - * @param \WC_Order $order Order object. - * @param string|false $permission If the current user can view the order details or not. - * @param array $attributes Block attributes. - * @param string $content Original block content. - * @return string + * @param array $query_args Query args. */ - protected function render_content($order, $permission = false, $attributes = [], $content = '') + protected function set_block_query_args(&$query_args) { } /** - * Extra data passed through from server to client for block. + * Get block attributes. * - * @param array $attributes Any attributes that currently are available from the block. - * Note, this will be empty in the editor context when the block is - * not in the post content on editor load. + * @return array */ - protected function enqueue_data(array $attributes = []) + protected function get_block_type_attributes() { } } +} +namespace Automattic\WooCommerce\Blocks\BlockTypes\ProductCollection { /** - * ShippingWrapper class. + * Controller class. */ - class ShippingWrapper extends \Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation\AbstractOrderConfirmationBlock + class Controller extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { + use \Automattic\WooCommerce\Blocks\BlockTypes\EnableBlockJsonAssetsTrait; /** * Block name. * * @var string */ - protected $block_name = 'order-confirmation-shipping-wrapper'; + protected $block_name = 'product-collection'; /** - * This renders the content of the shipping wrapper. + * Instance of HandlerRegistry. * - * @param \WC_Order $order Order object. - * @param string|false $permission If the current user can view the order details or not. - * @param array $attributes Block attributes. - * @param string $content Original block content. + * @var HandlerRegistry */ - protected function render_content($order, $permission = false, $attributes = [], $content = '') + protected $collection_handler_registry; + /** + * Instance of QueryBuilder. + * + * @var QueryBuilder + */ + protected $query_builder; + /** + * Instance of Renderer. + * + * @var Renderer + */ + protected $renderer; + /** + * Initialize this block type. + * + * - Register hooks and filters. + * - Set up QueryBuilder, Renderer and HandlerRegistry. + */ + protected function initialize() { } /** - * Get the frontend style handle for this block type. + * Add interactivity to the Product Title block within Product Collection. + * This enables the triggering of a custom event when the product title is clicked. * - * @return null + * @param string $block_content The block content. + * @param array $block The full block, including name and attributes. + * @param \WP_Block $instance The block instance. + * @return string Modified block content with added interactivity. */ - protected function get_block_type_style() + public function add_product_title_click_event_directives($block_content, $block, $instance) { } - } - /** - * Status class. - */ - class Status extends \Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation\AbstractOrderConfirmationBlock - { /** - * Block name. + * Verifies if the inner block is compatible with Interactivity API. * - * @var string + * @param string $block_name Name of the block to verify. + * @return boolean */ - protected $block_name = 'order-confirmation-status'; + private function is_block_compatible($block_name) + { + } /** - * This block uses a custom render method so that the email verification form can be appended to the block. This does - * not inherit styles from the parent block. + * Check inner blocks of Product Collection block if there's one + * incompatible with the Interactivity API and if so, disable client-side + * navigation. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. + * @param array $parsed_block The block being rendered. + * @return string Returns the parsed block, unmodified. + */ + public function disable_enhanced_pagination($parsed_block) + { + } + /** + * Extra data passed through from server to client for block. * - * @return string | void Rendered block output. + * @param array $attributes Any attributes that currently are available from the block. + * Note, this will be empty in the editor context when the block is + * not in the post content on editor load. */ - protected function render($attributes, $content, $block) + protected function enqueue_data(array $attributes = array()) { } /** - * This renders the content of the block within the wrapper. + * Exposes settings used by the Product Collection block when manipulating + * the default query. + */ + public function register_settings() + { + } + /** + * Update the query for the product query block in Editor. * - * @param \WC_Order $order Order object. - * @param string|false $permission If the current user can view the order details or not. - * @param array $attributes Block attributes. - * @param string $content Original block content. - * @return string + * @param array $query Query args. + * @param WP_REST_Request $request Request. */ - protected function render_content($order, $permission = false, $attributes = [], $content = '') + public function update_rest_query_in_editor($query, $request): array { } /** - * This is what gets rendered when the order does not exist. + * Add support for filter blocks: + * - Price filter block + * - Attributes filter block + * - Rating filter block + * - In stock filter block etc. * - * @return string + * @param array $pre_render The pre-rendered block. + * @param array $parsed_block The parsed block. */ - protected function render_content_fallback() + public function add_support_for_filter_blocks($pre_render, $parsed_block) { } /** - * If the order is invalid or there is no permission to view the details, tell the user to check email or log-in. + * Return a custom query based on attributes, filters and global WP_Query. * - * @param \WC_Order|null $order Order object. - * @return string + * @param WP_Query $query The WordPress Query. + * @param WP_Block $block The block being rendered. + * @param int $page The page number. + * + * @return array */ - protected function render_confirmation_notice($order = null) + public function build_frontend_query($query, $block, $page) { } /** - * Email verification for guest users. + * Extends allowed `collection_params` for the REST API * - * @return string + * By itself, the REST API doesn't accept custom `orderby` values, + * even if they are supported by a custom post type. + * + * @param array $params A list of allowed `orderby` values. + * + * @return array */ - protected function render_verification_form() + public function extend_rest_query_allowed_params($params) + { + } + /** + * Registers core collections and sets the handler store. + */ + protected function register_core_collections_and_set_handler_store() { } } /** - * Summary class. + * HandlerRegistry class. + * Manages collection handlers. */ - class Summary extends \Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation\AbstractOrderConfirmationBlock + class HandlerRegistry { /** - * Block name. + * Associative array of collection handlers. * - * @var string + * @var array */ - protected $block_name = 'order-confirmation-summary'; + protected $collection_handler_store = []; /** - * This renders the content of the block within the wrapper. + * Register handlers for a collection. * - * @param \WC_Order $order Order object. - * @param string|false $permission If the current user can view the order details or not. - * @param array $attributes Block attributes. - * @param string $content Original block content. - * @return string + * @param string $collection_name The name of the collection. + * @param callable $build_query The query builder callable. + * @param callable|null $frontend_args Optional frontend args callable. + * @param callable|null $editor_args Optional editor args callable. + * @param callable|null $preview_query Optional preview query callable. + * + * @throws InvalidArgumentException If handlers are already registered for the collection. */ - protected function render_content($order, $permission = false, $attributes = [], $content = '') + public function register_collection_handlers($collection_name, $build_query, $frontend_args = null, $editor_args = null, $preview_query = null) { } /** - * Render row in the order summary. + * Register core collection handlers. + */ + public function register_core_collections() + { + } + /** + * Get collection handler by name. * - * @param string $name name of row. - * @param string $value value of row. - * @return string + * @param string $name Collection name. + * @return array|null Collection handler array or null if not found. + */ + public function get_collection_handler($name) + { + } + /** + * Removes any custom collection handlers for the given collection. + * + * @param string $collection_name The name of the collection to unregister. + */ + public function unregister_collection_handlers($collection_name) + { + } + /** + * Get product IDs from an order. + * + * @param int $order_id The order ID. + * @return array The product IDs. */ - protected function render_summary_row($name, $value) + private function get_product_ids_from_order($order_id) { } } /** - * Totals class. + * NoResults class. */ - class Totals extends \Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation\AbstractOrderConfirmationBlock + class NoResults extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { /** * Block name. * * @var string */ - protected $block_name = 'order-confirmation-totals'; + protected $block_name = 'product-collection-no-results'; /** - * This renders the content of the block within the wrapper. + * Render the block. * - * @param \WC_Order $order Order object. - * @param string|false $permission If the current user can view the order details or not. - * @param array $attributes Block attributes. - * @param string $content Original block content. - * @return string + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * + * @return string | void Rendered block output. */ - protected function render_content($order, $permission = false, $attributes = [], $content = '') + protected function render($attributes, $content, $block) { } /** - * Enqueue frontend assets for this block, just in time for rendering. + * Get the frontend script handle for this block type. * - * @param array $attributes Any attributes that currently are available from the block. - * @return string + * @param string $key Data to get, or default to everything. */ - protected function get_inline_styles(array $attributes) + protected function get_block_type_script($key = null) { } /** - * Enqueue frontend assets for this block, just in time for rendering. + * Get the frontend style handle for this block type. * - * @param array $attributes Any attributes that currently are available from the block. - * @param string $content The block content. - * @param \WP_Block $block The block object. + * @return null */ - protected function enqueue_assets(array $attributes, $content, $block) + protected function get_block_type_style() { } /** - * Render order details table items. - * - * Loosely based on the templates order-details.php and order-details-item.php from core. + * Set the URL attributes for "clearing any filters" and "Store's home" links. * - * @param \WC_Order $order Order object. - * @return string + * @param string $content Block content. */ - protected function render_order_details_table_items($order) + protected function modify_anchor_tag_urls($content) { } /** - * Render an item in the order details table. - * - * @param \WC_Order $order Order object. - * @param integer $item_id Item ID. - * @param \WC_Order_Item $item Item object. - * @param \WC_Product|false $product Product object if it exists. - * @return string + * Get current URL without filter query parameters which will be used + * for the "clear any filters" link. */ - protected function render_order_details_table_item($order, $item_id, $item, $product) + protected function get_current_url_without_filters() { } + } + /** + * QueryBuilder class. + * Responsible for constructing and modifying product queries. + */ + class QueryBuilder + { /** - * Render an item purchase note. + * All query args from WP_Query. * - * @param \WC_Order $order Order object. - * @param \WC_Product|false $product Product object if it exists. - * @return string + * @var array */ - protected function render_order_details_table_item_purchase_note($order, $product) - { - } + protected $valid_query_vars; /** - * Render order details table totals. + * Orderby options not natively supported by WordPress REST API * - * @param \WC_Order $order Order object. - * @return string + * @var array */ - protected function render_order_details_table_totals($order) - { - } + protected $custom_order_opts = array('popularity', 'rating', 'post__in', 'price', 'sales', 'menu_order', 'random'); /** - * Render customer note. + * All the query args related to the filter by attributes block. * - * @param \WC_Order $order Order object. - * @return string + * @var array */ - protected function render_order_details_customer_note($order) - { - } - } - /** - * TotalsWrapper class. - */ - class TotalsWrapper extends \Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation\AbstractOrderConfirmationBlock - { + protected $attributes_filter_query_args = array(); /** - * Block name. + * Collection handler store. * - * @var string + * @var array */ - protected $block_name = 'order-confirmation-totals-wrapper'; + protected $collection_handler_store = array(); /** - * This renders the content of the totals wrapper. - * - * @param \WC_Order $order Order object. - * @param string|false $permission If the current user can view the order details or not. - * @param array $attributes Block attributes. - * @param string $content Original block content. + * Constructor. */ - protected function render_content($order, $permission = false, $attributes = [], $content = '') + public function __construct() { } /** - * Get the frontend style handle for this block type. + * Set the collection handler store. * - * @return null + * @param array $collection_handler_store The collection handler store containing registered collection handlers. */ - protected function get_block_type_style() + public function set_collection_handler_store($collection_handler_store) { } - } -} -namespace Automattic\WooCommerce\Blocks\BlockTypes { - /** - * Used in templates to wrap page content. Allows content to be populated at template level. - * - * @internal - */ - class PageContentWrapper extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock - { /** - * Block name. + * Set collection handler. * - * @var string + * @param string $collection_name The name of the custom collection. + * @param array $handlers Collection handlers. */ - protected $block_name = 'page-content-wrapper'; + public function set_collection_handler($collection_name, $handlers) + { + } /** - * It isn't necessary to register block assets. + * Set attributes filter query args. * - * @param string $key Data to get, or default to everything. - * @return array|string|null + * @param array $args The attributes filter query arguments. */ - protected function get_block_type_script($key = null) + public function set_attributes_filter_query_args($args) { } /** - * Get the frontend style handle for this block type. + * Return or initialize $valid_query_vars. * - * @return null + * @return array */ - protected function get_block_type_style() + private function get_valid_query_vars() { } - } - /** - * PaymentMethodIcons class. - */ - class PaymentMethodIcons extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock - { /** - * Block name. + * Get custom order options. * - * @var string + * @return array */ - protected $block_name = 'payment-method-icons'; + public function get_custom_order_opts() + { + } /** - * Get the frontend script handle for this block type. + * Get the final query arguments for the frontend. * - * @param string $key Data to get, or default to everything. - * @return array|string + * @param array $collection_args Any special arguments that should change the behavior of the query. + * @param array $query The query arguments. + * @param int $page The page number. + * @param bool $is_exclude_applied_filters Whether to exclude the applied filters or not. */ - protected function get_block_type_script($key = null) + public function get_final_frontend_query($collection_args, $query, $page = 1, $is_exclude_applied_filters = false) { } /** - * Get the frontend style handle for this block type. + * Return a query to filter products by taxonomies (product categories, product tags, etc.) * - * @return string[] + * For example: + * User could provide "Product Categories" using "Filters" ToolsPanel available in Inspector Controls. + * We use this function to extract its query from $tax_query. + * + * For example, this is how the query for product categories will look like in $tax_query array: + * Array + * ( + * [taxonomy] => product_cat + * [terms] => Array + * ( + * [0] => 36 + * ) + * ) + * + * For product tags, taxonomy would be "product_tag" + * + * @param array $tax_query Query to filter products by taxonomies. + * @return array Query to filter products by taxonomies. */ - protected function get_block_type_style() + private function get_filter_by_taxonomies_query($tax_query): array { } /** - * Extra data passed through from server to client for block. + * Get final query args based on provided values * - * @param array $attributes Any attributes that currently are available from the block. + * @param array $collection_args Any special arguments that should change the behavior of the query. + * @param array $common_query_values Common query values. + * @param array $query Query from block context. + * @param bool $is_exclude_applied_filters Whether to exclude the applied filters or not. */ - protected function enqueue_data(array $attributes = []) + public function get_final_query_args($collection_args, $common_query_values, $query, $is_exclude_applied_filters = false) { } /** - * Render the block. + * Get query args for preview mode. These query args will be used with WP_Query to fetch the products. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @param array $collection_args Any collection-specific arguments. + * @param array $args Query args. + * @param WP_REST_Request $request Request. */ - protected function render($attributes, $content, $block) + public function get_preview_query_args($collection_args, $args, $request) { } /** - * Render payment method icons. + * Return a query for products depending on their stock status. * - * @param array $attributes Block attributes. - * @return string Rendered block type output. + * @param array $stock_statuses An array of acceptable stock statuses. + * @return array */ - private function render_payment_method_icons($attributes) + private function get_stock_status_query($stock_statuses) { } /** - * Check if WooPayments is enabled. + * Merge tax_queries from various queries. * - * @return bool WooPayments enabled. + * @param array ...$queries Query arrays to be merged. + * @return array */ - private function is_woopayments_enabled() + private function merge_tax_queries(...$queries) { } /** - * Get the enabled card types for WooPayments. + * Return the `tax_query` for the requested attributes * - * Note: This uses hardcoded cards based on the default card types provided by WooPayments. This should be updated when these icons can be accessed via an API. + * @param array $attributes Attributes and their terms. * - * @return array Enabled card types. + * @return array */ - private function get_enabled_card_types() + private function get_product_attributes_query($attributes = array()) { } /** - * Get the card type icon URL. + * Generates a tax query to filter products based on their "featured" status. + * If the `$featured` parameter is true, the function will return a tax query + * that filters products to only those marked as featured. + * If `$featured` is false, an empty array is returned, meaning no filtering will be applied. * - * @param string $card_type Card type. - * @return string Card type icon URL. + * @param bool $featured A flag indicating whether to filter products based on featured status. + * + * @return array A tax query for fetching featured products if `$featured` is true; otherwise, an empty array. */ - private function get_card_type_icon_url($card_type) + private function get_featured_query($featured) { } /** - * Get other payment method icons from available gateways. + * Return a query that filters products by price. * - * @return array Other payment method icons. + * @return array */ - private function get_other_payment_method_icons() + private function get_filter_by_price_query() { } /** - * Get the available payment methods. + * Return a query that filters products by attributes. * - * @return array Available payment methods. + * @return array */ - private function get_available_payment_methods() + private function get_filter_by_attributes_query() { } - } - /** - * PriceFilter class. - */ - class PriceFilter extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock - { /** - * Block name. + * Get all the query args related to the filter by attributes block. * - * @var string + * @return array + * [color] => Array + * ( + * [filter] => filter_color + * [query_type] => query_type_color + * ) + * + * [size] => Array + * ( + * [filter] => filter_size + * [query_type] => query_type_size + * ) + * ) */ - protected $block_name = 'price-filter'; - const MIN_PRICE_QUERY_VAR = 'min_price'; - const MAX_PRICE_QUERY_VAR = 'max_price'; + private function get_filter_by_attributes_query_vars() + { + } /** - * Extra data passed through from server to client for block. + * Return a query that filters products by stock status. * - * @param array $attributes Any attributes that currently are available from the block. - * Note, this will be empty in the editor context when the block is - * not in the post content on editor load. + * @return array */ - protected function enqueue_data(array $attributes = []) + private function get_filter_by_stock_status_query() { } - } - /** - * ProceedToCheckoutBlock class. - */ - class ProceedToCheckoutBlock extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractInnerBlock - { /** - * Block name. + * Return a query that filters products by rating. * - * @var string + * @return array */ - protected $block_name = 'proceed-to-checkout-block'; + private function get_filter_by_rating_query() + { + } /** - * Extra data passed through from server to client for block. + * Merge two array recursively but replace the non-array values instead of + * merging them. The merging strategy: * - * @param array $attributes Any attributes that currently are available from the block. - * Note, this will be empty in the editor context when the block is - * not in the post content on editor load. + * - If keys from merge array doesn't exist in the base array, create them. + * - For array items with numeric keys, we merge them as normal. + * - For array items with string keys: + * + * - If the value isn't array, we'll use the value coming from the merge array. + * $base = ['orderby' => 'date'] + * $new_array = ['orderby' => 'meta_value_num'] + * Result: ['orderby' => 'meta_value_num'] + * + * - If the value is array, we'll use recursion to merge each key. + * $base = ['meta_query' => [ + * [ + * 'key' => '_stock_status', + * 'compare' => 'IN' + * 'value' => ['instock', 'onbackorder'] + * ] + * ]] + * $new_array = ['meta_query' => [ + * [ + * 'relation' => 'AND', + * [...], + * [...], + * ] + * ]] + * Result: ['meta_query' => [ + * [ + * 'key' => '_stock_status', + * 'compare' => 'IN' + * 'value' => ['instock', 'onbackorder'] + * ], + * [ + * 'relation' => 'AND', + * [...], + * [...], + * ] + * ]] + * + * $base = ['post__in' => [1, 2, 3, 4, 5]] + * $new_array = ['post__in' => [3, 4, 5, 6, 7]] + * Result: ['post__in' => [1, 2, 3, 4, 5, 3, 4, 5, 6, 7]] + * + * @param array $base First array. + * @param array $new_array Second array. */ - protected function enqueue_data(array $attributes = []) + private function array_merge_recursive_replace_non_array_properties($base, $new_array) { } - } - /** - * ProductAverageRating class. - */ - class ProductAverageRating extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock - { /** - * Block name. + * Return queries that are generated by query args. * - * @var string + * @return array */ - protected $block_name = 'product-average-rating'; + private function get_queries_by_applied_filters() + { + } /** - * API version name. + * Return a query for product visibility depending on their stock status. * - * @var string + * @param array $stock_query Stock status query. + * @param array $stock_status Selected stock status. + * + * @return array Tax query for product visibility. */ - protected $api_version = '3'; + private function get_product_visibility_query($stock_query, $stock_status) + { + } /** - * Overwrite parent method to prevent script registration. + * Constructs a date query for product filtering based on a specified time frame. * - * It is necessary to register and enqueues assets during the render - * phase because we want to load assets only if the block has the content. + * @param array $time_frame { + * Associative array with 'operator' (in or not-in) and 'value' (date string). + * + * @type string $operator Determines the inclusion or exclusion of the date range. + * @type string $value The date around which the range is applied. + * } + * @return array Date query array; empty if parameters are invalid. */ - protected function register_block_type_assets() + private function get_date_query(array $time_frame): array { } /** - * Get the frontend style handle for this block type. + * Get query arguments for price range filter. + * We are adding these extra query arguments to be used in `posts_clauses` + * because there are 2 special edge cases we wanna handle for Price range filter: + * Case 1: Prices excluding tax are displayed including tax + * Case 2: Prices including tax are displayed excluding tax * - * @return null + * Both of these cases require us to modify SQL query to get the correct results. + * + * See add_price_range_filter_posts_clauses function in this file for more details. + * + * @param array $price_range Price range with min and max values. + * @return array Query arguments. */ - protected function get_block_type_style() + public function get_price_range_query_args($price_range) { } /** - * Include and render the block. + * Add the `posts_clauses` filter to the main query. * - * @param array $attributes Block attributes. Default empty array. - * @param string $content Block content. Default empty string. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @param array $clauses The query clauses. + * @param WP_Query $query The WP_Query instance. */ - protected function render($attributes, $content, $block) + public function add_price_range_filter_posts_clauses($clauses, $query) { } - } - /** - * ProductBestSellers class. - */ - class ProductBestSellers extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractProductGrid - { /** - * Block name. + * Get query for price filters when dealing with displayed taxes. * - * @var string + * @param float $price_filter Price filter to apply. + * @param string $column Price being filtered (min or max). + * @param string $operator Comparison operator for column. + * @return string Constructed query. */ - protected $block_name = 'product-best-sellers'; + protected function get_price_filter_query_for_displayed_taxes($price_filter, $column = 'min_price', $operator = '>=') + { + } /** - * Set args specific to this block + * Adjusts a price filter based on a tax class and whether or not the amount includes or excludes taxes. * - * @param array $query_args Query args. + * This calculation logic is based on `wc_get_price_excluding_tax` and `wc_get_price_including_tax` in core. + * + * @param float $price_filter Price filter amount as entered. + * @param string $tax_class Tax class for adjustment. + * @return float */ - protected function set_block_query_args(&$query_args) + protected function adjust_price_filter_for_tax_class($price_filter, $tax_class) { } - } - /** - * ProductButton class. - */ - class ProductButton extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock - { - use \Automattic\WooCommerce\Blocks\BlockTypes\EnableBlockJsonAssetsTrait; - use \Automattic\WooCommerce\Blocks\Utils\BlocksSharedState; /** - * Block name. + * Determines if price filters need adjustment based on the tax display settings. * - * @var string + * This function checks if there's a discrepancy between how prices are stored in the database + * and how they are displayed to the user, specifically with respect to tax inclusion or exclusion. + * It returns true if an adjustment is needed, indicating that the price filters should account for this + * discrepancy to display accurate prices. + * + * @return bool True if the price filters need to be adjusted for tax display settings, false otherwise. */ - protected $block_name = 'product-button'; + private function should_adjust_price_range_for_taxes() + { + } /** - * Cart. + * Generates a post__in query to filter products to the set of provided IDs. * - * @var array + * @param int[]|false $handpicked_products The products to filter. + * + * @return array The post__in query. */ - private static $cart = null; + private function get_handpicked_query($handpicked_products) + { + } /** - * Register the context. + * Return a query for on sale products. + * + * @param bool $is_on_sale Whether to query for on sale products. + * + * @return array */ - protected function get_block_type_uses_context() + private function get_on_sale_products_query($is_on_sale) { } /** - * Enqueue frontend assets for this block, just in time for rendering. + * Merge in the first parameter the keys "post_in", "meta_query" and "tax_query" of the second parameter. * - * @param array $attributes Any attributes that currently are available from the block. - * @param string $content The block content. - * @param WP_Block $block The block object. + * @param array[] ...$queries Query arrays to be merged. + * @return array */ - protected function enqueue_assets(array $attributes, $content, $block) + private function merge_queries(...$queries) { } /** - * Dequeue the add-to-cart script. - * The block uses Interactivity API, it isn't necessary enqueue the add-to-cart script. + * Return query params to support custom sort values + * + * @param string $orderby Sort order option. + * + * @return array */ - public function dequeue_add_to_cart_scripts() + private function get_custom_orderby_query($orderby) { } /** - * Include and render the block. + * Add the `posts_clauses` filter to add price-based sorting * - * @param array $attributes Block attributes. Default empty array. - * @param string $content Block content. Default empty string. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @param array $clauses The list of clauses for the query. + * @param WP_Query $query The WP_Query instance. + * @return array Modified list of clauses. */ - protected function render($attributes, $content, $block) + public function add_price_sorting_posts_clauses($clauses, $query) { } /** - * Get the number of items in the cart for a given product id. + * Add the `posts_clauses` filter to add sales-based sorting * - * @param number $product_id The product id. - * @return number The number of items in the cart. + * @param array $clauses The list of clauses for the query. + * @param WP_Query $query The WP_Query instance. + * @return array Modified list of clauses. */ - private function get_cart_item_quantities_by_product_id($product_id) + public function add_sales_sorting_posts_clauses($clauses, $query) { } /** - * Check if a product is purchasable. + * Join wc_product_meta_lookup to posts if not already joined. * - * @param \WC_Product $product The product. - * @return boolean The product is purchasable. + * @param string $sql SQL join. + * @return string */ - private function is_product_purchasable($product) + protected function append_product_sorting_table_join($sql) { } /** - * Get the inTheCartText text for a given product. + * Merge all of the 'post__in' values and return an array containing only values that are present in all arrays. * - * @param \WC_Product $product The product. - * @return string The inTheCartText string. + * @param int[][] ...$post__in The 'post__in' values to be merged. + * + * @return int[] The merged 'post__in' values. */ - private function get_in_the_cart_text($product) + private function merge_post__in(...$post__in) { } /** - * Get the view cart link html. + * Add the `posts_clauses` filter to add menu order with title fallback sorting * - * @return string The view cart html. + * @param array $clauses The list of clauses for the query. + * @param WP_Query $query The WP_Query instance. + * @return array Modified list of clauses. */ - private function get_view_cart_html() + public function add_menu_order_with_title_fallback_posts_clauses($clauses, $query) { } } /** - * ProductCategories class. + * Renderer class. + * Handles rendering of the block and adds interactivity. */ - class ProductCategories extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractDynamicBlock + class Renderer { /** - * Block name. + * The render state of the product collection block. * - * @var string + * @var array */ - protected $block_name = 'product-categories'; + private $render_state = array('has_results' => false, 'has_no_results_block' => false); /** - * Default attribute values, should match what's set in JS `registerBlockType`. + * The Block with its attributes before it gets rendered * * @var array */ - protected $defaults = array('hasCount' => true, 'hasImage' => false, 'hasEmpty' => false, 'isDropdown' => false, 'isHierarchical' => true, 'showChildrenOnly' => false); + protected $parsed_block; /** - * Get block attributes. + * Constructor. + */ + public function __construct() + { + } + /** + * Set the parsed block. * - * @return array + * @param array $block The block to be parsed. */ - protected function get_block_type_attributes() + public function set_parsed_block($block) { } /** - * Render the Product Categories List block. + * Handle the rendering of the block. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @param string $block_content The block content about to be rendered. + * @param array $block The block being rendered. + * + * @return string */ - protected function render($attributes, $content, $block) + public function handle_rendering($block_content, $block) { } /** - * Get the list of classes to apply to this block. + * Check if the block should be prevented from rendering. * - * @param array $attributes Block attributes. Default empty array. - * @return string space-separated list of classes. + * @return bool */ - protected function get_container_classes($attributes = array()) + private function should_prevent_render() { } /** - * Get categories (terms) from the db. + * Reset the render state. + */ + private function reset_render_state() + { + } + /** + * Enhances the Product Collection block with client-side pagination. * - * @param array $attributes Block attributes. Default empty array. - * @return array + * This function identifies Product Collection blocks and adds necessary data attributes + * to enable client-side navigation. It also enqueues the Interactivity API runtime. + * + * @param string $block_content The HTML content of the block. + * @param array $block Block details, including its attributes. + * + * @return string Updated block content with added interactivity attributes. */ - protected function get_categories($attributes) + public function enhance_product_collection_with_interactivity($block_content, $block) { } /** - * Build hierarchical tree of categories. + * Add a fallback store notices div to the block content. * - * @param array $categories List of terms. - * @param bool $children_only Is the block rendering only the children of the current category. - * @return array + * @param string $block_content The block content. + * @return string The updated block content. */ - protected function build_category_tree($categories, $children_only) + private function add_store_notices_fallback($block_content) { } /** - * Build hierarchical tree of categories by appending children in the tree. + * Render interactivity API powered notices that can be added client-side. This reuses classes + * from the woocommerce/store-notices block to ensure style consistency. * - * @param array $categories List of terms. - * @param array $categories_by_parent List of terms grouped by parent. - * @return array + * @return string The rendered store notices HTML. */ - protected function fill_category_children($categories, $categories_by_parent) + protected function render_interactivity_notices_region() { } /** - * Render the category list as a dropdown. + * Get the styles for the list element (fixed width). * - * @param array $categories List of terms. - * @param array $attributes Block attributes. Default empty array. - * @param int $uid Unique ID for the rendered block, used for HTML IDs. - * @return string Rendered output. + * @param string $fixed_width Fixed width value. + * @return string */ - protected function renderDropdown($categories, $attributes, $uid) + protected function get_list_styles($fixed_width) { } /** - * Render dropdown options list. + * Set the style attribute for fixed width. * - * @param array $categories List of terms. - * @param array $attributes Block attributes. Default empty array. - * @param int $uid Unique ID for the rendered block, used for HTML IDs. - * @param int $depth Current depth. - * @return string Rendered output. + * @param WP_HTML_Tag_Processor $p The HTML tag processor. + * @param string $fixed_width The fixed width value. */ - protected function renderDropdownOptions($categories, $attributes, $uid, $depth = 0) + private function set_fixed_width_style($p, $fixed_width) { } /** - * Render the category list as a list. + * Handle block dimensions if width type is set to 'fixed'. * - * @param array $categories List of terms. - * @param array $attributes Block attributes. Default empty array. - * @param int $uid Unique ID for the rendered block, used for HTML IDs. - * @param int $depth Current depth. - * @return string Rendered output. + * @param WP_HTML_Tag_Processor $p The HTML tag processor. + * @param array $block The block details. */ - protected function renderList($categories, $attributes, $uid, $depth = 0) + private function handle_block_dimensions($p, $block) { } /** - * Render a list of terms. + * Add interactive links to all anchors inside the Query Pagination block. + * This enabled client-side navigation for the product collection block. * - * @param array $categories List of terms. - * @param array $attributes Block attributes. Default empty array. - * @param int $uid Unique ID for the rendered block, used for HTML IDs. - * @param int $depth Current depth. - * @return string Rendered output. + * @param string $block_content The block content. + * @param array $block The full block, including name and attributes. + * @param \WP_Block $instance The block instance. */ - protected function renderListItems($categories, $attributes, $uid, $depth = 0) + public function add_navigation_link_directives($block_content, $block, $instance) { } /** - * Returns the category image html + * Provides the location context to each inner block of the product collection block. + * Hint: Only blocks using the 'query' context will be affected. * - * @param \WP_Term $category Term object. - * @param array $attributes Block attributes. Default empty array. - * @param string $size Image size, defaults to 'woocommerce_thumbnail'. - * @return string + * The sourceData structure depends on the context type as follows: + * - site: [ ] + * - order: [ 'orderId' => int ] + * - cart: [ 'productIds' => int[] ] + * - archive: [ 'taxonomy' => string, 'termId' => int ] + * - product: [ 'productId' => int ] + * + * @example array( + * 'type' => 'product', + * 'sourceData' => array( 'productId' => 123 ), + * ) + * + * @param array $context The block context. + * @return array $context { + * The block context including the product collection location context. + * + * @type array $productCollectionLocation { + * @type string $type The context type. Possible values are 'site', 'order', 'cart', 'archive', 'product'. + * @type array $sourceData The context source data. Can be the product ID of the viewed product, the order ID of the current order viewed, etc. See structure above for more details. + * } + * } */ - public function get_image_html($category, $attributes, $size = 'woocommerce_thumbnail') + public function extend_context_for_inner_blocks($context) { } /** - * Get the count, if displaying. + * Get the global location context. + * Serve as a runtime cache for the location context. * - * @param object $category Term object. - * @param array $attributes Block attributes. Default empty array. - * @return string + * @see ProductCollectionUtils::parse_frontend_location_context() + * + * @return array The location context. */ - protected function getCount($category, $attributes) + private function get_location_context() { } } /** - * ProductCategory class. + * Utility methods used for the Product Collection block. + * {@internal This class and its methods are not intended for public use.} */ - class ProductCategory extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractProductGrid + class Utils { /** - * Block name. + * Prepare and execute a query for the Product Collection block. + * This method is used by the Product Collection block and the No Results block. * - * @var string + * @param WP_Block $block Block instance. */ - protected $block_name = 'product-category'; + public static function prepare_and_execute_query($block) + { + } /** - * Set args specific to this block + * Helper function that constructs a WP_Query args array from + * a Product Collection or global query. * - * @param array $query_args Query args. + * @param WP_Block $block Block instance. + * @param int $page Current query's page. + * + * @return array Returns the constructed WP_Query arguments. */ - protected function set_block_query_args(&$query_args) + public static function get_query_vars($block, $page) { } /** - * Get block attributes. + * Remove query array from tax or meta query by searching for arrays that + * contain exact key => value pair. + * + * @param array $queries tax_query or meta_query. + * @param string $key Array key to search for. + * @param mixed $value Value to compare with search result. * * @return array */ - protected function get_block_type_attributes() + public static function remove_query_array($queries, $key, $value) + { + } + /** + * Parse WP Query's front-end context for the Product Collection block. + * + * The sourceData structure depends on the context type as follows: + * - site: [ ] + * - order: [ 'orderId' => int ] + * - cart: [ 'productIds' => int[] ] + * - archive: [ 'taxonomy' => string, 'termId' => int ] + * - product: [ 'productId' => int ] + * + * @return array $context { + * @type string $type The context type. Possible values are 'site', 'order', 'cart', 'archive', 'product'. + * @type array $sourceData The context source data. Can be the product ID of the viewed product, the order ID of the current order, etc. + * } + */ + public static function parse_frontend_location_context() + { + } + /** + * Remove falsy item from array, recursively. + * + * @param array $array The input array to filter. + */ + private static function remove_empty_array_recursive($array) { } } } -namespace Automattic\WooCommerce\Blocks\BlockTypes\ProductCollection { +namespace Automattic\WooCommerce\Blocks\BlockTypes { /** - * Controller class. + * ProductDescription class. */ - class Controller extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class ProductDescription extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { - use \Automattic\WooCommerce\Blocks\BlockTypes\EnableBlockJsonAssetsTrait; /** * Block name. * * @var string */ - protected $block_name = 'product-collection'; + protected $block_name = 'product-description'; /** - * Instance of HandlerRegistry. + * Keeps track of seen product IDs to prevent recursive rendering. * - * @var HandlerRegistry + * @var array */ - protected $collection_handler_registry; + private static $seen_ids = array(); /** - * Instance of QueryBuilder. + * Render the block. * - * @var QueryBuilder - */ - protected $query_builder; - /** - * Instance of Renderer. + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. * - * @var Renderer + * @return string Rendered block output. */ - protected $renderer; + protected function render($attributes, $content, $block) + { + } /** - * Initialize this block type. + * Disable the frontend stylesheet for this block type. It does not have one. * - * - Register hooks and filters. - * - Set up QueryBuilder, Renderer and HandlerRegistry. + * @return null */ - protected function initialize() + protected function get_block_type_style() { } /** - * Add interactivity to the Product Title block within Product Collection. - * This enables the triggering of a custom event when the product title is clicked. + * Disable the frontend script for this block type. It does not have one. * - * @param string $block_content The block content. - * @param array $block The full block, including name and attributes. - * @param \WP_Block $instance The block instance. - * @return string Modified block content with added interactivity. + * @param string|null $key The script key. + * + * @return null */ - public function add_product_title_click_event_directives($block_content, $block, $instance) + protected function get_block_type_script($key = null) { } + } + /** + * ProductDetails class. + */ + class ProductDetails extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + { /** - * Verifies if the inner block is compatible with Interactivity API. + * Block name. * - * @param string $block_name Name of the block to verify. - * @return boolean + * @var string */ - private function is_block_compatible($block_name) - { - } + protected $block_name = 'product-details'; /** - * Check inner blocks of Product Collection block if there's one - * incompatible with the Interactivity API and if so, disable client-side - * navigation. + * Initialize the block type. * - * @param array $parsed_block The block being rendered. - * @return string Returns the parsed block, unmodified. + * @return void */ - public function disable_enhanced_pagination($parsed_block) + protected function initialize() { } /** - * Extra data passed through from server to client for block. + * Get the frontend script handle for this block type. * - * @param array $attributes Any attributes that currently are available from the block. - * Note, this will be empty in the editor context when the block is - * not in the post content on editor load. + * @see $this->register_block_type() + * @param string $key Data to get, or default to everything. + * @return array|string|null */ - protected function enqueue_data(array $attributes = array()) + protected function get_block_type_script($key = null) { } /** - * Exposes settings used by the Product Collection block when manipulating - * the default query. + * Render the block. + * + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * + * @return string Rendered block output. */ - public function register_settings() + protected function render($attributes, $content, $block) { } /** - * Update the query for the product query block in Editor. + * Inject compatible tabs. * - * @param array $query Query args. - * @param WP_REST_Request $request Request. + * @param array $parsed_block Parsed block. + * + * @return array Parsed block. */ - public function update_rest_query_in_editor($query, $request): array + private function inject_compatible_tabs($parsed_block) { } /** - * Add support for filter blocks: - * - Price filter block - * - Attributes filter block - * - Rating filter block - * - In stock filter block etc. + * Create an accordion item block. * - * @param array $pre_render The pre-rendered block. - * @param array $parsed_block The parsed block. + * @param string $title Title of the accordion item. + * @param string $content Content of the accordion item as block markup. + * + * @return array Accordion item. */ - public function add_support_for_filter_blocks($pre_render, $parsed_block) + private function create_accordion_item_block($title, $content) { } /** - * Return a custom query based on attributes, filters and global WP_Query. + * Inject parsed accordion blocks. * - * @param WP_Query $query The WordPress Query. - * @param WP_Block $block The block being rendered. - * @param int $page The page number. + * @param array $parsed_block Parsed block. + * @param array $accordion_blocks Accordion blocks. * - * @return array + * @return array Parsed block. */ - public function build_frontend_query($query, $block, $page) + private function inject_parsed_accordion_blocks($parsed_block, $accordion_blocks) { } /** - * Extends allowed `collection_params` for the REST API - * - * By itself, the REST API doesn't accept custom `orderby` values, - * even if they are supported by a custom post type. + * Hide empty accordion items. * - * @param array $params A list of allowed `orderby` values. + * @param array $parsed_block Parsed block. + * @param array $context Context. * - * @return array + * @return array Parsed block. */ - public function extend_rest_query_allowed_params($params) + private function hide_empty_accordion_items($parsed_block, $context) { } /** - * Registers core collections and sets the handler store. + * Mark an accordion item as hidden if it has no content. + * + * @param array $item Item to mark. + * @param array $context Context. + * + * @return array Item. */ - protected function register_core_collections_and_set_handler_store() + private function mark_accordion_item_hidden($item, $context) { } - } - /** - * HandlerRegistry class. - * Manages collection handlers. - */ - class HandlerRegistry - { /** - * Associative array of collection handlers. + * Check if a parsed block has an accordion. * - * @var array + * @param array $parsed_block Parsed block. + * + * @return bool True if the block has an accordion, false otherwise. */ - protected $collection_handler_store = []; + private function has_accordion($parsed_block) + { + } /** - * Register handlers for a collection. + * Validate hooked blocks data. Remove duplicated entries with the same title + * and invalid entries with invalid content. Log errors to the WC logger. * - * @param string $collection_name The name of the collection. - * @param callable $build_query The query builder callable. - * @param callable|null $frontend_args Optional frontend args callable. - * @param callable|null $editor_args Optional editor args callable. - * @param callable|null $preview_query Optional preview query callable. + * @param array $hooked_blocks { Hooked blocks data. + * @type string $title Title of the hooked block. + * @type string $content Content of the hooked block, as block markup. + * } * - * @throws InvalidArgumentException If handlers are already registered for the collection. + * @return array Validated hooked blocks. */ - public function register_collection_handlers($collection_name, $build_query, $frontend_args = null, $editor_args = null, $preview_query = null) + private function validate_hooked_blocks($hooked_blocks) { } /** - * Register core collection handlers. + * Register a product details item using Block Hooks API. + * + * @param string $slug The slug of the item. + * @param array $block The block data. + * @return void */ - public function register_core_collections() + private function register_hooked_block($slug, $block) { } /** - * Get collection handler by name. + * Enqueue legacy assets when this block is used as we don't enqueue them for block themes anymore. * - * @param string $name Collection name. - * @return array|null Collection handler array or null if not found. + * @see https://github.com/woocommerce/woocommerce/pull/60223 */ - public function get_collection_handler($name) + public function enqueue_legacy_assets() { } /** - * Removes any custom collection handlers for the given collection. + * Previously, the Product Details block was a standalone block. It doesn't + * have any inner blocks and it rendered the tabs directly like the classic + * template. When upgrading, we want the existing stores using the block to + * continue working as before, so we moved the logic the legacy render + * method here. * - * @param string $collection_name The name of the collection to unregister. + * @see https://github.com/woocommerce/woocommerce/pull/59005 + * + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * + * @return string Rendered block output. */ - public function unregister_collection_handlers($collection_name) + protected function render_legacy_block($attributes, $content, $block) { } /** - * Get product IDs from an order. + * Gets the tabs with their content to be rendered by the block. * - * @param int $order_id The order ID. - * @return array The product IDs. + * @return string The tabs html to be rendered by the block */ - private function get_product_ids_from_order($order_id) + protected function render_tabs() { } } /** - * NoResults class. + * Product Filter: Active Block. */ - class NoResults extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + final class ProductFilterActive extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { /** * Block name. * * @var string */ - protected $block_name = 'product-collection-no-results'; - /** - * Render the block. - * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * - * @return string | void Rendered block output. - */ - protected function render($attributes, $content, $block) - { - } + protected $block_name = 'product-filter-active'; /** - * Get the frontend script handle for this block type. + * Render the block. * - * @param string $key Data to get, or default to everything. + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - protected function get_block_type_script($key = null) + protected function render($attributes, $content, $block) { } /** @@ -94525,960 +97657,875 @@ protected function get_block_type_style() { } /** - * Set the URL attributes for "clearing any filters" and "Store's home" links. + * Disable the editor style handle for this block type. * - * @param string $content Block content. + * @return null */ - protected function modify_anchor_tag_urls($content) + protected function get_block_type_editor_style() { } /** - * Get current URL without filter query parameters which will be used - * for the "clear any filters" link. + * Disable the script handle for this block type. We use block.json to load the script. + * + * @param string|null $key The key of the script to get. + * @return null */ - protected function get_current_url_without_filters() + protected function get_block_type_script($key = null) { } } /** - * QueryBuilder class. - * Responsible for constructing and modifying product queries. + * Product Filter: Attribute Block. */ - class QueryBuilder + final class ProductFilterAttribute extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { /** - * All query args from WP_Query. - * - * @var array - */ - protected $valid_query_vars; - /** - * Orderby options not natively supported by WordPress REST API - * - * @var array - */ - protected $custom_order_opts = array('popularity', 'rating', 'post__in', 'price', 'sales', 'menu_order', 'random'); - /** - * All the query args related to the filter by attributes block. + * Block name. * - * @var array + * @var string */ - protected $attributes_filter_query_args = array(); + protected $block_name = 'product-filter-attribute'; /** - * Collection handler store. + * Initialize this block type. * - * @var array - */ - protected $collection_handler_store = array(); - /** - * Constructor. + * - Hook into WP lifecycle. + * - Register the block with WordPress. */ - public function __construct() + protected function initialize() { } /** - * Set the collection handler store. + * Extra data passed through from server to client for block. * - * @param array $collection_handler_store The collection handler store containing registered collection handlers. + * @param array $attributes Any attributes that currently are available from the block. + * Note, this will be empty in the editor context when the block is + * not in the post content on editor load. */ - public function set_collection_handler_store($collection_handler_store) + protected function enqueue_data(array $attributes = array()) { } /** - * Set collection handler. + * Delete the default attribute id transient when the attribute taxonomies are deleted. * - * @param string $collection_name The name of the custom collection. - * @param array $handlers Collection handlers. + * @param string $transient The transient name. */ - public function set_collection_handler($collection_name, $handlers) + public function delete_default_attribute_id_transient($transient) { } /** - * Set attributes filter query args. + * Prepare the active filter items. * - * @param array $args The attributes filter query arguments. + * @param array $items The active filter items. + * @param array $params The query param parsed from the URL. + * @return array Active filters items. */ - public function set_attributes_filter_query_args($args) + public function prepare_selected_filters($items, $params) { } /** - * Return or initialize $valid_query_vars. + * Render the block. * - * @return array + * @param array $block_attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - private function get_valid_query_vars() + protected function render($block_attributes, $content, $block) { } /** - * Get custom order options. + * Retrieve the attribute count for current block. * - * @return array + * @param WP_Block $block Block instance. + * @param string $slug Attribute slug. + * @param string $query_type Query type, accept 'and' or 'or'. */ - public function get_custom_order_opts() + private function get_attribute_counts($block, $slug, $query_type) { } /** - * Get the final query arguments for the frontend. + * Get the attribute if with most term but closest to 30 terms. * - * @param array $collection_args Any special arguments that should change the behavior of the query. - * @param array $query The query arguments. - * @param int $page The page number. - * @param bool $is_exclude_applied_filters Whether to exclude the applied filters or not. + * @return object */ - public function get_final_frontend_query($collection_args, $query, $page = 1, $is_exclude_applied_filters = false) + private function get_default_product_attribute() { } /** - * Return a query to filter products by taxonomies (product categories, product tags, etc.) - * - * For example: - * User could provide "Product Categories" using "Filters" ToolsPanel available in Inspector Controls. - * We use this function to extract its query from $tax_query. - * - * For example, this is how the query for product categories will look like in $tax_query array: - * Array - * ( - * [taxonomy] => product_cat - * [terms] => Array - * ( - * [0] => 36 - * ) - * ) - * - * For product tags, taxonomy would be "product_tag" - * - * @param array $tax_query Query to filter products by taxonomies. - * @return array Query to filter products by taxonomies. + * Register pattern for default product attribute. */ - private function get_filter_by_taxonomies_query($tax_query): array + public function register_block_patterns() { } /** - * Get final query args based on provided values + * Disable the editor style handle for this block type. * - * @param array $collection_args Any special arguments that should change the behavior of the query. - * @param array $common_query_values Common query values. - * @param array $query Query from block context. - * @param bool $is_exclude_applied_filters Whether to exclude the applied filters or not. + * @return null */ - public function get_final_query_args($collection_args, $common_query_values, $query, $is_exclude_applied_filters = false) + protected function get_block_type_editor_style() { } /** - * Get query args for preview mode. These query args will be used with WP_Query to fetch the products. + * Disable the script handle for this block type. We use block.json to load the script. * - * @param array $collection_args Any collection-specific arguments. - * @param array $args Query args. - * @param WP_REST_Request $request Request. + * @param string|null $key The key of the script to get. + * @return null */ - public function get_preview_query_args($collection_args, $args, $request) + protected function get_block_type_script($key = null) { } + } + /** + * Product Filter: Checkbox List Block. + */ + final class ProductFilterCheckboxList extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + { + use \Automattic\WooCommerce\Blocks\BlockTypes\EnableBlockJsonAssetsTrait; /** - * Return a query for products depending on their stock status. + * Block name. * - * @param array $stock_statuses An array of acceptable stock statuses. - * @return array + * @var string */ - private function get_stock_status_query($stock_statuses) - { - } + protected $block_name = 'product-filter-checkbox-list'; /** - * Merge tax_queries from various queries. + * Render the block. * - * @param array ...$queries Query arrays to be merged. - * @return array + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - private function merge_tax_queries(...$queries) + protected function render($attributes, $content, $block) { } /** - * Return the `tax_query` for the requested attributes - * - * @param array $attributes Attributes and their terms. + * Disable the style handle for this block type. We use block.json to load the style. * - * @return array + * @return null */ - private function get_product_attributes_query($attributes = array()) + protected function get_block_type_style() { } /** - * Generates a tax query to filter products based on their "featured" status. - * If the `$featured` parameter is true, the function will return a tax query - * that filters products to only those marked as featured. - * If `$featured` is false, an empty array is returned, meaning no filtering will be applied. + * Get aria label for filter item. * - * @param bool $featured A flag indicating whether to filter products based on featured status. + * @param array $item Filter item. + * @param bool $show_counts Whether to show counts. * - * @return array A tax query for fetching featured products if `$featured` is true; otherwise, an empty array. + * @return string Aria label. */ - private function get_featured_query($featured) + private function get_aria_label($item, $show_counts) { } + } + /** + * Product Filter: Chips Block. + */ + final class ProductFilterChips extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + { + use \Automattic\WooCommerce\Blocks\BlockTypes\EnableBlockJsonAssetsTrait; /** - * Return a query that filters products by price. + * Block name. * - * @return array + * @var string */ - private function get_filter_by_price_query() - { - } + protected $block_name = 'product-filter-chips'; /** - * Return a query that filters products by attributes. + * Render the block. * - * @return array + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - private function get_filter_by_attributes_query() + protected function render($attributes, $content, $block) { } /** - * Get all the query args related to the filter by attributes block. + * Get aria label for filter item. * - * @return array - * [color] => Array - * ( - * [filter] => filter_color - * [query_type] => query_type_color - * ) + * @param array $item Filter item. + * @param bool $show_counts Whether to show counts. * - * [size] => Array - * ( - * [filter] => filter_size - * [query_type] => query_type_size - * ) - * ) + * @return string Aria label. */ - private function get_filter_by_attributes_query_vars() + private function get_aria_label($item, $show_counts) { } + } + /** + * Product Filter: Clear Button Block. + */ + final class ProductFilterClearButton extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + { /** - * Return a query that filters products by stock status. + * Block name. * - * @return array + * @var string */ - private function get_filter_by_stock_status_query() - { - } + protected $block_name = 'product-filter-clear-button'; /** - * Return a query that filters products by rating. + * Get the frontend script handle for this block type. * - * @return array + * @param string $key Data to get, or default to everything. + * + * @return null */ - private function get_filter_by_rating_query() + protected function get_block_type_script($key = null) { } /** - * Merge two array recursively but replace the non-array values instead of - * merging them. The merging strategy: - * - * - If keys from merge array doesn't exist in the base array, create them. - * - For array items with numeric keys, we merge them as normal. - * - For array items with string keys: - * - * - If the value isn't array, we'll use the value coming from the merge array. - * $base = ['orderby' => 'date'] - * $new_array = ['orderby' => 'meta_value_num'] - * Result: ['orderby' => 'meta_value_num'] - * - * - If the value is array, we'll use recursion to merge each key. - * $base = ['meta_query' => [ - * [ - * 'key' => '_stock_status', - * 'compare' => 'IN' - * 'value' => ['instock', 'onbackorder'] - * ] - * ]] - * $new_array = ['meta_query' => [ - * [ - * 'relation' => 'AND', - * [...], - * [...], - * ] - * ]] - * Result: ['meta_query' => [ - * [ - * 'key' => '_stock_status', - * 'compare' => 'IN' - * 'value' => ['instock', 'onbackorder'] - * ], - * [ - * 'relation' => 'AND', - * [...], - * [...], - * ] - * ]] - * - * $base = ['post__in' => [1, 2, 3, 4, 5]] - * $new_array = ['post__in' => [3, 4, 5, 6, 7]] - * Result: ['post__in' => [1, 2, 3, 4, 5, 3, 4, 5, 6, 7]] + * Include and render the block. * - * @param array $base First array. - * @param array $new_array Second array. + * @param array $attributes Block attributes. Default empty array. + * @param string $content Block content. Default empty string. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - private function array_merge_recursive_replace_non_array_properties($base, $new_array) + protected function render($attributes, $content, $block) { } + } + /** + * Product Filter: Price Block. + */ + final class ProductFilterPrice extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + { + use \Automattic\WooCommerce\Blocks\BlockTypes\EnableBlockJsonAssetsTrait; /** - * Return queries that are generated by query args. + * Block name. * - * @return array + * @var string */ - private function get_queries_by_applied_filters() - { - } + protected $block_name = 'product-filter-price'; + const MIN_PRICE_QUERY_VAR = 'min_price'; + const MAX_PRICE_QUERY_VAR = 'max_price'; /** - * Return a query for product visibility depending on their stock status. - * - * @param array $stock_query Stock status query. - * @param array $stock_status Selected stock status. + * Initialize this block type. * - * @return array Tax query for product visibility. + * - Hook into WP lifecycle. + * - Register the block with WordPress. */ - private function get_product_visibility_query($stock_query, $stock_status) + protected function initialize() { } /** - * Constructs a date query for product filtering based on a specified time frame. - * - * @param array $time_frame { - * Associative array with 'operator' (in or not-in) and 'value' (date string). + * Prepare the active filter items. * - * @type string $operator Determines the inclusion or exclusion of the date range. - * @type string $value The date around which the range is applied. - * } - * @return array Date query array; empty if parameters are invalid. + * @param array $items The active filter items. + * @param array $params The query param parsed from the URL. + * @return array Active filters items. */ - private function get_date_query(array $time_frame): array + public function prepare_selected_filters($items, $params) { } /** - * Get query arguments for price range filter. - * We are adding these extra query arguments to be used in `posts_clauses` - * because there are 2 special edge cases we wanna handle for Price range filter: - * Case 1: Prices excluding tax are displayed including tax - * Case 2: Prices including tax are displayed excluding tax - * - * Both of these cases require us to modify SQL query to get the correct results. - * - * See add_price_range_filter_posts_clauses function in this file for more details. + * Render the block. * - * @param array $price_range Price range with min and max values. - * @return array Query arguments. + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - public function get_price_range_query_args($price_range) + protected function render($attributes, $content, $block) { } /** - * Add the `posts_clauses` filter to the main query. + * Retrieve the price filter data for current block. * - * @param array $clauses The query clauses. - * @param WP_Query $query The WP_Query instance. + * @param WP_Block $block Block instance. */ - public function add_price_range_filter_posts_clauses($clauses, $query) + private function get_filtered_price($block) { } + } + /** + * ProductFilterPriceSlider class. + */ + class ProductFilterPriceSlider extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + { + use \Automattic\WooCommerce\Blocks\BlockTypes\EnableBlockJsonAssetsTrait; /** - * Get query for price filters when dealing with displayed taxes. + * Block name. * - * @param float $price_filter Price filter to apply. - * @param string $column Price being filtered (min or max). - * @param string $operator Comparison operator for column. - * @return string Constructed query. + * @var string */ - protected function get_price_filter_query_for_displayed_taxes($price_filter, $column = 'min_price', $operator = '>=') - { - } + protected $block_name = 'product-filter-price-slider'; /** - * Adjusts a price filter based on a tax class and whether or not the amount includes or excludes taxes. - * - * This calculation logic is based on `wc_get_price_excluding_tax` and `wc_get_price_including_tax` in core. + * Render the block. * - * @param float $price_filter Price filter amount as entered. - * @param string $tax_class Tax class for adjustment. - * @return float + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - protected function adjust_price_filter_for_tax_class($price_filter, $tax_class) + protected function render($attributes, $content, $block) { } + } + /** + * Product Filter: Rating Block + * + * @package Automattic\WooCommerce\Blocks\BlockTypes + */ + final class ProductFilterRating extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + { /** - * Determines if price filters need adjustment based on the tax display settings. - * - * This function checks if there's a discrepancy between how prices are stored in the database - * and how they are displayed to the user, specifically with respect to tax inclusion or exclusion. - * It returns true if an adjustment is needed, indicating that the price filters should account for this - * discrepancy to display accurate prices. + * Block name. * - * @return bool True if the price filters need to be adjusted for tax display settings, false otherwise. + * @var string */ - private function should_adjust_price_range_for_taxes() - { - } + protected $block_name = 'product-filter-rating'; + const RATING_FILTER_QUERY_VAR = 'rating_filter'; /** - * Generates a post__in query to filter products to the set of provided IDs. - * - * @param int[]|false $handpicked_products The products to filter. + * Initialize this block type. * - * @return array The post__in query. + * - Hook into WP lifecycle. + * - Register the block with WordPress. */ - private function get_handpicked_query($handpicked_products) + protected function initialize() { } /** - * Return a query for on sale products. - * - * @param bool $is_on_sale Whether to query for on sale products. + * Prepare the active filter items. * - * @return array + * @param array $items The active filter items. + * @param array $params The query param parsed from the URL. + * @return array Active filters items. */ - private function get_on_sale_products_query($is_on_sale) + public function prepare_selected_filters($items, $params) { } /** - * Merge in the first parameter the keys "post_in", "meta_query" and "tax_query" of the second parameter. + * Include and render the block. * - * @param array[] ...$queries Query arrays to be merged. - * @return array + * @param array $attributes Block attributes. Default empty array. + * @param string $content Block content. Default empty string. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - private function merge_queries(...$queries) + protected function render($attributes, $content, $block) { } /** - * Return query params to support custom sort values - * - * @param string $orderby Sort order option. + * Render the rating label. * - * @return array + * @param int $rating The rating to render. + * @return string|false */ - private function get_custom_orderby_query($orderby) + private function render_rating_label($rating) { } /** - * Add the `posts_clauses` filter to add price-based sorting + * Retrieve the rating filter data for current block. * - * @param array $clauses The list of clauses for the query. - * @param WP_Query $query The WP_Query instance. - * @return array Modified list of clauses. + * @param WP_Block $block Block instance. */ - public function add_price_sorting_posts_clauses($clauses, $query) + private function get_rating_counts($block) { } /** - * Add the `posts_clauses` filter to add sales-based sorting + * Disable the editor style handle for this block type. * - * @param array $clauses The list of clauses for the query. - * @param WP_Query $query The WP_Query instance. - * @return array Modified list of clauses. + * @return null */ - public function add_sales_sorting_posts_clauses($clauses, $query) + protected function get_block_type_editor_style() { } /** - * Join wc_product_meta_lookup to posts if not already joined. + * Disable the script handle for this block type. We use block.json to load the script. * - * @param string $sql SQL join. - * @return string + * @param string|null $key The key of the script to get. + * @return null */ - protected function append_product_sorting_table_join($sql) + protected function get_block_type_script($key = null) { } + } + /** + * Product Filter: Removable Chips Block. + */ + final class ProductFilterRemovableChips extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + { + use \Automattic\WooCommerce\Blocks\BlockTypes\EnableBlockJsonAssetsTrait; /** - * Merge all of the 'post__in' values and return an array containing only values that are present in all arrays. - * - * @param int[][] ...$post__in The 'post__in' values to be merged. + * Block name. * - * @return int[] The merged 'post__in' values. + * @var string */ - private function merge_post__in(...$post__in) - { - } + protected $block_name = 'product-filter-removable-chips'; /** - * Add the `posts_clauses` filter to add menu order with title fallback sorting + * Render the block. * - * @param array $clauses The list of clauses for the query. - * @param WP_Query $query The WP_Query instance. - * @return array Modified list of clauses. + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - public function add_menu_order_with_title_fallback_posts_clauses($clauses, $query) + protected function render($attributes, $content, $block) { } } /** - * Renderer class. - * Handles rendering of the block and adds interactivity. + * Product Filter: Status Block. */ - class Renderer + final class ProductFilterStatus extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { /** - * The render state of the product collection block. + * Block name. * - * @var array + * @var string */ - private $render_state = array('has_results' => false, 'has_no_results_block' => false); + protected $block_name = 'product-filter-status'; + const STOCK_STATUS_QUERY_VAR = 'filter_stock_status'; /** - * The Block with its attributes before it gets rendered + * Initialize this block type. * - * @var array - */ - protected $parsed_block; - /** - * Constructor. + * - Hook into WP lifecycle. + * - Register the block with WordPress. */ - public function __construct() + protected function initialize() { } /** - * Set the parsed block. + * Prepare the active filter items. * - * @param array $block The block to be parsed. + * @param array $items The active filter items. + * @param array $params The query param parsed from the URL. + * @return array Active filters items. */ - public function set_parsed_block($block) + public function prepare_selected_filters($items, $params) { } /** - * Handle the rendering of the block. - * - * @param string $block_content The block content about to be rendered. - * @param array $block The block being rendered. + * Extra data passed through from server to client for block. * - * @return string + * @param array $stock_statuses Any stock statuses that currently are available from the block. + * Note, this will be empty in the editor context when the block is + * not in the post content on editor load. */ - public function handle_rendering($block_content, $block) + protected function enqueue_data(array $stock_statuses = array()) { } /** - * Check if the block should be prevented from rendering. + * Include and render the block. * - * @return bool + * @param array $attributes Block attributes. Default empty array. + * @param string $content Block content. Default empty string. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - private function should_prevent_render() + protected function render($attributes, $content, $block) { } /** - * Reset the render state. + * Retrieve the status filter data for current block. + * + * @param WP_Block $block Block instance. */ - private function reset_render_state() + private function get_stock_status_counts($block) { } /** - * Enhances the Product Collection block with client-side pagination. - * - * This function identifies Product Collection blocks and adds necessary data attributes - * to enable client-side navigation. It also enqueues the Interactivity API runtime. - * - * @param string $block_content The HTML content of the block. - * @param array $block Block details, including its attributes. + * Disable the editor style handle for this block type. * - * @return string Updated block content with added interactivity attributes. + * @return null */ - public function enhance_product_collection_with_interactivity($block_content, $block) + protected function get_block_type_editor_style() { } /** - * Add a fallback store notices div to the block content. + * Disable the script handle for this block type. We use block.json to load the script. * - * @param string $block_content The block content. - * @return string The updated block content. + * @param string|null $key The key of the script to get. + * @return null */ - private function add_store_notices_fallback($block_content) + protected function get_block_type_script($key = null) { } + } + /** + * Product Filter: Taxonomy Block. + */ + final class ProductFilterTaxonomy extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + { /** - * Render interactivity API powered notices that can be added client-side. This reuses classes - * from the woocommerce/store-notices block to ensure style consistency. + * Block name. * - * @return string The rendered store notices HTML. + * @var string */ - protected function render_interactivity_notices_region() + protected $block_name = 'product-filter-taxonomy'; + /** + * Prepare the active filter items. + * + * @internal For exclusive usage of WooCommerce core, backwards compatibility not guaranteed. + * + * @param array $items The active filter items. + * @param array $params The query param parsed from the URL. + * @return array Active filters items. + */ + public function prepare_selected_filters($items, $params) { } /** - * Get the styles for the list element (fixed width). + * Initialize this block type. * - * @param string $fixed_width Fixed width value. - * @return string + * - Hook into WP lifecycle. + * - Register the block with WordPress. */ - protected function get_list_styles($fixed_width) + protected function initialize() { } /** - * Set the style attribute for fixed width. + * Extra data passed through from server to client for block. * - * @param WP_HTML_Tag_Processor $p The HTML tag processor. - * @param string $fixed_width The fixed width value. + * @param array $attributes Any attributes that currently are available from the block. + * Note, this will be empty in the editor context when the block is + * not in the post content on editor load. */ - private function set_fixed_width_style($p, $fixed_width) + protected function enqueue_data(array $attributes = array()) { } /** - * Handle block dimensions if width type is set to 'fixed'. + * Get the frontend script handle for this block type. * - * @param WP_HTML_Tag_Processor $p The HTML tag processor. - * @param array $block The block details. + * @see $this->register_block_type() + * @param string $key Data to get, or default to everything. + * @return array|string|null */ - private function handle_block_dimensions($p, $block) + protected function get_block_type_script($key = null) { } /** - * Add interactive links to all anchors inside the Query Pagination block. - * This enabled client-side navigation for the product collection block. + * Render the block. * - * @param string $block_content The block content. - * @param array $block The full block, including name and attributes. - * @param \WP_Block $instance The block instance. + * @param array $block_attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - public function add_navigation_link_directives($block_content, $block, $instance) + protected function render($block_attributes, $content, $block) { } /** - * Provides the location context to each inner block of the product collection block. - * Hint: Only blocks using the 'query' context will be affected. - * - * The sourceData structure depends on the context type as follows: - * - site: [ ] - * - order: [ 'orderId' => int ] - * - cart: [ 'productIds' => int[] ] - * - archive: [ 'taxonomy' => string, 'termId' => int ] - * - product: [ 'productId' => int ] - * - * @example array( - * 'type' => 'product', - * 'sourceData' => array( 'productId' => 123 ), - * ) - * - * @param array $context The block context. - * @return array $context { - * The block context including the product collection location context. + * Get terms sorted based on taxonomy type (hierarchical vs flat). * - * @type array $productCollectionLocation { - * @type string $type The context type. Possible values are 'site', 'order', 'cart', 'archive', 'product'. - * @type array $sourceData The context source data. Can be the product ID of the viewed product, the order ID of the current order viewed, etc. See structure above for more details. - * } - * } + * @param string $taxonomy Taxonomy slug. + * @param array $taxonomy_counts Term counts with term_id as key. + * @param bool $hide_empty Whether to hide empty terms. + * @param string $orderby Sort field (name, count, menu_order). + * @param string $order Sort direction (ASC, DESC). + * @return array Sorted terms array. */ - public function extend_context_for_inner_blocks($context) + private function get_sorted_terms($taxonomy, $taxonomy_counts, $hide_empty, $orderby, $order) { } /** - * Get the global location context. - * Serve as a runtime cache for the location context. - * - * @see ProductCollectionUtils::parse_frontend_location_context() + * Retrieve the taxonomy term counts for current block. * - * @return array The location context. + * @param WP_Block $block Block instance. + * @param string $taxonomy Taxonomy slug. + * @return array Term counts with term_id as key and count as value. */ - private function get_location_context() + private function get_taxonomy_term_counts($block, $taxonomy) { } - } - /** - * Utility methods used for the Product Collection block. - * {@internal This class and its methods are not intended for public use.} - */ - class Utils - { /** - * Prepare and execute a query for the Product Collection block. - * This method is used by the Product Collection block and the No Results block. + * Get product taxonomies for the block. * - * @param WP_Block $block Block instance. + * @return array */ - public static function prepare_and_execute_query($block) + private function get_taxonomies() { } /** - * Helper function that constructs a WP_Query args array from - * a Product Collection or global query. - * - * @param WP_Block $block Block instance. - * @param int $page Current query's page. + * Sort hierarchical terms recursively maintaining parent-child relationships. * - * @return array Returns the constructed WP_Query arguments. + * @param array $terms Hierarchical terms array with children. + * @param string $orderby Sort field (name, count, menu_order). + * @param string $order Sort direction (ASC, DESC). + * @param array $taxonomy_counts Context-aware term counts. + * @return array Sorted hierarchical terms. */ - public static function get_query_vars($block, $page) + private function sort_hierarchy_terms($terms, $orderby, $order, $taxonomy_counts) { } /** - * Remove query array from tax or meta query by searching for arrays that - * contain exact key => value pair. - * - * @param array $queries tax_query or meta_query. - * @param string $key Array key to search for. - * @param mixed $value Value to compare with search result. + * Flatten hierarchical term tree into flat array maintaining depth-first order. * - * @return array + * @param array $terms Hierarchical terms with children structure. + * @param array $result Reference to result array being built. + * @param array $visited_ids Reference to array tracking visited term IDs to prevent circular references. + * @param int $depth Current recursion depth for bounds checking. */ - public static function remove_query_array($queries, $key, $value) + private function flatten_terms_list($terms, &$result, &$visited_ids = array(), $depth = 0) { } /** - * Parse WP Query's front-end context for the Product Collection block. - * - * The sourceData structure depends on the context type as follows: - * - site: [ ] - * - order: [ 'orderId' => int ] - * - cart: [ 'productIds' => int[] ] - * - archive: [ 'taxonomy' => string, 'termId' => int ] - * - product: [ 'productId' => int ] + * Get taxonomy terms ordered hierarchically. * - * @return array $context { - * @type string $type The context type. Possible values are 'site', 'order', 'cart', 'archive', 'product'. - * @type array $sourceData The context source data. Can be the product ID of the viewed product, the order ID of the current order, etc. - * } + * @param string $taxonomy Taxonomy slug. + * @param array $taxonomy_counts Term counts with term_id as key. + * @param bool $hide_empty Whether to hide empty terms. + * @param string $orderby Sort field for siblings (name, count, menu_order). + * @param string $order Sort direction (ASC, DESC). + * @return array|\WP_Error Hierarchically ordered terms or error. */ - public static function parse_frontend_location_context() + private function get_hierarchical_terms(string $taxonomy, array $taxonomy_counts, bool $hide_empty, string $orderby, string $order) { } /** - * Remove falsy item from array, recursively. + * Sort terms by the specified criteria (name or count). * - * @param array $array The input array to filter. + * @param array $terms Array of term objects to sort. + * @param string $orderby Sort field (name, count, menu_order). + * @param string $order Sort direction (ASC, DESC). + * @param array $taxonomy_counts Context-aware term counts. + * @return array Sorted terms. */ - private static function remove_empty_array_recursive($array) + private function sort_terms_by_criteria(array $terms, string $orderby, string $order, array $taxonomy_counts): array { } } -} -namespace Automattic\WooCommerce\Blocks\BlockTypes { /** - * BlockifiedProductDetails class. + * ProductFilters class. */ - class ProductDescription extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class ProductFilters extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { + use \Automattic\WooCommerce\Blocks\Utils\BlocksSharedState; /** * Block name. * * @var string */ - protected $block_name = 'product-description'; + protected $block_name = 'product-filters'; /** - * Keeps track of seen product IDs to prevent recursive rendering. + * Register the context. * - * @var array + * @return string[] */ - private static $seen_ids = array(); + protected function get_block_type_uses_context() + { + } /** - * Render the block. - * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. + * Extra data passed through from server to client for block. * - * @return string Rendered block output. + * @param array $attributes Any attributes that currently are available from the block. + * Note, this will be empty in the editor context when the block is + * not in the post content on editor load. */ - protected function render($attributes, $content, $block) + protected function enqueue_data(array $attributes = array()) { } /** - * Disable the frontend stylesheet for this block type. It does not have one. + * Include and render the block. * - * @return null + * @param array $attributes Block attributes. Default empty array. + * @param string $content Block content. Default empty string. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - protected function get_block_type_style() + protected function render($attributes, $content, $block) { } /** - * Disable the frontend script for this block type. It does not have one. - * - * @param string|null $key The script key. + * Get SVG icon markup for a given icon name. * - * @return null + * @param string $name The name of the icon to retrieve. + * @return string SVG markup for the icon, or empty string if icon not found. */ - protected function get_block_type_script($key = null) + private function get_svg_icon(string $name) { } - } - /** - * ProductDetails class. - */ - class ProductDetails extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock - { /** - * Block name. + * Generate a unique navigation ID for the block. * - * @var string + * @param mixed $block - Block instance. + * @return string - Unique navigation ID. */ - protected $block_name = 'product-details'; + private function generate_navigation_id($block) + { + } /** - * Initialize the block type. + * Parse the filter parameters from the URL. + * For now we only get the global query params from the URL. In the future, + * we should get the query params based on $query_id. * - * @return void + * @param int $query_id Query ID. + * @return array Parsed filter params. */ - protected function initialize() + private function get_filter_params($query_id) { } /** - * Get the frontend script handle for this block type. + * Disable the style handle for this block type. We use block.json to load the style. * - * @see $this->register_block_type() - * @param string $key Data to get, or default to everything. - * @return array|string|null + * @return null */ - protected function get_block_type_script($key = null) + protected function get_block_type_style() { } /** - * Render the block. - * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. + * Disable the editor style handle for this block type. We use block.json to load the style. * - * @return string Rendered block output. + * @return null */ - protected function render($attributes, $content, $block) + protected function get_block_type_editor_style() { } /** - * Inject compatible tabs. - * - * @param array $parsed_block Parsed block. + * Disable the script handle for this block type. We use block.json to load the script. * - * @return array Parsed block. + * @param string|null $key The key of the script to get. + * @return null */ - private function inject_compatible_tabs($parsed_block) + protected function get_block_type_script($key = null) { } /** - * Create an accordion item block. - * - * @param string $title Title of the accordion item. - * @param string $content Content of the accordion item as block markup. + * Get the canonical URL without pagination. * - * @return array Accordion item. + * @param array $filter_params Filter parameters. + * @return string Canonical URL without pagination. */ - private function create_accordion_item_block($title, $content) + private function get_canonical_url_no_pagination($filter_params) { } + } + /** + * ProductGallery class. + */ + class ProductGallery extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + { + use \Automattic\WooCommerce\Blocks\BlockTypes\EnableBlockJsonAssetsTrait; /** - * Inject parsed accordion blocks. + * Block name. * - * @param array $parsed_block Parsed block. - * @param array $accordion_blocks Accordion blocks. + * @var string + */ + protected $block_name = 'product-gallery'; + /** + * Register the context * - * @return array Parsed block. + * @return string[] */ - private function inject_parsed_accordion_blocks($parsed_block, $accordion_blocks) + protected function get_block_type_uses_context() { } /** - * Hide empty accordion items. - * - * @param array $parsed_block Parsed block. - * @param array $context Context. + * Return the dialog content. * - * @return array Parsed block. + * @param array $images An array of all images of the product. + * @return string */ - private function hide_empty_accordion_items($parsed_block, $context) + protected function render_dialog($images) { } /** - * Mark an accordion item as hidden if it has no content. + * Inject dialog into the product gallery HTML. * - * @param array $item Item to mark. - * @param array $context Context. + * @param string $gallery_html The gallery HTML. + * @param string $dialog_html The dialog HTML. * - * @return array Item. + * @return string */ - private function mark_accordion_item_hidden($item, $context) + protected function inject_dialog($gallery_html, $dialog_html) { } /** - * Check if a parsed block has an accordion. - * - * @param array $parsed_block Parsed block. + * Include and render the block. * - * @return bool True if the block has an accordion, false otherwise. + * @param array $attributes Block attributes. Default empty array. + * @param string $content Block content. Default empty string. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - private function has_accordion($parsed_block) + protected function render($attributes, $content, $block) { } + } + /** + * ProductGalleryLargeImage class. + */ + class ProductGalleryLargeImage extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + { + use \Automattic\WooCommerce\Blocks\BlockTypes\EnableBlockJsonAssetsTrait; /** - * Validate hooked blocks data. Remove duplicated entries with the same title - * and invalid entries with invalid content. Log errors to the WC logger. - * - * @param array $hooked_blocks { Hooked blocks data. - * @type string $title Title of the hooked block. - * @type string $content Content of the hooked block, as block markup. - * } + * Block name. * - * @return array Validated hooked blocks. + * @var string */ - private function validate_hooked_blocks($hooked_blocks) - { - } + protected $block_name = 'product-gallery-large-image'; /** - * Register a product details item using Block Hooks API. + * Register the context * - * @param string $slug The slug of the item. - * @param array $block The block data. - * @return void + * @return string[] */ - private function register_hooked_block($slug, $block) + protected function get_block_type_uses_context() { } /** - * Enqueue legacy assets when this block is used as we don't enqueue them for block themes anymore. + * Initialize this block type. * - * @see https://github.com/woocommerce/woocommerce/pull/60223 + * - Hook into WP lifecycle. + * - Register the block with WordPress. + * - Hook into pre_render_block to update the query. */ - public function enqueue_legacy_assets() + protected function initialize() { } /** - * Previously, the Product Details block was a standalone block. It doesn't - * have any inner blocks and it rendered the tabs directly like the classic - * template. When upgrading, we want the existing stores using the block to - * continue working as before, so we moved the logic the legacy render - * method here. - * - * @see https://github.com/woocommerce/woocommerce/pull/59005 - * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. + * Enqueue frontend assets for this block, just in time for rendering. * - * @return string Rendered block output. + * @param array $attributes Any attributes that currently are available from the block. + * @param string $content The block content. + * @param WP_Block $block The block object. */ - protected function render_legacy_block($attributes, $content, $block) + protected function enqueue_assets(array $attributes, $content, $block) { } /** - * Gets the tabs with their content to be rendered by the block. + * Include and render the block. * - * @return string The tabs html to be rendered by the block + * @param array $attributes Block attributes. Default empty array. + * @param string $content Block content. Default empty string. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - protected function render_tabs() + protected function render($attributes, $content, $block) { } - } - /** - * Product Filter: Active Block. - */ - final class ProductFilterActive extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock - { /** - * Block name. + * Update the single image html. * - * @var string + * @param string $image_html The image html. + * @param array $context The block context. + * @param int $index The index of the image. + * @return string */ - protected $block_name = 'product-filter-active'; + private function update_single_image($image_html, $context, $index) + { + } /** - * Render the block. + * Get the main images html code. The first element of the array contains the HTML of the first image that is visible, the second element contains the HTML of the other images that are hidden. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @param array $context The block context. + * @param \WC_Product $product The product object. + * @param WP_Block $inner_block The inner block object. + * @return array */ - protected function render($attributes, $content, $block) + private function get_main_images_html($context, $product, $inner_block) { } /** - * Get the frontend style handle for this block type. + * Get the main images html code. The first element of the array contains the HTML of the first image that is visible, the second element contains the HTML of the other images that are hidden. * - * @return null + * @param array $context The block context. + * @param \WC_Product $product The product object. + * + * @return array */ - protected function get_block_type_style() + private function legacy_get_main_images_html($context, $product) { } /** @@ -95490,213 +98537,187 @@ protected function get_block_type_editor_style() { } /** - * Disable the script handle for this block type. We use block.json to load the script. + * Large Image renders inner blocks manually so we need to skip default + * rendering routine for its inner blocks * - * @param string|null $key The key of the script to get. - * @return null + * @param array $settings Array of determined settings for registering a block type. + * @param array $metadata Metadata provided for registering a block type. + * @return array */ - protected function get_block_type_script($key = null) + public function add_block_type_metadata_settings($settings, $metadata) { } } /** - * Product Filter: Attribute Block. + * ProductGalleryThumbnails class. */ - final class ProductFilterAttribute extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class ProductGalleryThumbnails extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { + use \Automattic\WooCommerce\Blocks\BlockTypes\EnableBlockJsonAssetsTrait; /** * Block name. * * @var string */ - protected $block_name = 'product-filter-attribute'; + protected $block_name = 'product-gallery-thumbnails'; /** - * Initialize this block type. + * Register the context * - * - Hook into WP lifecycle. - * - Register the block with WordPress. + * @return string[] */ - protected function initialize() + protected function get_block_type_uses_context() { } /** - * Extra data passed through from server to client for block. + * Include and render the block. * - * @param array $attributes Any attributes that currently are available from the block. - * Note, this will be empty in the editor context when the block is - * not in the post content on editor load. + * @param array $attributes Block attributes. Default empty array. + * @param string $content Block content. Default empty string. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - protected function enqueue_data(array $attributes = array()) + protected function render($attributes, $content, $block) { } + } + /** + * ProductImage class. + */ + class ProductImage extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + { /** - * Delete the default attribute id transient when the attribute taxonomies are deleted. + * Block name. * - * @param string $transient The transient name. + * @var string */ - public function delete_default_attribute_id_transient($transient) - { - } + protected $block_name = 'product-image'; /** - * Prepare the active filter items. + * API version name. * - * @param array $items The active filter items. - * @param array $params The query param parsed from the URL. - * @return array Active filters items. + * @var string */ - public function prepare_selected_filters($items, $params) - { - } + protected $api_version = '3'; /** - * Render the block. - * - * @param array $block_attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * It is necessary to register and enqueues assets during the render phase because we want to load assets only if the block has the content. */ - protected function render($block_attributes, $content, $block) + protected function register_block_type_assets() { } /** - * Retrieve the attribute count for current block. - * - * @param WP_Block $block Block instance. - * @param string $slug Attribute slug. - * @param string $query_type Query type, accept 'and' or 'or'. + * Register the context. */ - private function get_attribute_counts($block, $slug, $query_type) + protected function get_block_type_uses_context() { } /** - * Get the attribute if with most term but closest to 30 terms. + * Get the block's attributes. * - * @return object - */ - private function get_default_product_attribute() - { - } - /** - * Register pattern for default product attribute. + * @param array $attributes Block attributes. Default empty array. + * @return array Block attributes merged with defaults. */ - public function register_block_patterns() + private function parse_attributes($attributes) { } /** - * Disable the editor style handle for this block type. + * Render on Sale Badge. * - * @return null + * @param \WC_Product $product Product object. + * @param array $attributes Attributes. + * @return string */ - protected function get_block_type_editor_style() + private function render_on_sale_badge($product, $attributes) { } /** - * Disable the script handle for this block type. We use block.json to load the script. + * Render anchor. * - * @param string|null $key The key of the script to get. - * @return null + * @param \WC_Product $product Product object. + * @param string $on_sale_badge Return value from $render_image. + * @param string $product_image Return value from $render_on_sale_badge. + * @param array $attributes Attributes. + * @param string $inner_blocks_content Rendered HTML of inner blocks. + * @return string */ - protected function get_block_type_script($key = null) + private function render_anchor($product, $on_sale_badge, $product_image, $attributes, $inner_blocks_content) { } - } - /** - * Product Filter: Checkbox List Block. - */ - final class ProductFilterCheckboxList extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock - { - use \Automattic\WooCommerce\Blocks\BlockTypes\EnableBlockJsonAssetsTrait; - /** - * Block name. - * - * @var string - */ - protected $block_name = 'product-filter-checkbox-list'; /** - * Render the block. + * Render Image. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @param \WC_Product $product Product object. + * @param array $attributes Parsed attributes. + * @param int|null $image_id Optional image ID from context. + * @return string */ - protected function render($attributes, $content, $block) + private function render_image($product, $attributes, $image_id = null) { } /** - * Disable the style handle for this block type. We use block.json to load the style. + * Extra data passed through from server to client for block. * - * @return null + * @param array $attributes Any attributes that currently are available from the block. + * Note, this will be empty in the editor context when the block is + * not in the post content on editor load. */ - protected function get_block_type_style() + protected function enqueue_data(array $attributes = []) { } /** - * Get aria label for filter item. - * - * @param array $item Filter item. - * @param bool $show_counts Whether to show counts. + * Include and render the block * - * @return string Aria label. + * @param array $attributes Block attributes. Default empty array. + * @param string $content Block content. Default empty string. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - private function get_aria_label($item, $show_counts) + protected function render($attributes, $content, $block) { } } /** - * Product Filter: Chips Block. + * ProductImageGallery class. */ - final class ProductFilterChips extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class ProductImageGallery extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { - use \Automattic\WooCommerce\Blocks\BlockTypes\EnableBlockJsonAssetsTrait; /** * Block name. * * @var string */ - protected $block_name = 'product-filter-chips'; + protected $block_name = 'product-image-gallery'; /** - * Render the block. - * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * It isn't necessary register block assets because it is a server side block. */ - protected function render($attributes, $content, $block) + protected function register_block_type_assets() { } /** - * Get aria label for filter item. - * - * @param array $item Filter item. - * @param bool $show_counts Whether to show counts. + * Register the context * - * @return string Aria label. + * @return string[] */ - private function get_aria_label($item, $show_counts) + protected function get_block_type_uses_context() { } - } - /** - * Product Filter: Clear Button Block. - */ - final class ProductFilterClearButton extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock - { /** - * Block name. + * Enqueue assets specific to this block. * - * @var string + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. */ - protected $block_name = 'product-filter-clear-button'; + protected function enqueue_assets($attributes, $content, $block) + { + } /** - * Get the frontend script handle for this block type. + * Enqueue legacy assets when this block is used as we don't enqueue them for block themes anymore. * - * @param string $key Data to get, or default to everything. + * Note: This enqueue logic is intentionally duplicated in ClassicTemplate.php + * to keep legacy blocks independent and allow for separate deprecation paths. * - * @return null + * @see https://github.com/woocommerce/woocommerce/pull/60223 */ - protected function get_block_type_script($key = null) + public function enqueue_legacy_assets() { } /** @@ -95712,178 +98733,146 @@ protected function render($attributes, $content, $block) } } /** - * Product Filter: Price Block. + * ProductMeta class. */ - final class ProductFilterPrice extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class ProductMeta extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { - use \Automattic\WooCommerce\Blocks\BlockTypes\EnableBlockJsonAssetsTrait; /** * Block name. * * @var string */ - protected $block_name = 'product-filter-price'; - const MIN_PRICE_QUERY_VAR = 'min_price'; - const MAX_PRICE_QUERY_VAR = 'max_price'; + protected $block_name = 'product-meta'; /** - * Initialize this block type. + * Get the editor script data for this block type. * - * - Hook into WP lifecycle. - * - Register the block with WordPress. + * @param string $key Data to get, or default to everything. + * @return null */ - protected function initialize() + protected function get_block_type_editor_script($key = null) { } /** - * Prepare the active filter items. + * Get the editor style handle for this block type. * - * @param array $items The active filter items. - * @param array $params The query param parsed from the URL. - * @return array Active filters items. + * @return null */ - public function prepare_selected_filters($items, $params) + protected function get_block_type_editor_style() { } /** - * Render the block. + * Get the frontend script handle for this block type. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @param string $key Data to get, or default to everything. + * @return null */ - protected function render($attributes, $content, $block) + protected function get_block_type_script($key = null) { } /** - * Retrieve the price filter data for current block. + * Get the frontend style handle for this block type. * - * @param WP_Block $block Block instance. + * @return null */ - private function get_filtered_price($block) + protected function get_block_type_style() { } } /** - * ProductFilterPriceSlider class. + * ProductNew class. */ - class ProductFilterPriceSlider extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class ProductNew extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractProductGrid { - use \Automattic\WooCommerce\Blocks\BlockTypes\EnableBlockJsonAssetsTrait; /** * Block name. * * @var string */ - protected $block_name = 'product-filter-price-slider'; + protected $block_name = 'product-new'; /** - * Render the block. + * Set args specific to this block * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @param array $query_args Query args. */ - protected function render($attributes, $content, $block) + protected function set_block_query_args(&$query_args) { } } /** - * Product Filter: Rating Block - * - * @package Automattic\WooCommerce\Blocks\BlockTypes + * ProductOnSale class. */ - final class ProductFilterRating extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class ProductOnSale extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractProductGrid { /** * Block name. * * @var string */ - protected $block_name = 'product-filter-rating'; - const RATING_FILTER_QUERY_VAR = 'rating_filter'; + protected $block_name = 'product-on-sale'; /** - * Initialize this block type. + * Set args specific to this block * - * - Hook into WP lifecycle. - * - Register the block with WordPress. + * @param array $query_args Query args. */ - protected function initialize() + protected function set_block_query_args(&$query_args) { } /** - * Prepare the active filter items. + * Get block attributes. * - * @param array $items The active filter items. - * @param array $params The query param parsed from the URL. - * @return array Active filters items. + * @return array */ - public function prepare_selected_filters($items, $params) + protected function get_block_type_attributes() { } + } + /** + * ProductPrice class. + */ + class ProductPrice extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + { + use \Automattic\WooCommerce\Blocks\BlockTypes\EnableBlockJsonAssetsTrait; + use \Automattic\WooCommerce\Blocks\Utils\BlocksSharedState; /** - * Include and render the block. + * Block name. * - * @param array $attributes Block attributes. Default empty array. - * @param string $content Block content. Default empty string. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @var string */ - protected function render($attributes, $content, $block) - { - } + protected $block_name = 'product-price'; /** - * Render the rating label. + * API version name. * - * @param int $rating The rating to render. - * @return string|false + * @var string */ - private function render_rating_label($rating) - { - } + protected $api_version = '3'; /** - * Retrieve the rating filter data for current block. + * Get the frontend style handle for this block type. * - * @param WP_Block $block Block instance. + * @return null */ - private function get_rating_counts($block) + protected function get_block_type_style() { } /** - * Disable the editor style handle for this block type. + * Overwrite parent method to prevent script registration. * - * @return null + * It is necessary to register and enqueues assets during the render + * phase because we want to load assets only if the block has the content. */ - protected function get_block_type_editor_style() + protected function register_block_type_assets() { } /** - * Disable the script handle for this block type. We use block.json to load the script. - * - * @param string|null $key The key of the script to get. - * @return null + * Register the context. */ - protected function get_block_type_script($key = null) + protected function get_block_type_uses_context() { } - } - /** - * Product Filter: Removable Chips Block. - */ - final class ProductFilterRemovableChips extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock - { - use \Automattic\WooCommerce\Blocks\BlockTypes\EnableBlockJsonAssetsTrait; - /** - * Block name. - * - * @var string - */ - protected $block_name = 'product-filter-removable-chips'; /** - * Render the block. + * Include and render the block. * - * @param array $attributes Block attributes. - * @param string $content Block content. + * @param array $attributes Block attributes. Default empty array. + * @param string $content Block content. Default empty string. * @param WP_Block $block Block instance. * @return string Rendered block type output. */ @@ -95891,422 +98880,455 @@ protected function render($attributes, $content, $block) { } } + // phpcs:disable WordPress.DB.SlowDBQuery.slow_db_query_tax_query + // phpcs:disable WordPress.DB.SlowDBQuery.slow_db_query_meta_query + // phpcs:disable WordPress.DB.SlowDBQuery.slow_db_query_meta_key /** - * Product Filter: Status Block. + * ProductQuery class. */ - final class ProductFilterStatus extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class ProductQuery extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { /** * Block name. * * @var string */ - protected $block_name = 'product-filter-status'; - const STOCK_STATUS_QUERY_VAR = 'filter_stock_status'; + protected $block_name = 'product-query'; /** - * Initialize this block type. + * The Block with its attributes before it gets rendered * - * - Hook into WP lifecycle. - * - Register the block with WordPress. + * @var array */ - protected function initialize() - { - } + protected $parsed_block; /** - * Prepare the active filter items. + * Orderby options not natively supported by WordPress REST API * - * @param array $items The active filter items. - * @param array $params The query param parsed from the URL. - * @return array Active filters items. + * @var array */ - public function prepare_selected_filters($items, $params) - { - } + protected $custom_order_opts = array('popularity', 'rating'); /** - * Extra data passed through from server to client for block. + * All the query args related to the filter by attributes block. * - * @param array $stock_statuses Any stock statuses that currently are available from the block. - * Note, this will be empty in the editor context when the block is - * not in the post content on editor load. + * @var array */ - protected function enqueue_data(array $stock_statuses = array()) - { - } + protected $attributes_filter_query_args = array(); + /** This is a feature flag to enable the custom inherit Global Query implementation. + * This is not intended to be a permanent feature flag, but rather a temporary. + * It is also necessary to enable this feature flag on the PHP side: `assets/js/blocks/product-query/utils.tsx:83`. + * https://github.com/woocommerce/woocommerce-blocks/pull/7382 + * + * @var boolean + */ + protected $is_custom_inherit_global_query_implementation_enabled = false; /** - * Include and render the block. + * All query args from WP_Query. * - * @param array $attributes Block attributes. Default empty array. - * @param string $content Block content. Default empty string. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @var array */ - protected function render($attributes, $content, $block) - { - } + protected $valid_query_vars; /** - * Retrieve the status filter data for current block. + * Initialize this block type. * - * @param WP_Block $block Block instance. + * - Hook into WP lifecycle. + * - Register the block with WordPress. + * - Hook into pre_render_block to update the query. */ - private function get_stock_status_counts($block) + protected function initialize() { } /** - * Disable the editor style handle for this block type. - * - * @return null + * Post Template support for grid view was introduced in Gutenberg 16 / WordPress 6.3 + * Fixed in: + * - https://github.com/woocommerce/woocommerce-blocks/pull/9916 + * - https://github.com/woocommerce/woocommerce-blocks/pull/10360 */ - protected function get_block_type_editor_style() + private function check_if_post_template_has_support_for_grid_view() { } /** - * Disable the script handle for this block type. We use block.json to load the script. + * Extra data passed through from server to client for block. * - * @param string|null $key The key of the script to get. - * @return null + * @param array $attributes Any attributes that currently are available from the block. + * Note, this will be empty in the editor context when the block is + * not in the post content on editor load. */ - protected function get_block_type_script($key = null) + protected function enqueue_data(array $attributes = []) { } - } - /** - * Product Filter: Taxonomy Block. - */ - final class ProductFilterTaxonomy extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock - { /** - * Block name. + * Check if a given block * - * @var string + * @param array $parsed_block The block being rendered. + * @return boolean */ - protected $block_name = 'product-filter-taxonomy'; + public static function is_woocommerce_variation($parsed_block) + { + } /** - * Prepare the active filter items. + * Enqueues the variation styles when rendering the Product Query variation. * - * @internal For exclusive usage of WooCommerce core, backwards compatibility not guaranteed. + * @param string $block_content The block content. + * @param array $block The full block, including name and attributes. * - * @param array $items The active filter items. - * @param array $params The query param parsed from the URL. - * @return array Active filters items. + * @return string The block content. */ - public function prepare_selected_filters($items, $params) + public function enqueue_styles(string $block_content, array $block) { } /** - * Initialize this block type. + * Update the query for the product query block. * - * - Hook into WP lifecycle. - * - Register the block with WordPress. + * @param string|null $pre_render The pre-rendered content. Default null. + * @param array $parsed_block The block being rendered. */ - protected function initialize() + public function update_query($pre_render, $parsed_block) { } /** - * Extra data passed through from server to client for block. + * Merge tax_queries from various queries. * - * @param array $attributes Any attributes that currently are available from the block. - * Note, this will be empty in the editor context when the block is - * not in the post content on editor load. + * @param array ...$queries Query arrays to be merged. + * @return array */ - protected function enqueue_data(array $attributes = array()) + private function merge_tax_queries(...$queries) { } /** - * Get the frontend script handle for this block type. + * Update the query for the product query block in Editor. * - * @see $this->register_block_type() - * @param string $key Data to get, or default to everything. - * @return array|string|null + * @param array $args Query args. + * @param WP_REST_Request $request Request. */ - protected function get_block_type_script($key = null) + public function update_rest_query($args, $request): array { } /** - * Render the block. + * Return a custom query based on attributes, filters and global WP_Query. * - * @param array $block_attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @param WP_Query $query The WordPress Query. + * @param WP_Block $block The block being rendered. + * @return array */ - protected function render($block_attributes, $content, $block) + public function build_query($query, $block = null) { } /** - * Get terms sorted based on taxonomy type (hierarchical vs flat). + * Merge in the first parameter the keys "post_in", "meta_query" and "tax_query" of the second parameter. * - * @param string $taxonomy Taxonomy slug. - * @param array $taxonomy_counts Term counts with term_id as key. - * @param bool $hide_empty Whether to hide empty terms. - * @param string $orderby Sort field (name, count, menu_order). - * @param string $order Sort direction (ASC, DESC). - * @return array Sorted terms array. + * @param array[] ...$queries Query arrays to be merged. + * @return array */ - private function get_sorted_terms($taxonomy, $taxonomy_counts, $hide_empty, $orderby, $order) + private function merge_queries(...$queries) { } /** - * Retrieve the taxonomy term counts for current block. + * Extends allowed `collection_params` for the REST API * - * @param WP_Block $block Block instance. - * @param string $taxonomy Taxonomy slug. - * @return array Term counts with term_id as key and count as value. + * By itself, the REST API doesn't accept custom `orderby` values, + * even if they are supported by a custom post type. + * + * @param array $params A list of allowed `orderby` values. + * + * @return array */ - private function get_taxonomy_term_counts($block, $taxonomy) + public function extend_rest_query_allowed_params($params) { } /** - * Get product taxonomies for the block. + * Return a query for on sale products. * * @return array */ - private function get_taxonomies() + private function get_on_sale_products_query() { } /** - * Sort hierarchical terms recursively maintaining parent-child relationships. + * Return query params to support custom sort values * - * @param array $terms Hierarchical terms array with children. - * @param string $orderby Sort field (name, count, menu_order). - * @param string $order Sort direction (ASC, DESC). - * @param array $taxonomy_counts Context-aware term counts. - * @return array Sorted hierarchical terms. + * @param string $orderby Sort order option. + * + * @return array */ - private function sort_hierarchy_terms($terms, $orderby, $order, $taxonomy_counts) + private function get_custom_orderby_query($orderby) { } /** - * Flatten hierarchical term tree into flat array maintaining depth-first order. + * Apply the query only to a subset of products * - * @param array $terms Hierarchical terms with children structure. - * @param array $result Reference to result array being built. - * @param array $visited_ids Reference to array tracking visited term IDs to prevent circular references. - * @param int $depth Current recursion depth for bounds checking. + * @param array $query The query. + * @param array $ids Array of selected product ids. + * + * @return array */ - private function flatten_terms_list($terms, &$result, &$visited_ids = array(), $depth = 0) + private function filter_query_to_only_include_ids($query, $ids) { } /** - * Get taxonomy terms ordered hierarchically. + * Return the `tax_query` for the requested attributes * - * @param string $taxonomy Taxonomy slug. - * @param array $taxonomy_counts Term counts with term_id as key. - * @param bool $hide_empty Whether to hide empty terms. - * @param string $orderby Sort field for siblings (name, count, menu_order). - * @param string $order Sort direction (ASC, DESC). - * @return array|\WP_Error Hierarchically ordered terms or error. + * @param array $attributes Attributes and their terms. + * + * @return array */ - private function get_hierarchical_terms(string $taxonomy, array $taxonomy_counts, bool $hide_empty, string $orderby, string $order) + private function get_product_attributes_query($attributes = array()) { } /** - * Sort terms by the specified criteria (name or count). + * Return a query for products depending on their stock status. * - * @param array $terms Array of term objects to sort. - * @param string $orderby Sort field (name, count, menu_order). - * @param string $order Sort direction (ASC, DESC). - * @param array $taxonomy_counts Context-aware term counts. - * @return array Sorted terms. + * @param array $stock_statii An array of acceptable stock statii. + * @return array */ - private function sort_terms_by_criteria(array $terms, string $orderby, string $order, array $taxonomy_counts): array + private function get_stock_status_query($stock_statii) { } - } - /** - * ProductFilters class. - */ - class ProductFilters extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock - { - use \Automattic\WooCommerce\Blocks\Utils\BlocksSharedState; /** - * Block name. + * Return a query for product visibility depending on their stock status. * - * @var string - */ - protected $block_name = 'product-filters'; - /** - * Register the context. + * @param array $stock_query Stock status query. * - * @return string[] + * @return array Tax query for product visibility. */ - protected function get_block_type_uses_context() + private function get_product_visibility_query($stock_query) { } /** - * Extra data passed through from server to client for block. + * Set the query vars that are used by filter blocks. * - * @param array $attributes Any attributes that currently are available from the block. - * Note, this will be empty in the editor context when the block is - * not in the post content on editor load. + * @return array */ - protected function enqueue_data(array $attributes = array()) + private function get_query_vars_from_filter_blocks() { } /** - * Include and render the block. + * Set the query vars that are used by filter blocks. * - * @param array $attributes Block attributes. Default empty array. - * @param string $content Block content. Default empty string. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @param array $public_query_vars Public query vars. + * @return array */ - protected function render($attributes, $content, $block) + public function set_query_vars($public_query_vars) { } /** - * Get SVG icon markup for a given icon name. + * Get all the query args related to the filter by attributes block. * - * @param string $name The name of the icon to retrieve. - * @return string SVG markup for the icon, or empty string if icon not found. + * @return array + * [color] => Array + * ( + * [filter] => filter_color + * [query_type] => query_type_color + * ) + * + * [size] => Array + * ( + * [filter] => filter_size + * [query_type] => query_type_size + * ) + * ) */ - private function get_svg_icon(string $name) + private function get_filter_by_attributes_query_vars() { } /** - * Generate a unique navigation ID for the block. + * Return queries that are generated by query args. * - * @param mixed $block - Block instance. - * @return string - Unique navigation ID. + * @return array */ - private function generate_navigation_id($block) + private function get_queries_by_applied_filters() { } /** - * Parse the filter parameters from the URL. - * For now we only get the global query params from the URL. In the future, - * we should get the query params based on $query_id. + * Return queries that are generated by attributes * - * @param int $query_id Query ID. - * @return array Parsed filter params. + * @param array $parsed_block The Product Query that being rendered. + * @return array */ - private function get_filter_params($query_id) + private function get_queries_by_custom_attributes($parsed_block) { } /** - * Disable the style handle for this block type. We use block.json to load the style. + * Return a query that filters products by price. * - * @return null + * @return array */ - protected function get_block_type_style() + private function get_filter_by_price_query() { } /** - * Disable the editor style handle for this block type. We use block.json to load the style. + * Return a query that filters products by attributes. * - * @return null + * @return array */ - protected function get_block_type_editor_style() + private function get_filter_by_attributes_query() { } /** - * Disable the script handle for this block type. We use block.json to load the script. + * Return a query that filters products by stock status. * - * @param string|null $key The key of the script to get. - * @return null + * @return array */ - protected function get_block_type_script($key = null) + private function get_filter_by_stock_status_query() { } /** - * Get the canonical URL without pagination. + * Return or initialize $valid_query_vars. * - * @param array $filter_params Filter parameters. - * @return string Canonical URL without pagination. + * @return array */ - private function get_canonical_url_no_pagination($filter_params) + private function get_valid_query_vars() { } - } - /** - * ProductGallery class. - */ - class ProductGallery extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock - { - use \Automattic\WooCommerce\Blocks\BlockTypes\EnableBlockJsonAssetsTrait; /** - * Block name. + * Merge two array recursively but replace the non-array values instead of + * merging them. The merging strategy: * - * @var string + * - If keys from merge array doesn't exist in the base array, create them. + * - For array items with numeric keys, we merge them as normal. + * - For array items with string keys: + * + * - If the value isn't array, we'll use the value coming from the merge array. + * $base = ['orderby' => 'date'] + * $new = ['orderby' => 'meta_value_num'] + * Result: ['orderby' => 'meta_value_num'] + * + * - If the value is array, we'll use recursion to merge each key. + * $base = ['meta_query' => [ + * [ + * 'key' => '_stock_status', + * 'compare' => 'IN' + * 'value' => ['instock', 'onbackorder'] + * ] + * ]] + * $new = ['meta_query' => [ + * [ + * 'relation' => 'AND', + * [...], + * [...], + * ] + * ]] + * Result: ['meta_query' => [ + * [ + * 'key' => '_stock_status', + * 'compare' => 'IN' + * 'value' => ['instock', 'onbackorder'] + * ], + * [ + * 'relation' => 'AND', + * [...], + * [...], + * ] + * ]] + * + * $base = ['post__in' => [1, 2, 3, 4, 5]] + * $new = ['post__in' => [3, 4, 5, 6, 7]] + * Result: ['post__in' => [1, 2, 3, 4, 5, 3, 4, 5, 6, 7]] + * + * @param array $base First array. + * @param array $new Second array. */ - protected $block_name = 'product-gallery'; + private function array_merge_recursive_replace_non_array_properties($base, $new) + { + } /** - * Register the context + * Get product-related query variables from the global query. * - * @return string[] + * @param array $parsed_block The Product Query that being rendered. + * + * @return array */ - protected function get_block_type_uses_context() + private function get_global_query($parsed_block) { } /** - * Return the dialog content. + * Return a query that filters products by rating. * - * @param array $images An array of all images of the product. - * @return string + * @return array */ - protected function render_dialog($images) + private function get_filter_by_rating_query() { } /** - * Inject dialog into the product gallery HTML. + * Return a query to filter products by taxonomies (product categories, product tags, etc.) * - * @param string $gallery_html The gallery HTML. - * @param string $dialog_html The dialog HTML. + * For example: + * User could provide "Product Categories" using "Filters" ToolsPanel available in Inspector Controls. + * We use this function to extract it's query from $tax_query. * - * @return string + * For example, this is how the query for product categories will look like in $tax_query array: + * Array + * ( + * [taxonomy] => product_cat + * [terms] => Array + * ( + * [0] => 36 + * ) + * ) + * + * For product categories, taxonomy would be "product_tag" + * + * @param array $query WP_Query. + * @return array Query to filter products by taxonomies. */ - protected function inject_dialog($gallery_html, $dialog_html) + private function get_filter_by_taxonomies_query($query): array { } /** - * Include and render the block. + * Returns the keyword filter from the given query. * - * @param array $attributes Block attributes. Default empty array. - * @param string $content Block content. Default empty string. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @param WP_Query $query The query to extract the keyword filter from. + * @return array The keyword filter, or an empty array if none is found. */ - protected function render($attributes, $content, $block) + private function get_filter_by_keyword_query($query): array { } } /** - * ProductGalleryLargeImage class. + * ProductRating class. */ - class ProductGalleryLargeImage extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class ProductRating extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { - use \Automattic\WooCommerce\Blocks\BlockTypes\EnableBlockJsonAssetsTrait; /** * Block name. * * @var string */ - protected $block_name = 'product-gallery-large-image'; + protected $block_name = 'product-rating'; /** - * Register the context + * API version name. * - * @return string[] + * @var string */ - protected function get_block_type_uses_context() + protected $api_version = '3'; + /** + * Get the block's attributes. + * + * @param array $attributes Block attributes. Default empty array. + * @return array Block attributes merged with defaults. + */ + private function parse_attributes($attributes) { } /** - * Initialize this block type. + * Overwrite parent method to prevent script registration. * - * - Hook into WP lifecycle. - * - Register the block with WordPress. - * - Hook into pre_render_block to update the query. + * It is necessary to register and enqueues assets during the render + * phase because we want to load assets only if the block has the content. */ - protected function initialize() + protected function register_block_type_assets() { } /** - * Enqueue frontend assets for this block, just in time for rendering. + * Get the frontend style handle for this block type. * - * @param array $attributes Any attributes that currently are available from the block. - * @param string $content The block content. - * @param WP_Block $block The block object. + * @return null */ - protected function enqueue_assets(array $attributes, $content, $block) + protected function get_block_type_style() + { + } + /** + * Register the context. + */ + protected function get_block_type_uses_context() { } /** @@ -96320,75 +99342,52 @@ protected function enqueue_assets(array $attributes, $content, $block) protected function render($attributes, $content, $block) { } + } + /** + * ProductRatingCounter class. + */ + class ProductRatingCounter extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + { /** - * Update the single image html. + * Block name. * - * @param string $image_html The image html. - * @param array $context The block context. - * @param int $index The index of the image. - * @return string + * @var string */ - private function update_single_image($image_html, $context, $index) - { - } + protected $block_name = 'product-rating-counter'; /** - * Get the main images html code. The first element of the array contains the HTML of the first image that is visible, the second element contains the HTML of the other images that are hidden. + * API version name. * - * @param array $context The block context. - * @param \WC_Product $product The product object. - * @param WP_Block $inner_block The inner block object. - * @return array + * @var string */ - private function get_main_images_html($context, $product, $inner_block) - { - } + protected $api_version = '3'; /** - * Get the main images html code. The first element of the array contains the HTML of the first image that is visible, the second element contains the HTML of the other images that are hidden. - * - * @param array $context The block context. - * @param \WC_Product $product The product object. + * Get the block's attributes. * - * @return array + * @param array $attributes Block attributes. Default empty array. + * @return array Block attributes merged with defaults. */ - private function legacy_get_main_images_html($context, $product) + private function parse_attributes($attributes) { } /** - * Disable the editor style handle for this block type. + * Overwrite parent method to prevent script registration. * - * @return null + * It is necessary to register and enqueues assets during the render + * phase because we want to load assets only if the block has the content. */ - protected function get_block_type_editor_style() + protected function register_block_type_assets() { } /** - * Large Image renders inner blocks manually so we need to skip default - * rendering routine for its inner blocks + * Get the frontend style handle for this block type. * - * @param array $settings Array of determined settings for registering a block type. - * @param array $metadata Metadata provided for registering a block type. - * @return array + * @return null */ - public function add_block_type_metadata_settings($settings, $metadata) + protected function get_block_type_style() { } - } - /** - * ProductGalleryThumbnails class. - */ - class ProductGalleryThumbnails extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock - { - use \Automattic\WooCommerce\Blocks\BlockTypes\EnableBlockJsonAssetsTrait; - /** - * Block name. - * - * @var string - */ - protected $block_name = 'product-gallery-thumbnails'; /** - * Register the context - * - * @return string[] + * Register the context. */ protected function get_block_type_uses_context() { @@ -96406,16 +99405,16 @@ protected function render($attributes, $content, $block) } } /** - * ProductImage class. + * ProductRatingStars class. */ - class ProductImage extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class ProductRatingStars extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { /** * Block name. * * @var string */ - protected $block_name = 'product-image'; + protected $block_name = 'product-rating-stars'; /** * API version name. * @@ -96423,7 +99422,10 @@ class ProductImage extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlo */ protected $api_version = '3'; /** - * It is necessary to register and enqueues assets during the render phase because we want to load assets only if the block has the content. + * Overwrite parent method to prevent script registration. + * + * It is necessary to register and enqueues assets during the render + * phase because we want to load assets only if the block has the content. */ protected function register_block_type_assets() { @@ -96435,114 +99437,79 @@ protected function get_block_type_uses_context() { } /** - * Get the block's attributes. - * - * @param array $attributes Block attributes. Default empty array. - * @return array Block attributes merged with defaults. - */ - private function parse_attributes($attributes) - { - } - /** - * Render on Sale Badge. + * Include and render the block. * - * @param \WC_Product $product Product object. - * @param array $attributes Attributes. - * @return string + * @param array $attributes Block attributes. Default empty array. + * @param string $content Block content. Default empty string. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - private function render_on_sale_badge($product, $attributes) + protected function render($attributes, $content, $block) { } + } + /** + * ProductResultsCount class. + */ + class ProductResultsCount extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + { /** - * Render anchor. + * Block name. * - * @param \WC_Product $product Product object. - * @param string $on_sale_badge Return value from $render_image. - * @param string $product_image Return value from $render_on_sale_badge. - * @param array $attributes Attributes. - * @param string $inner_blocks_content Rendered HTML of inner blocks. - * @return string + * @var string */ - private function render_anchor($product, $on_sale_badge, $product_image, $attributes, $inner_blocks_content) - { - } + protected $block_name = 'product-results-count'; /** - * Render Image. + * Get the frontend script handle for this block type. * - * @param \WC_Product $product Product object. - * @param array $attributes Parsed attributes. - * @param int|null $image_id Optional image ID from context. - * @return string + * @param string $key Data to get, or default to everything. */ - private function render_image($product, $attributes, $image_id = null) + protected function get_block_type_script($key = null) { } /** - * Extra data passed through from server to client for block. + * Render the block. * - * @param array $attributes Any attributes that currently are available from the block. - * Note, this will be empty in the editor context when the block is - * not in the post content on editor load. - */ - protected function enqueue_data(array $attributes = []) - { - } - /** - * Include and render the block + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. * - * @param array $attributes Block attributes. Default empty array. - * @param string $content Block content. Default empty string. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @return string Rendered block output. */ protected function render($attributes, $content, $block) { } } /** - * ProductImageGallery class. + * ProductSKU class. */ - class ProductImageGallery extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class ProductSKU extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { /** * Block name. * * @var string */ - protected $block_name = 'product-image-gallery'; - /** - * It isn't necessary register block assets because it is a server side block. - */ - protected function register_block_type_assets() - { - } + protected $block_name = 'product-sku'; /** - * Register the context + * API version name. * - * @return string[] + * @var string */ - protected function get_block_type_uses_context() - { - } + protected $api_version = '3'; /** - * Enqueue assets specific to this block. + * Overwrite parent method to prevent script registration. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. + * It is necessary to register and enqueues assets during the render + * phase because we want to load assets only if the block has the content. */ - protected function enqueue_assets($attributes, $content, $block) + protected function register_block_type_assets() { } /** - * Enqueue legacy assets when this block is used as we don't enqueue them for block themes anymore. - * - * Note: This enqueue logic is intentionally duplicated in ClassicTemplate.php - * to keep legacy blocks independent and allow for separate deprecation paths. - * - * @see https://github.com/woocommerce/woocommerce/pull/60223 + * Register the context. */ - public function enqueue_legacy_assets() + protected function get_block_type_uses_context() { } /** @@ -96558,103 +99525,125 @@ protected function render($attributes, $content, $block) } } /** - * ProductMeta class. + * ProductSaleBadge class. */ - class ProductMeta extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class ProductSaleBadge extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { /** * Block name. * * @var string */ - protected $block_name = 'product-meta'; + protected $block_name = 'product-sale-badge'; /** - * Get the editor script data for this block type. + * API version name. * - * @param string $key Data to get, or default to everything. - * @return null + * @var string */ - protected function get_block_type_editor_script($key = null) - { - } + protected $api_version = '3'; /** - * Get the editor style handle for this block type. + * Overwrite parent method to prevent script registration. * - * @return null + * It is necessary to register and enqueues assets during the render + * phase because we want to load assets only if the block has the content. */ - protected function get_block_type_editor_style() + protected function register_block_type_assets() { } /** - * Get the frontend script handle for this block type. - * - * @param string $key Data to get, or default to everything. - * @return null + * Register the context. */ - protected function get_block_type_script($key = null) + protected function get_block_type_uses_context() { } /** - * Get the frontend style handle for this block type. + * Include and render the block. * - * @return null + * @param array $attributes Block attributes. Default empty array. + * @param string $content Block content. Default empty string. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - protected function get_block_type_style() + protected function render($attributes, $content, $block) { } } /** - * ProductNew class. + * ProductSearch class. */ - class ProductNew extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractProductGrid + class ProductSearch extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { /** * Block name. * * @var string */ - protected $block_name = 'product-new'; + protected $block_name = 'product-search'; /** - * Set args specific to this block + * Get the frontend script handle for this block type. * - * @param array $query_args Query args. + * @param string $key Data to get, or default to everything. + * @return null */ - protected function set_block_query_args(&$query_args) + protected function get_block_type_script($key = null) + { + } + /** + * Render the block. + * + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. + */ + protected function render($attributes, $content, $block) { } } /** - * ProductOnSale class. + * ProductSpecifications class. */ - class ProductOnSale extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractProductGrid + class ProductSpecifications extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { /** * Block name. * * @var string */ - protected $block_name = 'product-on-sale'; + protected $block_name = 'product-specifications'; /** - * Set args specific to this block + * Get the frontend script handle for this block type. * - * @param array $query_args Query args. + * @param string $key Data to get, or default to everything. */ - protected function set_block_query_args(&$query_args) + protected function get_block_type_script($key = null) { } /** - * Get block attributes. + * Render the block. * - * @return array + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * + * @return string Rendered block output. */ - protected function get_block_type_attributes() + protected function render($attributes, $content, $block) + { + } + /** + * Get the frontend style handle for this block type. + * + * @return string[] + */ + protected function get_block_type_style() { } } /** - * ProductPrice class. + * ProductStockIndicator class. */ - class ProductPrice extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class ProductStockIndicator extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { use \Automattic\WooCommerce\Blocks\BlockTypes\EnableBlockJsonAssetsTrait; use \Automattic\WooCommerce\Blocks\Utils\BlocksSharedState; @@ -96663,7 +99652,7 @@ class ProductPrice extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlo * * @var string */ - protected $block_name = 'product-price'; + protected $block_name = 'product-stock-indicator'; /** * API version name. * @@ -96671,30 +99660,42 @@ class ProductPrice extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlo */ protected $api_version = '3'; /** - * Get the frontend style handle for this block type. + * Register script and style assets for the block type before it is registered. * - * @return null + * This registers the scripts; it does not enqueue them. */ - protected function get_block_type_style() + protected function register_block_type_assets() { } /** - * Overwrite parent method to prevent script registration. + * Register the context. + */ + protected function get_block_type_uses_context() + { + } + /** + * Get product types that should not display stock indicators. * - * It is necessary to register and enqueues assets during the render - * phase because we want to load assets only if the block has the content. + * @return array */ - protected function register_block_type_assets() + protected function get_product_types_without_stock_indicator() { } /** - * Register the context. + * Extra data passed through from server to client for block. + * + * @param array $attributes Any attributes that currently are available from the block. + * Note, this will be empty in the editor context when the block is + * not in the post content on editor load. */ - protected function get_block_type_uses_context() + protected function enqueue_data(array $attributes = []) { } /** - * Include and render the block. + * Renders the stock indicator block. + * + * This method handles both direct product context and global product context, + * ensuring the stock indicator displays correctly in various template scenarios. * * @param array $attributes Block attributes. Default empty array. * @param string $content Block content. Default empty string. @@ -96705,595 +99706,663 @@ protected function render($attributes, $content, $block) { } } - // phpcs:disable WordPress.DB.SlowDBQuery.slow_db_query_tax_query - // phpcs:disable WordPress.DB.SlowDBQuery.slow_db_query_meta_query - // phpcs:disable WordPress.DB.SlowDBQuery.slow_db_query_meta_key /** - * ProductQuery class. + * ProductSummary class. */ - class ProductQuery extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class ProductSummary extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { /** * Block name. * * @var string */ - protected $block_name = 'product-query'; + protected $block_name = 'product-summary'; /** - * The Block with its attributes before it gets rendered + * API version name. * - * @var array + * @var string */ - protected $parsed_block; + protected $api_version = '3'; /** - * Orderby options not natively supported by WordPress REST API + * Overwrite parent method to prevent script registration. * - * @var array + * It is necessary to register and enqueues assets during the render + * phase because we want to load assets only if the block has the content. */ - protected $custom_order_opts = array('popularity', 'rating'); + protected function register_block_type_assets() + { + } /** - * All the query args related to the filter by attributes block. - * - * @var array - */ - protected $attributes_filter_query_args = array(); - /** This is a feature flag to enable the custom inherit Global Query implementation. - * This is not intended to be a permanent feature flag, but rather a temporary. - * It is also necessary to enable this feature flag on the PHP side: `assets/js/blocks/product-query/utils.tsx:83`. - * https://github.com/woocommerce/woocommerce-blocks/pull/7382 - * - * @var boolean + * Register the context. */ - protected $is_custom_inherit_global_query_implementation_enabled = false; + protected function get_block_type_uses_context() + { + } /** - * All query args from WP_Query. + * Get product description depends on config. * - * @var array + * @param WC_Product $product Product object. + * @param bool $show_description_if_empty Defines if fallback to full description. + * @return string */ - protected $valid_query_vars; + private function get_source($product, $show_description_if_empty) + { + } /** - * Initialize this block type. + * Create anchor element based on input. * - * - Hook into WP lifecycle. - * - Register the block with WordPress. - * - Hook into pre_render_block to update the query. + * @param WC_Product $product Product object. + * @param string $link_text Link text. + * @return string */ - protected function initialize() + private function create_anchor($product, $link_text) { } /** - * Post Template support for grid view was introduced in Gutenberg 16 / WordPress 6.3 - * Fixed in: - * - https://github.com/woocommerce/woocommerce-blocks/pull/9916 - * - https://github.com/woocommerce/woocommerce-blocks/pull/10360 + * Get first paragraph from some HTML text, or return the whole string. + * + * @param string $source Source text. + * @return string First paragraph found in string. */ - private function check_if_post_template_has_support_for_grid_view() + private function get_first_paragraph($source) { } /** - * Extra data passed through from server to client for block. + * Count words, characters (excluding spaces), or characters (including spaces). * - * @param array $attributes Any attributes that currently are available from the block. - * Note, this will be empty in the editor context when the block is - * not in the post content on editor load. + * @param string $text Text to count. + * @param string $count_type Count type: 'words', 'characters_excluding_spaces', or 'characters_including_spaces'. + * @return int Count of specified type. */ - protected function enqueue_data(array $attributes = []) + private function count_text($text, $count_type) { } /** - * Check if a given block + * Trim characters to a specified length. * - * @param array $parsed_block The block being rendered. - * @return boolean + * @param string $text Text to trim. + * @param int $max_length Maximum length of the text. + * @param string $count_type What is being counted. One of 'words', 'characters_excluding_spaces', or 'characters_including_spaces'. + * @return string Trimmed text. */ - public static function is_woocommerce_variation($parsed_block) + private function trim_characters($text, $max_length, $count_type) { } /** - * Enqueues the variation styles when rendering the Product Query variation. + * Generates the summary text from a string of text. It's not ideal + * but allows keeping the editor and frontend consistent. * - * @param string $block_content The block content. - * @param array $block The full block, including name and attributes. + * NOTE: If editing, keep it in sync with generateSummary function from + * plugins/woocommerce/client/blocks/assets/js/base/components/summary/utils.ts! * - * @return string The block content. + * Once HTML API allow for HTML manipulation both functions (PHP and JS) + * should be updated to solution fully respecting the word count. + * https://github.com/woocommerce/woocommerce/issues/52835 + * + * @param string $source Source text. + * @param int $max_length Limit number of items returned if text has multiple paragraphs. + * @return string Generated summary. */ - public function enqueue_styles(string $block_content, array $block) + private function generate_summary($source, $max_length) { } /** - * Update the query for the product query block. + * Include and render the block. * - * @param string|null $pre_render The pre-rendered content. Default null. - * @param array $parsed_block The block being rendered. + * @param array $attributes Block attributes. Default empty array. + * @param string $content Block content. Default empty string. + * @param WP_Block $block Block instance. + * @return string Rendered block type output. */ - public function update_query($pre_render, $parsed_block) + protected function render($attributes, $content, $block) { } + } + /** + * ProductTag class. + */ + class ProductTag extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractProductGrid + { /** - * Merge tax_queries from various queries. + * Block name. * - * @param array ...$queries Query arrays to be merged. - * @return array + * @var string */ - private function merge_tax_queries(...$queries) - { - } + protected $block_name = 'product-tag'; /** - * Update the query for the product query block in Editor. + * Set args specific to this block. * - * @param array $args Query args. - * @param WP_REST_Request $request Request. + * @param array $query_args Query args. */ - public function update_rest_query($args, $request): array + protected function set_block_query_args(&$query_args) { } /** - * Return a custom query based on attributes, filters and global WP_Query. + * Get block attributes. * - * @param WP_Query $query The WordPress Query. - * @param WP_Block $block The block being rendered. * @return array */ - public function build_query($query, $block = null) + protected function get_block_type_attributes() { } /** - * Merge in the first parameter the keys "post_in", "meta_query" and "tax_query" of the second parameter. + * Extra data passed through from server to client for block. * - * @param array[] ...$queries Query arrays to be merged. - * @return array + * @param array $attributes Any attributes that currently are available from the block. + * Note, this will be empty in the editor context when the block is + * not in the post content on editor load. */ - private function merge_queries(...$queries) + protected function enqueue_data(array $attributes = []) { } + } + /** + * ProductTemplate class. + */ + class ProductTemplate extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + { + use \Automattic\WooCommerce\Blocks\BlockTypes\EnableBlockJsonAssetsTrait; /** - * Extends allowed `collection_params` for the REST API - * - * By itself, the REST API doesn't accept custom `orderby` values, - * even if they are supported by a custom post type. - * - * @param array $params A list of allowed `orderby` values. + * Block name. * - * @return array + * @var string */ - public function extend_rest_query_allowed_params($params) - { - } + protected $block_name = 'product-template'; /** - * Return a query for on sale products. + * Initialize this block type. * - * @return array + * - Hook into WP lifecycle. + * - Register the block with WordPress. + * - Hook into pre_render_block to update the query. */ - private function get_on_sale_products_query() + protected function initialize() { } /** - * Return query params to support custom sort values - * - * @param string $orderby Sort order option. + * Get the frontend script handle for this block type. * - * @return array + * @param string $key Data to get, or default to everything. */ - private function get_custom_orderby_query($orderby) + protected function get_block_type_script($key = null) { } /** - * Apply the query only to a subset of products + * Render the block. * - * @param array $query The query. - * @param array $ids Array of selected product ids. + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. * - * @return array + * @return string | void Rendered block output. */ - private function filter_query_to_only_include_ids($query, $ids) + protected function render($attributes, $content, $block) { } /** - * Return the `tax_query` for the requested attributes + * Determines whether a block list contains a block that uses the featured image. * - * @param array $attributes Attributes and their terms. + * @param WP_Block_List $inner_blocks Inner block instance. * - * @return array + * @return bool Whether the block list contains a block that uses the featured image. */ - private function get_product_attributes_query($attributes = array()) + protected function block_core_post_template_uses_featured_image($inner_blocks) { } /** - * Return a query for products depending on their stock status. + * Product Template renders inner blocks manually so we need to skip default + * rendering routine for its inner blocks * - * @param array $stock_statii An array of acceptable stock statii. + * @param array $settings Array of determined settings for registering a block type. + * @param array $metadata Metadata provided for registering a block type. * @return array */ - private function get_stock_status_query($stock_statii) + public function add_block_type_metadata_settings($settings, $metadata) { } + } + /** + * ProductTitle class. + */ + class ProductTitle extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + { /** - * Return a query for product visibility depending on their stock status. - * - * @param array $stock_query Stock status query. + * Block name. * - * @return array Tax query for product visibility. + * @var string */ - private function get_product_visibility_query($stock_query) - { - } + protected $block_name = 'product-title'; /** - * Set the query vars that are used by filter blocks. + * API version name. * - * @return array + * @var string */ - private function get_query_vars_from_filter_blocks() - { - } + protected $api_version = '3'; /** - * Set the query vars that are used by filter blocks. + * Register script and style assets for the block type before it is registered. * - * @param array $public_query_vars Public query vars. - * @return array + * This registers the scripts; it does not enqueue them. */ - public function set_query_vars($public_query_vars) + protected function register_block_type_assets() { } + } + /** + * ProductTopRated class. + */ + class ProductTopRated extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractProductGrid + { /** - * Get all the query args related to the filter by attributes block. + * Block name. * - * @return array - * [color] => Array - * ( - * [filter] => filter_color - * [query_type] => query_type_color - * ) + * @var string + */ + protected $block_name = 'product-top-rated'; + /** + * Force orderby to rating. * - * [size] => Array - * ( - * [filter] => filter_size - * [query_type] => query_type_size - * ) - * ) + * @param array $query_args Query args. */ - private function get_filter_by_attributes_query_vars() + protected function set_block_query_args(&$query_args) { } + } + /** + * ProductsByAttribute class. + */ + class ProductsByAttribute extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractProductGrid + { /** - * Return queries that are generated by query args. + * Block name. * - * @return array + * @var string */ - private function get_queries_by_applied_filters() - { - } + protected $block_name = 'products-by-attribute'; /** - * Return queries that are generated by attributes + * Set args specific to this block * - * @param array $parsed_block The Product Query that being rendered. - * @return array + * @param array $query_args Query args. */ - private function get_queries_by_custom_attributes($parsed_block) + protected function set_block_query_args(&$query_args) { } /** - * Return a query that filters products by price. + * Get block attributes. * * @return array */ - private function get_filter_by_price_query() + protected function get_block_type_attributes() { } + } + /** + * PriceFilter class. + */ + class RatingFilter extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + { /** - * Return a query that filters products by attributes. + * Block name. * - * @return array + * @var string */ - private function get_filter_by_attributes_query() - { - } + protected $block_name = 'rating-filter'; + const RATING_QUERY_VAR = 'rating_filter'; /** - * Return a query that filters products by stock status. + * Get the frontend script handle for this block type. * - * @return array + * @param string $key Data to get, or default to everything. */ - private function get_filter_by_stock_status_query() + protected function get_block_type_script($key = null) { } /** - * Return or initialize $valid_query_vars. + * Get the frontend style handle for this block type. * - * @return array + * @return string[] */ - private function get_valid_query_vars() + protected function get_block_type_style() { } + } + /** + * RelatedProducts class. + */ + class RelatedProducts extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + { /** - * Merge two array recursively but replace the non-array values instead of - * merging them. The merging strategy: - * - * - If keys from merge array doesn't exist in the base array, create them. - * - For array items with numeric keys, we merge them as normal. - * - For array items with string keys: - * - * - If the value isn't array, we'll use the value coming from the merge array. - * $base = ['orderby' => 'date'] - * $new = ['orderby' => 'meta_value_num'] - * Result: ['orderby' => 'meta_value_num'] - * - * - If the value is array, we'll use recursion to merge each key. - * $base = ['meta_query' => [ - * [ - * 'key' => '_stock_status', - * 'compare' => 'IN' - * 'value' => ['instock', 'onbackorder'] - * ] - * ]] - * $new = ['meta_query' => [ - * [ - * 'relation' => 'AND', - * [...], - * [...], - * ] - * ]] - * Result: ['meta_query' => [ - * [ - * 'key' => '_stock_status', - * 'compare' => 'IN' - * 'value' => ['instock', 'onbackorder'] - * ], - * [ - * 'relation' => 'AND', - * [...], - * [...], - * ] - * ]] + * Block name. * - * $base = ['post__in' => [1, 2, 3, 4, 5]] - * $new = ['post__in' => [3, 4, 5, 6, 7]] - * Result: ['post__in' => [1, 2, 3, 4, 5, 3, 4, 5, 6, 7]] + * @var string + */ + protected $block_name = 'related-products'; + /** + * The Block with its attributes before it gets rendered * - * @param array $base First array. - * @param array $new Second array. + * @var array */ - private function array_merge_recursive_replace_non_array_properties($base, $new) + protected $parsed_block; + /** + * Initialize this block type. + * + * - Hook into WP lifecycle. + * - Register the block with WordPress. + * - Hook into pre_render_block to update the query. + */ + protected function initialize() { } /** - * Get product-related query variables from the global query. + * It isn't necessary register block assets because it is a server side block. + */ + protected function register_block_type_assets() + { + } + /** + * Get the frontend style handle for this block type. * - * @param array $parsed_block The Product Query that being rendered. + * @return null + */ + protected function get_block_type_style() + { + } + /** + * Update the query for the product query block. * - * @return array + * @param string|null $pre_render The pre-rendered content. Default null. + * @param array $parsed_block The block being rendered. */ - private function get_global_query($parsed_block) + public function update_query($pre_render, $parsed_block) { } /** - * Return a query that filters products by rating. + * Return a custom query based on attributes, filters and global WP_Query. * + * @param WP_Query $query The WordPress Query. + * @param WP_Block $block The block being rendered. * @return array */ - private function get_filter_by_rating_query() + public function build_query($query, $block = null) { } /** - * Return a query to filter products by taxonomies (product categories, product tags, etc.) + * If there are no related products, return an empty string. * - * For example: - * User could provide "Product Categories" using "Filters" ToolsPanel available in Inspector Controls. - * We use this function to extract it's query from $tax_query. + * @param string $content The block content. + * @param array $block The block. * - * For example, this is how the query for product categories will look like in $tax_query array: - * Array - * ( - * [taxonomy] => product_cat - * [terms] => Array - * ( - * [0] => 36 - * ) - * ) + * @return string The block content. + */ + public function render_block(string $content, array $block) + { + } + /** + * Determines whether the block is a related products block. * - * For product categories, taxonomy would be "product_tag" + * @param array $parsed_block The parsed block. + * @param array $rendered_block The rendered block. * - * @param array $query WP_Query. - * @return array Query to filter products by taxonomies. + * @return bool Whether the block is a related products block. */ - private function get_filter_by_taxonomies_query($query): array + private function is_related_products_block($parsed_block, $rendered_block = null) { } /** - * Returns the keyword filter from the given query. + * Get related products ids. + * The logic is copied from the core function woocommerce_related_products. https://github.com/woocommerce/woocommerce/blob/ca49caabcba84ce9f60a03c6d3534ec14b350b80/plugins/woocommerce/includes/wc-template-functions.php/#L2039-L2074 * - * @param WP_Query $query The query to extract the keyword filter from. - * @return array The keyword filter, or an empty array if none is found. + * @param number $product_per_page Products per page. + * @return array Products ids. */ - private function get_filter_by_keyword_query($query): array + private function get_related_products_ids($product_per_page = 5) { } } +} +namespace Automattic\WooCommerce\Blocks\BlockTypes\Reviews { /** - * ProductRating class. + * ProductReviewAuthorName class. */ - class ProductRating extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class ProductReviewAuthorName extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { /** * Block name. * * @var string */ - protected $block_name = 'product-rating'; + protected $block_name = 'product-review-author-name'; /** - * API version name. + * Render the block. * - * @var string + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block content. */ - protected $api_version = '3'; + protected function render($attributes, $content, $block) + { + } /** - * Get the block's attributes. + * Get the frontend script handle for this block type. * - * @param array $attributes Block attributes. Default empty array. - * @return array Block attributes merged with defaults. + * @see $this->register_block_type() + * @param string $key Data to get, or default to everything. + * @return array|string|null */ - private function parse_attributes($attributes) + protected function get_block_type_script($key = null) { } + } + /** + * ProductReviewContent class. + */ + class ProductReviewContent extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + { /** - * Overwrite parent method to prevent script registration. + * Block name. * - * It is necessary to register and enqueues assets during the render - * phase because we want to load assets only if the block has the content. + * @var string */ - protected function register_block_type_assets() + protected $block_name = 'product-review-content'; + /** + * Render the block. + * + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block content. + */ + protected function render($attributes, $content, $block) { } /** - * Get the frontend style handle for this block type. + * Get the frontend script handle for this block type. * - * @return null + * @see $this->register_block_type() + * @param string $key Data to get, or default to everything. + * @return array|string|null */ - protected function get_block_type_style() + protected function get_block_type_script($key = null) { } + } + /** + * ProductReviewDate class. + */ + class ProductReviewDate extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + { /** - * Register the context. + * Block name. + * + * @var string */ - protected function get_block_type_uses_context() + protected $block_name = 'product-review-date'; + /** + * Render the block. + * + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block content. + */ + protected function render($attributes, $content, $block) { } /** - * Include and render the block. + * Get the frontend script handle for this block type. * - * @param array $attributes Block attributes. Default empty array. - * @param string $content Block content. Default empty string. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @see $this->register_block_type() + * @param string $key Data to get, or default to everything. + * @return array|string|null */ - protected function render($attributes, $content, $block) + protected function get_block_type_script($key = null) { } } /** - * ProductRatingCounter class. + * ProductReviewForm class. */ - class ProductRatingCounter extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class ProductReviewForm extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { + use \Automattic\WooCommerce\Blocks\BlockTypes\EnableBlockJsonAssetsTrait; /** * Block name. * * @var string */ - protected $block_name = 'product-rating-counter'; + protected $block_name = 'product-review-form'; /** - * API version name. + * Render the block. * - * @var string + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block content. */ - protected $api_version = '3'; + protected function render($attributes, $content, $block) + { + } /** - * Get the block's attributes. - * - * @param array $attributes Block attributes. Default empty array. - * @return array Block attributes merged with defaults. + * Render stars for rating selector. */ - private function parse_attributes($attributes) + private function render_stars() { } + } + /** + * ProductReviewRating class. + */ + class ProductReviewRating extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + { /** - * Overwrite parent method to prevent script registration. + * Block name. * - * It is necessary to register and enqueues assets during the render - * phase because we want to load assets only if the block has the content. + * @var string */ - protected function register_block_type_assets() - { - } + protected $block_name = 'product-review-rating'; /** * Get the frontend style handle for this block type. * - * @return null + * @return string[]|null */ protected function get_block_type_style() { } /** - * Register the context. + * Render the block. + * + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block content. */ - protected function get_block_type_uses_context() + protected function render($attributes, $content, $block) { } /** - * Include and render the block. + * Get the frontend script handle for this block type. * - * @param array $attributes Block attributes. Default empty array. - * @param string $content Block content. Default empty string. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @see $this->register_block_type() + * @param string $key Data to get, or default to everything. + * @return array|string|null */ - protected function render($attributes, $content, $block) + protected function get_block_type_script($key = null) { } } /** - * ProductRatingStars class. + * ProductReviewTemplate class. */ - class ProductRatingStars extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class ProductReviewTemplate extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { /** * Block name. * * @var string */ - protected $block_name = 'product-rating-stars'; - /** - * API version name. - * - * @var string - */ - protected $api_version = '3'; + protected $block_name = 'product-review-template'; /** - * Overwrite parent method to prevent script registration. + * Get the frontend script handle for this block type. * - * It is necessary to register and enqueues assets during the render - * phase because we want to load assets only if the block has the content. + * @see $this->register_block_type() + * @param string $key Data to get, or default to everything. + * @return array|string|null */ - protected function register_block_type_assets() + protected function get_block_type_script($key = null) { } /** - * Register the context. + * Function that recursively renders a list of nested reviews. + * + * @since 6.3.0 Changed render_block_context priority to `1`. + * + * @param WP_Comment[] $comments The array of comments. + * @param WP_Block $block Block instance. + * @return string */ - protected function get_block_type_uses_context() + protected function block_product_review_template_render_comments($comments, $block) { } /** - * Include and render the block. + * Render the block. * - * @param array $attributes Block attributes. Default empty array. - * @param string $content Block content. Default empty string. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * @return string Rendered block content. */ protected function render($attributes, $content, $block) { } } /** - * ProductResultsCount class. + * ProductReviews class. */ - class ProductResultsCount extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class ProductReviews extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { + use \Automattic\WooCommerce\Blocks\BlockTypes\EnableBlockJsonAssetsTrait; /** * Block name. * * @var string */ - protected $block_name = 'product-results-count'; + protected $block_name = 'product-reviews'; /** - * Get the frontend script handle for this block type. + * Render the block. * - * @param string $key Data to get, or default to everything. + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. + * + * @return string Rendered block output. */ - protected function get_block_type_script($key = null) + protected function render($attributes, $content, $block) { } /** - * Render the block. + * Previously, the Product Reviews block was a standalone block. It doesn't + * have any inner blocks and it rendered the tabs directly like the classic + * template. When upgrading, we want the existing stores using the block to + * continue working as before, so we moved the logic the legacy render + * method here. * * @param array $attributes Block attributes. * @param string $content Block content. @@ -97301,147 +100370,203 @@ protected function get_block_type_script($key = null) * * @return string Rendered block output. */ - protected function render($attributes, $content, $block) + protected function render_legacy_block($attributes, $content, $block) { } } /** - * ProductSKU class. + * ProductReviewsPagination class. */ - class ProductSKU extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class ProductReviewsPagination extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { /** * Block name. * * @var string */ - protected $block_name = 'product-sku'; + protected $block_name = 'product-reviews-pagination'; /** - * API version name. + * Render the block. + * + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param \WP_Block $block Block instance. + * @return string Rendered block type output. + */ + protected function render($attributes, $content, $block) + { + } + /** + * Get the frontend script handle for this block type. + * + * @see $this->register_block_type() + * @param string $key Data to get, or default to everything. + * @return array|string|null + */ + protected function get_block_type_script($key = null) + { + } + } + /** + * ProductReviewsPaginationNext class. + */ + class ProductReviewsPaginationNext extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + { + /** + * Block name. * * @var string */ - protected $api_version = '3'; + protected $block_name = 'product-reviews-pagination-next'; /** - * Overwrite parent method to prevent script registration. + * Render the block. * - * It is necessary to register and enqueues assets during the render - * phase because we want to load assets only if the block has the content. + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param \WP_Block $block Block instance. + * @return string Rendered block type output. */ - protected function register_block_type_assets() + protected function render($attributes, $content, $block) { } /** - * Register the context. + * Get the pagination arrow. + * + * @param \WP_Block $block Block instance. + * @return string|null */ - protected function get_block_type_uses_context() + protected function get_pagination_arrow($block) { } /** - * Include and render the block. + * Get the frontend script handle for this block type. * - * @param array $attributes Block attributes. Default empty array. - * @param string $content Block content. Default empty string. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @see $this->register_block_type() + * @param string $key Data to get, or default to everything. + * @return array|string|null */ - protected function render($attributes, $content, $block) + protected function get_block_type_script($key = null) + { + } + /** + * Get the frontend style handle for this block type. + * + * @return string|null + */ + protected function get_block_type_style() { } } /** - * ProductSaleBadge class. + * ProductReviewsPaginationNumbers class. */ - class ProductSaleBadge extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class ProductReviewsPaginationNumbers extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { /** * Block name. * * @var string */ - protected $block_name = 'product-sale-badge'; - /** - * API version name. - * - * @var string - */ - protected $api_version = '3'; + protected $block_name = 'product-reviews-pagination-numbers'; /** - * Overwrite parent method to prevent script registration. + * Render the block. * - * It is necessary to register and enqueues assets during the render - * phase because we want to load assets only if the block has the content. + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param \WP_Block $block Block instance. + * @return string Rendered block type output. */ - protected function register_block_type_assets() + protected function render($attributes, $content, $block) { } /** - * Register the context. + * Get the frontend script handle for this block type. + * + * @see $this->register_block_type() + * @param string $key Data to get, or default to everything. + * @return array|string|null */ - protected function get_block_type_uses_context() + protected function get_block_type_script($key = null) { } /** - * Include and render the block. + * Get the frontend style handle for this block type. * - * @param array $attributes Block attributes. Default empty array. - * @param string $content Block content. Default empty string. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @return string|null */ - protected function render($attributes, $content, $block) + protected function get_block_type_style() { } } /** - * ProductSearch class. + * ProductReviewsPaginationPrevious class. */ - class ProductSearch extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class ProductReviewsPaginationPrevious extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { /** * Block name. * * @var string */ - protected $block_name = 'product-search'; + protected $block_name = 'product-reviews-pagination-previous'; + /** + * Render the block. + * + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param \WP_Block $block Block instance. + * @return string Rendered block type output. + */ + protected function render($attributes, $content, $block) + { + } + /** + * Get the pagination arrow. + * + * @param \WP_Block $block Block instance. + * @return string|null + */ + protected function get_pagination_arrow($block) + { + } /** * Get the frontend script handle for this block type. * + * @see $this->register_block_type() * @param string $key Data to get, or default to everything. - * @return null + * @return array|string|null */ protected function get_block_type_script($key = null) { } /** - * Render the block. + * Get the frontend style handle for this block type. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @return string|null */ - protected function render($attributes, $content, $block) + protected function get_block_type_style() { } } /** - * ProductSpecifications class. + * ProductReviewsTitle class. */ - class ProductSpecifications extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class ProductReviewsTitle extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { /** * Block name. * * @var string */ - protected $block_name = 'product-specifications'; + protected $block_name = 'product-reviews-title'; /** - * Get the frontend script handle for this block type. + * Get the reviews title. * - * @param string $key Data to get, or default to everything. + * @param array $attributes Block attributes. + * @param WC_Product $product Product instance. + * @return string */ - protected function get_block_type_script($key = null) + private function get_reviews_title($attributes, $product) { } /** @@ -97450,60 +100575,75 @@ protected function get_block_type_script($key = null) * @param array $attributes Block attributes. * @param string $content Block content. * @param WP_Block $block Block instance. - * - * @return string Rendered block output. + * @return string Rendered block content. */ protected function render($attributes, $content, $block) { } /** - * Get the frontend style handle for this block type. + * Get the frontend script handle for this block type. * - * @return string[] + * @see $this->register_block_type() + * @param string $key Data to get, or default to everything. + * @return array|string|null */ - protected function get_block_type_style() + protected function get_block_type_script($key = null) { } } +} +namespace Automattic\WooCommerce\Blocks\BlockTypes { /** - * ProductStockIndicator class. + * ReviewsByCategory class. */ - class ProductStockIndicator extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class ReviewsByCategory extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { - use \Automattic\WooCommerce\Blocks\BlockTypes\EnableBlockJsonAssetsTrait; - use \Automattic\WooCommerce\Blocks\Utils\BlocksSharedState; /** * Block name. * * @var string */ - protected $block_name = 'product-stock-indicator'; + protected $block_name = 'reviews-by-category'; /** - * API version name. + * Get the frontend script handle for this block type. * - * @var string + * @see $this->register_block_type() + * @param string $key Data to get, or default to everything. + * @return array|string */ - protected $api_version = '3'; + protected function get_block_type_script($key = null) + { + } /** - * Register script and style assets for the block type before it is registered. + * Extra data passed through from server to client for block. * - * This registers the scripts; it does not enqueue them. + * @param array $attributes Any attributes that currently are available from the block. + * Note, this will be empty in the editor context when the block is + * not in the post content on editor load. */ - protected function register_block_type_assets() + protected function enqueue_data(array $attributes = []) { } + } + /** + * ReviewsByProduct class. + */ + class ReviewsByProduct extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + { /** - * Register the context. + * Block name. + * + * @var string */ - protected function get_block_type_uses_context() - { - } + protected $block_name = 'reviews-by-product'; /** - * Get product types that should not display stock indicators. + * Get the frontend script handle for this block type. * - * @return array + * @see $this->register_block_type() + * @param string $key Data to get, or default to everything. + * @return array|string */ - protected function get_product_types_without_stock_indicator() + protected function get_block_type_script($key = null) { } /** @@ -97516,201 +100656,169 @@ protected function get_product_types_without_stock_indicator() protected function enqueue_data(array $attributes = []) { } - /** - * Renders the stock indicator block. - * - * This method handles both direct product context and global product context, - * ensuring the stock indicator displays correctly in various template scenarios. - * - * @param array $attributes Block attributes. Default empty array. - * @param string $content Block content. Default empty string. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. - */ - protected function render($attributes, $content, $block) - { - } } /** - * ProductSummary class. + * SingleProduct class. */ - class ProductSummary extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class SingleProduct extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { + use \Automattic\WooCommerce\Blocks\BlockTypes\EnableBlockJsonAssetsTrait; /** * Block name. * * @var string */ - protected $block_name = 'product-summary'; + protected $block_name = 'single-product'; /** - * API version name. + * Product ID of the current product to be displayed in the Single Product block. + * This is used to replace the global post for the Single Product inner blocks. * - * @var string + * @var int */ - protected $api_version = '3'; + protected $product_id = 0; /** - * Overwrite parent method to prevent script registration. + * Single Product inner blocks names. + * This is used to map all the inner blocks for a Single Product block. * - * It is necessary to register and enqueues assets during the render - * phase because we want to load assets only if the block has the content. - */ - protected function register_block_type_assets() - { - } - /** - * Register the context. + * @var array */ - protected function get_block_type_uses_context() - { - } + protected $single_product_inner_blocks_names = []; /** - * Get product description depends on config. + * Initialize the block and Hook into the `render_block_context` filter + * to update the context with the correct data. * - * @param WC_Product $product Product object. - * @param bool $show_description_if_empty Defines if fallback to full description. - * @return string + * @var string */ - private function get_source($product, $show_description_if_empty) + protected function initialize() { } /** - * Create anchor element based on input. + * Restore the global post variable right before generating the render output for the post title and/or post excerpt blocks. * - * @param WC_Product $product Product object. - * @param string $link_text Link text. - * @return string + * This is required due to the changes made via the replace_post_for_single_product_inner_block method. + * It is a temporary fix to ensure these blocks work as expected until Gutenberg versions 15.2 and 15.6 are part of the core of WordPress. + * + * @see https://github.com/WordPress/gutenberg/pull/48001 + * @see https://github.com/WordPress/gutenberg/pull/49495 + * + * @param string $block_content The block content. + * @param array $parsed_block The full block, including name and attributes. + * @param \WP_Block $block_instance The block instance. + * + * @return mixed */ - private function create_anchor($product, $link_text) + public function restore_global_post($block_content, $parsed_block, $block_instance) { } /** - * Get first paragraph from some HTML text, or return the whole string. + * Update the context by injecting the correct post data + * for each one of the Single Product inner blocks. * - * @param string $source Source text. - * @return string First paragraph found in string. + * @param array $context Block context. + * @param array $block Block attributes. + * @param WP_Block $parent_block Block instance. + * + * @return array Updated block context. */ - private function get_first_paragraph($source) + public function update_context($context, $block, $parent_block) { } /** - * Count words, characters (excluding spaces), or characters (including spaces). + * Extract the inner block names for the Single Product block. This way it's possible + * to map all the inner blocks for a Single Product block and manipulate the data as needed. * - * @param string $text Text to count. - * @param string $count_type Count type: 'words', 'characters_excluding_spaces', or 'characters_including_spaces'. - * @return int Count of specified type. + * @param array $block The Single Product block or its inner blocks. + * @param array $result Array of inner block names. + * + * @return array Array containing all the inner block names of a Single Product block. */ - private function count_text($text, $count_type) + protected function extract_single_product_inner_block_names($block, &$result = []) { } /** - * Trim characters to a specified length. + * Replace the global post for the Single Product inner blocks and reset it after. * - * @param string $text Text to trim. - * @param int $max_length Maximum length of the text. - * @param string $count_type What is being counted. One of 'words', 'characters_excluding_spaces', or 'characters_including_spaces'. - * @return string Trimmed text. + * This is needed because some of the inner blocks may use the global post + * instead of fetching the product through the `productId` attribute, so even if the + * `productId` is passed to the inner block, it will still use the global post. + * + * @param array $block Block attributes. + * @param array $context Block context. */ - private function trim_characters($text, $max_length, $count_type) + protected function replace_post_for_single_product_inner_block($block, &$context) { } /** - * Generates the summary text from a string of text. It's not ideal - * but allows keeping the editor and frontend consistent. - * - * NOTE: If editing, keep it in sync with generateSummary function from - * plugins/woocommerce/client/blocks/assets/js/base/components/summary/utils.ts! + * Render the Single Product block. * - * Once HTML API allow for HTML manipulation both functions (PHP and JS) - * should be updated to solution fully respecting the word count. - * https://github.com/woocommerce/woocommerce/issues/52835 + * @param array $attributes Block attributes. + * @param string $content Block content. + * @param WP_Block $block Block instance. * - * @param string $source Source text. - * @param int $max_length Limit number of items returned if text has multiple paragraphs. - * @return string Generated summary. + * @return string Rendered block type output. */ - private function generate_summary($source, $max_length) + protected function render($attributes, $content, $block) { } /** - * Include and render the block. + * Get the frontend script handle for this block type. * - * @param array $attributes Block attributes. Default empty array. - * @param string $content Block content. Default empty string. - * @param WP_Block $block Block instance. - * @return string Rendered block type output. + * @param string $key Data to get, or default to everything. + * + * @return null This block has no frontend script. */ - protected function render($attributes, $content, $block) + protected function get_block_type_script($key = null) { } } /** - * ProductTag class. + * AttributeFilter class. */ - class ProductTag extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractProductGrid + class StockFilter extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { /** * Block name. * * @var string */ - protected $block_name = 'product-tag'; + protected $block_name = 'stock-filter'; + const STOCK_STATUS_QUERY_VAR = 'filter_stock_status'; /** - * Set args specific to this block. + * Extra data passed through from server to client for block. * - * @param array $query_args Query args. + * @param array $stock_statuses Any stock statuses that currently are available from the block. + * Note, this will be empty in the editor context when the block is + * not in the post content on editor load. */ - protected function set_block_query_args(&$query_args) + protected function enqueue_data(array $stock_statuses = []) { } /** - * Get block attributes. - * - * @return array + * Get Stock status query variables values. */ - protected function get_block_type_attributes() + public static function get_stock_status_query_var_values() { } /** - * Extra data passed through from server to client for block. + * Get the frontend style handle for this block type. * - * @param array $attributes Any attributes that currently are available from the block. - * Note, this will be empty in the editor context when the block is - * not in the post content on editor load. + * @return string[] */ - protected function enqueue_data(array $attributes = []) + protected function get_block_type_style() { } } /** - * ProductTemplate class. + * StoreNotices class. */ - class ProductTemplate extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class StoreNotices extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock { - use \Automattic\WooCommerce\Blocks\BlockTypes\EnableBlockJsonAssetsTrait; /** * Block name. * * @var string */ - protected $block_name = 'product-template'; - /** - * Initialize this block type. - * - * - Hook into WP lifecycle. - * - Register the block with WordPress. - * - Hook into pre_render_block to update the query. - */ - protected function initialize() - { - } - /** - * Get the frontend script handle for this block type. - * - * @param string $key Data to get, or default to everything. - */ - protected function get_block_type_script($key = null) - { - } + protected $block_name = 'store-notices'; /** * Render the block. * @@ -97724,4330 +100832,4425 @@ protected function render($attributes, $content, $block) { } /** - * Determines whether a block list contains a block that uses the featured image. - * - * @param WP_Block_List $inner_blocks Inner block instance. - * - * @return bool Whether the block list contains a block that uses the featured image. - */ - protected function block_core_post_template_uses_featured_image($inner_blocks) - { - } - /** - * Product Template renders inner blocks manually so we need to skip default - * rendering routine for its inner blocks + * Disable frontend script for this block type, it's a script module. * - * @param array $settings Array of determined settings for registering a block type. - * @param array $metadata Metadata provided for registering a block type. - * @return array + * @param string $key Data to get, or default to everything. + * @return array|string|null */ - public function add_block_type_metadata_settings($settings, $metadata) + protected function get_block_type_script($key = null) { } } +} +namespace Automattic\WooCommerce\Blocks { /** - * ProductTitle class. + * BlockTypesController class. + * + * @since 5.0.0 + * @internal */ - class ProductTitle extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + final class BlockTypesController { /** - * Block name. + * Instance of the asset API. * - * @var string + * @var AssetApi */ - protected $block_name = 'product-title'; + protected $asset_api; /** - * API version name. + * Instance of the asset data registry. * - * @var string + * @var AssetDataRegistry */ - protected $api_version = '3'; + protected $asset_data_registry; /** - * Register script and style assets for the block type before it is registered. + * Holds the registered blocks that have WooCommerce blocks as their parents. * - * This registers the scripts; it does not enqueue them. + * @var array List of registered blocks. */ - protected function register_block_type_assets() - { - } - } - /** - * ProductTopRated class. - */ - class ProductTopRated extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractProductGrid - { + private $registered_blocks_with_woocommerce_parents; /** - * Block name. + * Constructor. * - * @var string + * @param AssetApi $asset_api Instance of the asset API. + * @param AssetDataRegistry $asset_data_registry Instance of the asset data registry. */ - protected $block_name = 'product-top-rated'; + public function __construct(\Automattic\WooCommerce\Blocks\Assets\Api $asset_api, \Automattic\WooCommerce\Blocks\Assets\AssetDataRegistry $asset_data_registry) + { + } /** - * Force orderby to rating. - * - * @param array $query_args Query args. + * Initialize class features. */ - protected function set_block_query_args(&$query_args) + protected function init() { } - } - /** - * ProductsByAttribute class. - */ - class ProductsByAttribute extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractProductGrid - { /** - * Block name. + * Get registered blocks that have WooCommerce blocks as their parents. Adds the value to the + * `registered_blocks_with_woocommerce_parents` cache if `init` has been fired. * - * @var string + * @return array Registered blocks with WooCommerce blocks as parents. */ - protected $block_name = 'products-by-attribute'; + public function get_registered_blocks_with_woocommerce_parent() + { + } /** - * Set args specific to this block - * - * @param array $query_args Query args. + * Register blocks, hooking up assets and render functions as needed. */ - protected function set_block_query_args(&$query_args) + public function register_blocks() { } /** - * Get block attributes. + * Register block metadata collections for WooCommerce blocks. * - * @return array + * This method handles the registration of block metadata by using WordPress's block metadata + * collection registration system. It includes a temporary workaround for WordPress 6.7's + * strict path validation that might fail for sites using symlinked plugins. + * + * If the registration fails due to path validation, blocks will fall back to regular + * registration without affecting functionality. */ - protected function get_block_type_attributes() + public function register_block_metadata() { } - } - /** - * PriceFilter class. - */ - class RatingFilter extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock - { /** - * Block name. + * Temporarily bypasses _doing_it_wrong() notices for block metadata collection registration. * - * @var string - */ - protected $block_name = 'rating-filter'; - const RATING_QUERY_VAR = 'rating_filter'; - /** - * Get the frontend script handle for this block type. + * WordPress 6.7 introduced block metadata collections (with strict path validation). + * Any sites using symlinks for plugins will fail the validation which causes the metadata + * collection to not be registered. However, the blocks will still fall back to the regular + * registration and no functionality is affected. + * While this validation is being discussed in WordPress Core (#62140), + * this method allows registration to proceed by temporarily disabling + * the relevant notice. * - * @param string $key Data to get, or default to everything. + * @param bool $trigger Whether to trigger the error. + * @param string $function The function that was called. + * @param string $message A message explaining what was done incorrectly. + * @param string $version The version of WordPress where the message was added. + * @return bool Whether to trigger the error. */ - protected function get_block_type_script($key = null) + public static function bypass_block_metadata_doing_it_wrong($trigger, $function, $message, $version) { } /** - * Get the frontend style handle for this block type. - * - * @return string[] + * Register block patterns */ - protected function get_block_type_style() + public function register_block_patterns() { } - } - /** - * RelatedProducts class. - */ - class RelatedProducts extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock - { /** - * Block name. + * Register block categories * - * @var string - */ - protected $block_name = 'related-products'; - /** - * The Block with its attributes before it gets rendered + * Used in combination with the `block_categories_all` filter, to append + * WooCommerce Blocks related categories to the Gutenberg editor. * - * @var array + * @param array $categories The array of already registered categories. */ - protected $parsed_block; + public function register_block_categories($categories) + { + } /** - * Initialize this block type. + * Check if a block should have data attributes appended on render. If it's in an allowed namespace, or the block + * has explicitly been added to the allowed block list, or if one of the block's parents is in the WooCommerce + * namespace it can have data attributes. * - * - Hook into WP lifecycle. - * - Register the block with WordPress. - * - Hook into pre_render_block to update the query. + * @param string $block_name Name of the block to check. + * + * @return boolean */ - protected function initialize() + public function block_should_have_data_attributes($block_name) { } /** - * It isn't necessary register block assets because it is a server side block. + * Add data- attributes to blocks when rendered if the block is under the woocommerce/ namespace. + * + * @param string $content Block content. + * @param array $block Parsed block data. + * @return string */ - protected function register_block_type_assets() + public function add_data_attributes($content, $block) { } /** - * Get the frontend style handle for this block type. - * - * @return null + * Adds a redirect field to the login form so blocks can redirect users after login. */ - protected function get_block_type_style() + public function redirect_to_field() { } /** - * Update the query for the product query block. + * Hide legacy widgets with a feature complete block equivalent in the inserter + * and prevent them from showing as an option in the Legacy Widget block. * - * @param string|null $pre_render The pre-rendered content. Default null. - * @param array $parsed_block The block being rendered. + * @param array $widget_types An array of widgets hidden in core. + * @return array $widget_types An array including the WooCommerce widgets to hide. */ - public function update_query($pre_render, $parsed_block) + public function hide_legacy_widgets_with_block_equivalent($widget_types) { } /** - * Return a custom query based on attributes, filters and global WP_Query. - * - * @param WP_Query $query The WordPress Query. - * @param WP_Block $block The block being rendered. - * @return array + * Delete product transients when a product is deleted. */ - public function build_query($query, $block = null) + public function delete_product_transients() { } /** - * If there are no related products, return an empty string. - * - * @param string $content The block content. - * @param array $block The block. + * Get list of block types allowed in Widget Areas. New blocks won't be + * exposed in the Widget Area unless specifically added here. * - * @return string The block content. + * @return array Array of block types. */ - public function render_block(string $content, array $block) + protected function get_widget_area_block_types() { } /** - * Determines whether the block is a related products block. - * - * @param array $parsed_block The parsed block. - * @param array $rendered_block The rendered block. + * Get list of block types. * - * @return bool Whether the block is a related products block. + * @return array */ - private function is_related_products_block($parsed_block, $rendered_block = null) + protected function get_block_types() { } /** - * Get related products ids. - * The logic is copied from the core function woocommerce_related_products. https://github.com/woocommerce/woocommerce/blob/ca49caabcba84ce9f60a03c6d3534ec14b350b80/plugins/woocommerce/includes/wc-template-functions.php/#L2039-L2074 + * By default, when the classic theme is used, block style is always + * enqueued even if the block is not used on the page. We want WooCommerce + * store to always performant so we have to manually enqueue the block style + * on-demand for classic themes. * - * @param number $product_per_page Products per page. - * @return array Products ids. + * @internal + * + * @param array $args Block metadata. + * @param string $block_name Block name. + * + * @return array Block metadata. */ - private function get_related_products_ids($product_per_page = 5) + public function enqueue_block_style_for_classic_themes($args, $block_name) { } } } -namespace Automattic\WooCommerce\Blocks\BlockTypes\Reviews { +namespace Automattic\WooCommerce\Blocks\Domain { /** - * ProductReviewAuthorName class. + * Takes care of bootstrapping the plugin. + * + * @since 2.5.0 */ - class ProductReviewAuthorName extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class Bootstrap { /** - * Block name. + * Holds the Dependency Injection Container * - * @var string + * @var Container */ - protected $block_name = 'product-review-author-name'; + private $container; /** - * Render the block. + * Holds the Package instance * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block content. + * @var Package */ - protected function render($attributes, $content, $block) + private $package; + /** + * Constructor + * + * @param Container $container The Dependency Injection Container. + */ + public function __construct(\Automattic\WooCommerce\Blocks\Registry\Container $container) { } /** - * Get the frontend script handle for this block type. + * Init the package - load the blocks library and define constants. + */ + protected function init() + { + } + /** + * See if files have been built or not. * - * @see $this->register_block_type() - * @param string $key Data to get, or default to everything. - * @return array|string|null + * @return bool */ - protected function get_block_type_script($key = null) + protected function is_built() + { + } + /** + * Add a notice stating that the build has not been done yet. + */ + protected function add_build_notice() + { + } + /** + * Register core dependencies with the container. + */ + protected function register_dependencies() + { + } + /** + * Throws a deprecation notice for a dependency without breaking requests. + * + * @param string $function Class or function being deprecated. + * @param string $version Version in which it was deprecated. + * @param string $replacement Replacement class or function, if applicable. + * @param string $trigger_error_version Optional version to start surfacing this as a PHP error rather than a log. Defaults to $version. + */ + protected function deprecated_dependency($function, $version, $replacement = '', $trigger_error_version = '') + { + } + /** + * Register payment method integrations with the container. + */ + protected function register_payment_methods() { } } /** - * ProductReviewContent class. + * Main package class. + * + * Returns information about the package and handles init. + * + * @since 2.5.0 */ - class ProductReviewContent extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class Package { /** - * Block name. + * Holds the current version of the blocks plugin. * * @var string */ - protected $block_name = 'product-review-content'; + private $version; /** - * Render the block. + * Holds the main path to the blocks plugin directory. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block content. + * @var string */ - protected function render($attributes, $content, $block) - { - } + private $path; /** - * Get the frontend script handle for this block type. + * Holds locally the plugin_dir_url to avoid recomputing it. * - * @see $this->register_block_type() - * @param string $key Data to get, or default to everything. - * @return array|string|null + * @var string */ - protected function get_block_type_script($key = null) - { - } - } - /** - * ProductReviewDate class. - */ - class ProductReviewDate extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock - { + private $plugin_dir_url; /** - * Block name. + * Holds the feature gating class instance. * - * @var string + * @var FeatureGating */ - protected $block_name = 'product-review-date'; + private $feature_gating; /** - * Render the block. + * Constructor * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block content. + * @param string $version Version of the plugin. + * @param string $plugin_path Path to the main plugin file. + * @param FeatureGating $deprecated Deprecated Feature gating class. */ - protected function render($attributes, $content, $block) + public function __construct($version, $plugin_path, $deprecated = null) { } /** - * Get the frontend script handle for this block type. + * Returns the version of WooCommerce Blocks. * - * @see $this->register_block_type() - * @param string $key Data to get, or default to everything. - * @return array|string|null + * Note: since Blocks was merged into WooCommerce Core, the version of + * WC Blocks doesn't update anymore. Use + * `Constants::get_constant( 'WC_VERSION' )` when possible to get the + * WooCommerce Core version. + * + * @return string */ - protected function get_block_type_script($key = null) + public function get_version() { } - } - /** - * ProductReviewForm class. - */ - class ProductReviewForm extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock - { - use \Automattic\WooCommerce\Blocks\BlockTypes\EnableBlockJsonAssetsTrait; - /** - * Block name. - * - * @var string - */ - protected $block_name = 'product-review-form'; /** - * Render the block. + * Returns the version of WooCommerce Blocks stored in the database. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block content. + * @return string */ - protected function render($attributes, $content, $block) + public function get_version_stored_on_db() { } /** - * Render stars for rating selector. + * Sets the version of WooCommerce Blocks in the database. + * This is useful during the first installation or after the upgrade process. */ - private function render_stars() + public function set_version_stored_on_db() { } - } - /** - * ProductReviewRating class. - */ - class ProductReviewRating extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock - { /** - * Block name. + * Returns the path to the plugin directory. * - * @var string - */ - protected $block_name = 'product-review-rating'; - /** - * Get the frontend style handle for this block type. + * @param string $relative_path If provided, the relative path will be + * appended to the plugin path. * - * @return string[]|null + * @return string */ - protected function get_block_type_style() + public function get_path($relative_path = '') { } /** - * Render the block. + * Returns the url to the blocks plugin directory. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block content. + * @param string $relative_url If provided, the relative url will be + * appended to the plugin url. + * + * @return string */ - protected function render($attributes, $content, $block) + public function get_url($relative_url = '') { } /** - * Get the frontend script handle for this block type. + * Returns an instance of the FeatureGating class. * - * @see $this->register_block_type() - * @param string $key Data to get, or default to everything. - * @return array|string|null + * @return FeatureGating */ - protected function get_block_type_script($key = null) + public function feature() { } } +} +namespace Automattic\WooCommerce\Blocks\Domain\Services { /** - * ProductReviewTemplate class. + * Service class managing checkout fields and its related extensibility points. */ - class ProductReviewTemplate extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock + class CheckoutFields { /** - * Block name. + * Additional checkout fields. * - * @var string + * @var array */ - protected $block_name = 'product-review-template'; + private $additional_fields = []; /** - * Get the frontend script handle for this block type. + * Fields locations. * - * @see $this->register_block_type() - * @param string $key Data to get, or default to everything. - * @return array|string|null + * @var array */ - protected function get_block_type_script($key = null) - { - } + private $fields_locations; /** - * Function that recursively renders a list of nested reviews. + * Supported field types * - * @since 6.3.0 Changed render_block_context priority to `1`. + * @var array + */ + private $supported_field_types = ['text', 'select', 'checkbox']; + /** + * Groups of fields to be saved. * - * @param WP_Comment[] $comments The array of comments. - * @param WP_Block $block Block instance. - * @return string + * @var array */ - protected function block_product_review_template_render_comments($comments, $block) - { - } + private $groups = ['billing', 'shipping', 'other']; /** - * Render the block. + * Instance of the asset data registry. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block content. + * @var AssetDataRegistry */ - protected function render($attributes, $content, $block) - { - } - } - /** - * ProductReviews class. - */ - class ProductReviews extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock - { - use \Automattic\WooCommerce\Blocks\BlockTypes\EnableBlockJsonAssetsTrait; + private $asset_data_registry; /** - * Block name. + * Billing fields meta key. * * @var string */ - protected $block_name = 'product-reviews'; + const BILLING_FIELDS_PREFIX = '_wc_billing/'; /** - * Render the block. + * Shipping fields meta key. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. + * @var string + */ + const SHIPPING_FIELDS_PREFIX = '_wc_shipping/'; + /** + * Additional fields meta key. * - * @return string Rendered block output. + * @var string + * @deprecated 8.9.0 Use OTHER_FIELDS_PREFIX instead. */ - protected function render($attributes, $content, $block) - { - } + const ADDITIONAL_FIELDS_PREFIX = '_wc_additional/'; /** - * Previously, the Product Reviews block was a standalone block. It doesn't - * have any inner blocks and it rendered the tabs directly like the classic - * template. When upgrading, we want the existing stores using the block to - * continue working as before, so we moved the logic the legacy render - * method here. + * Other fields meta key. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. + * @var string + */ + const OTHER_FIELDS_PREFIX = '_wc_other/'; + /** + * Sets up core fields. * - * @return string Rendered block output. + * @param AssetDataRegistry $asset_data_registry Instance of the asset data registry. */ - protected function render_legacy_block($attributes, $content, $block) + public function __construct(\Automattic\WooCommerce\Blocks\Assets\AssetDataRegistry $asset_data_registry) { } - } - /** - * ProductReviewsPagination class. - */ - class ProductReviewsPagination extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock - { /** - * Block name. - * - * @var string + * Initialize hooks. */ - protected $block_name = 'product-reviews-pagination'; + public function init() + { + } /** - * Render the block. + * Add fields data to the asset data registry. + */ + public function add_fields_data() + { + } + /** + * Add session meta keys. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param \WP_Block $block Block instance. - * @return string Rendered block type output. + * This is an allow-list of meta data keys which we want to store in session. + * + * @param array $keys Session meta keys. + * @return array */ - protected function render($attributes, $content, $block) + public function add_session_meta_keys($keys) { } /** - * Get the frontend script handle for this block type. + * If a field does not declare a sanitization callback, this is the default sanitization callback. * - * @see $this->register_block_type() - * @param string $key Data to get, or default to everything. - * @return array|string|null + * @param mixed $value Value to sanitize. + * @param array $field Field data. + * @return mixed */ - protected function get_block_type_script($key = null) + public function default_sanitize_callback($value, $field) { } - } - /** - * ProductReviewsPaginationNext class. - */ - class ProductReviewsPaginationNext extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock - { /** - * Block name. + * If a field does not declare a validation callback, this is the default validation callback. * - * @var string + * @param mixed $value Value to sanitize. + * @param array $field Field data. + * @return WP_Error|void If there is a validation error, return an WP_Error object. */ - protected $block_name = 'product-reviews-pagination-next'; + public function default_validate_callback($value, $field) + { + } /** - * Render the block. + * Registers an additional field for Checkout. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param \WP_Block $block Block instance. - * @return string Rendered block type output. + * @param array $options The field options. + * + * @return WP_Error|void True if the field was registered, a WP_Error otherwise. */ - protected function render($attributes, $content, $block) + public function register_checkout_field($options) { } /** - * Get the pagination arrow. + * Returns true if the field is required. Takes rules into consideration if a document object is provided. * - * @param \WP_Block $block Block instance. - * @return string|null + * @param array|string $field The field array or field key. + * @param DocumentObject|null $document_object The document object. + * @return bool */ - protected function get_pagination_arrow($block) + public function is_required_field($field, $document_object = null) { } /** - * Get the frontend script handle for this block type. + * Returns true if the field is hidden. Takes rules into consideration if a document object is provided. * - * @see $this->register_block_type() - * @param string $key Data to get, or default to everything. - * @return array|string|null + * @param array|string $field The field array or field key. + * @param DocumentObject|null $document_object The document object. + * @return bool */ - protected function get_block_type_script($key = null) + public function is_hidden_field($field, $document_object = null) { } /** - * Get the frontend style handle for this block type. + * Returns true if the field is conditionally required or rendered. * - * @return string|null + * @param array|string $field The field array or field key. + * @return bool */ - protected function get_block_type_style() + public function is_conditional_field($field) { } - } - /** - * ProductReviewsPaginationNumbers class. - */ - class ProductReviewsPaginationNumbers extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock - { /** - * Block name. + * Validates a field against the given document object and context. * - * @var string + * @param array $field The field. + * @param DocumentObject|null $document_object The document object. + * @return bool|\WP_Error True if the field is valid, a WP_Error otherwise. */ - protected $block_name = 'product-reviews-pagination-numbers'; + public function is_valid_field($field, $document_object = null) + { + } /** - * Render the block. + * Returns true if the property is an array and not empty. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param \WP_Block $block Block instance. - * @return string Rendered block type output. + * @param mixed $property The property to check. + * @return bool */ - protected function render($attributes, $content, $block) + protected function contains_valid_rules($property) { } /** - * Get the frontend script handle for this block type. + * Returns the validate callback for a given field. * - * @see $this->register_block_type() - * @param string $key Data to get, or default to everything. - * @return array|string|null + * @param array $field The field. + * @param DocumentObject|null $document_object The document object. + * @return callable The validate callback. */ - protected function get_block_type_script($key = null) + public function get_validate_callback($field, $document_object = null) { } /** - * Get the frontend style handle for this block type. + * Deregister a checkout field. * - * @return string|null + * @param string $field_id The field ID. + * + * @internal */ - protected function get_block_type_style() + public function deregister_checkout_field($field_id) { } - } - /** - * ProductReviewsPaginationPrevious class. - */ - class ProductReviewsPaginationPrevious extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock - { /** - * Block name. + * Validates the "base" options (id, label, location) and shows warnings if they're not supplied. * - * @var string + * @param array $options The options supplied during field registration. + * @return bool false if an error was encountered, true otherwise. */ - protected $block_name = 'product-reviews-pagination-previous'; + private function validate_options(&$options) + { + } /** - * Render the block. + * Processes the options for a field type and returns the new field_options array. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param \WP_Block $block Block instance. - * @return string Rendered block type output. + * @param array $field_data The field data array to be updated. + * @param array $options The options supplied during field registration. + * @return array The updated $field_data array. */ - protected function render($attributes, $content, $block) + private function process_field_options($field_data, $options) { } /** - * Get the pagination arrow. + * Processes the options for a select field and returns the new field_options array. * - * @param \WP_Block $block Block instance. - * @return string|null + * @param array $field_data The field data array to be updated. + * @param array $options The options supplied during field registration. + * + * @return array|false The updated $field_data array or false if an error was encountered. */ - protected function get_pagination_arrow($block) + private function process_select_field($field_data, $options) { } /** - * Get the frontend script handle for this block type. + * Processes the options for a checkbox field and returns the new field_options array. * - * @see $this->register_block_type() - * @param string $key Data to get, or default to everything. - * @return array|string|null + * @param array $field_data The field data array to be updated. + * @param array $options The options supplied during field registration. + * + * @return array|false The updated $field_data array or false if an error was encountered. */ - protected function get_block_type_script($key = null) + private function process_checkbox_field($field_data, $options) { } /** - * Get the frontend style handle for this block type. + * Processes the attributes supplied during field registration. * - * @return string|null + * @param array $id The field ID. + * @param array $attributes The attributes supplied during field registration. + * + * @return array The processed attributes. */ - protected function get_block_type_style() + private function register_field_attributes($id, $attributes) { } - } - /** - * ProductReviewsTitle class. - */ - class ProductReviewsTitle extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock - { /** - * Block name. + * Returns the keys of all core fields. * - * @var string + * @return array An array of field keys. */ - protected $block_name = 'product-reviews-title'; + public function get_core_fields_keys() + { + } /** - * Get the reviews title. + * Returns an array of all core fields. * - * @param array $attributes Block attributes. - * @param WC_Product $product Product instance. - * @return string + * @return array An array of fields. */ - private function get_reviews_title($attributes, $product) + public function get_core_fields() { } /** - * Render the block. + * Returns an array of all additional fields. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. - * @return string Rendered block content. + * @return array An array of fields. */ - protected function render($attributes, $content, $block) + public function get_additional_fields() { } /** - * Get the frontend script handle for this block type. + * Gets the location of a field. * - * @see $this->register_block_type() - * @param string $key Data to get, or default to everything. - * @return array|string|null + * @param string $field_key The key of the field to get the location for. + * @return string The location of the field. */ - protected function get_block_type_script($key = null) + public function get_field_location($field_key) { } - } -} -namespace Automattic\WooCommerce\Blocks\BlockTypes { - /** - * ReviewsByCategory class. - */ - class ReviewsByCategory extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock - { /** - * Block name. + * Sanitize an additional field against any custom sanitization rules. * - * @var string + * @since 8.7.0 + * @param string $field_key The key of the field. + * @param mixed $field_value The value of the field. + * @return mixed */ - protected $block_name = 'reviews-by-category'; + public function sanitize_field($field_key, $field_value) + { + } /** - * Get the frontend script handle for this block type. + * Validate an additional field. * - * @see $this->register_block_type() - * @param string $key Data to get, or default to everything. - * @return array|string + * @since 8.6.0 + * + * @param array $field The field. + * @param mixed $field_value The value of the field. + * @return WP_Error */ - protected function get_block_type_script($key = null) + public function validate_field($field, $field_value) { } /** - * Extra data passed through from server to client for block. + * Update the default locale with additional fields without country limitations. * - * @param array $attributes Any attributes that currently are available from the block. - * Note, this will be empty in the editor context when the block is - * not in the post content on editor load. + * @param array $locale The locale to update. + * @return mixed */ - protected function enqueue_data(array $attributes = []) + public function update_default_locale_with_fields($locale) { } - } - /** - * ReviewsByProduct class. - */ - class ReviewsByProduct extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock - { /** - * Block name. + * Returns an array of fields keys for the address location. * - * @var string + * @return array An array of fields keys. */ - protected $block_name = 'reviews-by-product'; + public function get_address_fields_keys() + { + } /** - * Get the frontend script handle for this block type. + * Returns an array of fields keys for the contact location. * - * @see $this->register_block_type() - * @param string $key Data to get, or default to everything. - * @return array|string + * @return array An array of fields keys. */ - protected function get_block_type_script($key = null) + public function get_contact_fields_keys() { } /** - * Extra data passed through from server to client for block. + * Returns an array of fields keys for the additional area location. * - * @param array $attributes Any attributes that currently are available from the block. - * Note, this will be empty in the editor context when the block is - * not in the post content on editor load. + * @return array An array of fields keys. + * @deprecated 8.9.0 Use get_order_fields_keys instead. */ - protected function enqueue_data(array $attributes = []) + public function get_additional_fields_keys() { } - } - /** - * SingleProduct class. - */ - class SingleProduct extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock - { - use \Automattic\WooCommerce\Blocks\BlockTypes\EnableBlockJsonAssetsTrait; /** - * Block name. + * Returns an array of fields keys for the additional area group. * - * @var string + * @return array An array of fields keys. */ - protected $block_name = 'single-product'; + public function get_order_fields_keys() + { + } /** - * Product ID of the current product to be displayed in the Single Product block. - * This is used to replace the global post for the Single Product inner blocks. + * Returns an array of fields for a given location. * - * @var int + * @param string $location The location to get fields for (address|contact|order). + * @return array An array of fields definitions. */ - protected $product_id = 0; + public function get_fields_for_location($location) + { + } /** - * Single Product inner blocks names. - * This is used to map all the inner blocks for a Single Product block. + * Returns an array of fields for a given location and uses context to evaluate hidden and required fields. * - * @var array + * @param string $location The location to get fields for (address|contact|order). + * @param DocumentObject|null $document_object The document object. + * @return array An array of fields definitions. */ - protected $single_product_inner_blocks_names = []; + public function get_contextual_fields_for_location($location, $document_object = null) + { + } /** - * Initialize the block and Hook into the `render_block_context` filter - * to update the context with the correct data. + * Validates a set of fields for a given location against custom validation rules. * - * @var string + * @param array $fields Array of key value pairs of field values to validate. + * @param string $location The location being validated (address|contact|order). + * @param string $group The group to get the field value for (shipping|billing|other). + * @return WP_Error */ - protected function initialize() + public function validate_fields_for_location($fields, $location, $group = 'other') { } /** - * Restore the global post variable right before generating the render output for the post title and/or post excerpt blocks. - * - * This is required due to the changes made via the replace_post_for_single_product_inner_block method. - * It is a temporary fix to ensure these blocks work as expected until Gutenberg versions 15.2 and 15.6 are part of the core of WordPress. + * Validates a field to check it belongs to the given location and is valid according to its registration. * - * @see https://github.com/WordPress/gutenberg/pull/48001 - * @see https://github.com/WordPress/gutenberg/pull/49495 + * This does not apply any custom validation rules on the value. * - * @param string $block_content The block content. - * @param array $parsed_block The full block, including name and attributes. - * @param \WP_Block $block_instance The block instance. + * @param string $key The field key. + * @param mixed $value The field value. + * @param string $location The location to validate the field for (address|contact|order). * - * @return mixed + * @return true|WP_Error True if the field is valid, a WP_Error otherwise. */ - public function restore_global_post($block_content, $parsed_block, $block_instance) + public function validate_field_for_location($key, $value, $location) { } /** - * Update the context by injecting the correct post data - * for each one of the Single Product inner blocks. + * Returns all fields key for a given group. * - * @param array $context Block context. - * @param array $block Block attributes. - * @param WP_Block $parent_block Block instance. + * @param string $group The group to get the key for (shipping|billing|other). * - * @return array Updated block context. + * @return string[] Field keys. */ - public function update_context($context, $block, $parent_block) + public function get_fields_for_group($group = 'other') { } /** - * Extract the inner block names for the Single Product block. This way it's possible - * to map all the inner blocks for a Single Product block and manipulate the data as needed. + * Returns true if the given key is a valid field. * - * @param array $block The Single Product block or its inner blocks. - * @param array $result Array of inner block names. + * @param string $key The field key. * - * @return array Array containing all the inner block names of a Single Product block. + * @return bool True if the field is valid, false otherwise. */ - protected function extract_single_product_inner_block_names($block, &$result = []) + public function is_field($key) { } /** - * Replace the global post for the Single Product inner blocks and reset it after. + * Returns true if the given key is a valid customer field. * - * This is needed because some of the inner blocks may use the global post - * instead of fetching the product through the `productId` attribute, so even if the - * `productId` is passed to the inner block, it will still use the global post. + * Customer fields are fields saved to the customer data, like address and contact fields. * - * @param array $block Block attributes. - * @param array $context Block context. + * @param string $key The field key. + * + * @return bool True if the field is valid, false otherwise. */ - protected function replace_post_for_single_product_inner_block($block, &$context) + public function is_customer_field($key) { } /** - * Render the Single Product block. + * Persists a field value for a given order. This would also optionally set the field value on the customer object if the order is linked to a registered customer. * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. + * @param string $key The field key. + * @param mixed $value The field value. + * @param WC_Order $order The order to persist the field for. + * @param string $group The group to persist the field for (shipping|billing|other). + * @param bool $set_customer Whether to set the field value on the customer or not. * - * @return string Rendered block type output. + * @return void */ - protected function render($attributes, $content, $block) + public function persist_field_for_order(string $key, $value, \WC_Order $order, string $group = 'other', bool $set_customer = true) { } /** - * Get the frontend script handle for this block type. + * Persists a field value for a given customer. * - * @param string $key Data to get, or default to everything. + * @param string $key The field key. + * @param mixed $value The field value. + * @param WC_Customer $customer The customer to persist the field for. + * @param string $group The group to persist the field for (shipping|billing|other). * - * @return null This block has no frontend script. + * @return void */ - protected function get_block_type_script($key = null) + public function persist_field_for_customer(string $key, $value, \WC_Customer $customer, string $group = 'other') { } - } - /** - * AttributeFilter class. - */ - class StockFilter extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock - { /** - * Block name. + * Sets a field value in an array meta, supporting routing things to billing, shipping, or additional fields, based on a prefix for the key. * - * @var string - */ - protected $block_name = 'stock-filter'; - const STOCK_STATUS_QUERY_VAR = 'filter_stock_status'; - /** - * Extra data passed through from server to client for block. + * @param string $key The field key. + * @param mixed $value The field value. + * @param WC_Customer|WC_Order $wc_object The object to set the field value for. + * @param string $group The group to set the field value for (shipping|billing|other). * - * @param array $stock_statuses Any stock statuses that currently are available from the block. - * Note, this will be empty in the editor context when the block is - * not in the post content on editor load. + * @return void */ - protected function enqueue_data(array $stock_statuses = []) + private function set_array_meta(string $key, $value, \WC_Data $wc_object, string $group) { } /** - * Get Stock status query variables values. + * Returns a field value for a given object. + * + * @param string $key The field key. + * @param WC_Customer|WC_Order $wc_object The customer or order to get the field value for. + * @param string $group The group to get the field value for (shipping|billing|other). + * + * @return mixed The field value. */ - public static function get_stock_status_query_var_values() + public function get_field_from_object(string $key, \WC_Data $wc_object, string $group = 'other') { } /** - * Get the frontend style handle for this block type. + * Returns an array of all fields values for a given object in a group. * - * @return string[] + * @param WC_Data $wc_object The object or order to get the fields for. + * @param string $group The group to get the fields for (shipping|billing|other). + * @param bool $all Whether to return all fields or only the ones that are still registered. Default false. + * @return array An array of fields. */ - protected function get_block_type_style() + public function get_all_fields_from_object(\WC_Data $wc_object, string $group = 'other', bool $all = false) { } - } - /** - * StoreNotices class. - */ - class StoreNotices extends \Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock - { - /** - * Block name. - * - * @var string - */ - protected $block_name = 'store-notices'; /** - * Render the block. - * - * @param array $attributes Block attributes. - * @param string $content Block content. - * @param WP_Block $block Block instance. + * Copies additional fields from an order to a customer. * - * @return string | void Rendered block output. + * @param WC_Order $order The order to sync the fields for. + * @param WC_Customer $customer The customer to sync the fields for. */ - protected function render($attributes, $content, $block) + public function sync_customer_additional_fields_with_order(\WC_Order $order, \WC_Customer $customer) { } /** - * Disable frontend script for this block type, it's a script module. + * Copies additional fields from a customer to an order. * - * @param string $key Data to get, or default to everything. - * @return array|string|null + * @param WC_Order $order The order to sync the fields for. + * @param WC_Customer $customer The customer to sync the fields for. */ - protected function get_block_type_script($key = null) + public function sync_order_additional_fields_with_customer(\WC_Order $order, \WC_Customer $customer) { } - } -} -namespace Automattic\WooCommerce\Blocks { - /** - * BlockTypesController class. - * - * @since 5.0.0 - * @internal - */ - final class BlockTypesController - { /** - * Instance of the asset API. + * From a set of fields, returns only the ones for a given location. * - * @var AssetApi + * @param array $fields The fields to filter. + * @param string $location The location to validate the field for (address|contact|order). + * @return array The filtered fields. */ - protected $asset_api; + public function filter_fields_for_location(array $fields, string $location) + { + } /** - * Instance of the asset data registry. + * Filter fields for order confirmation. * - * @var AssetDataRegistry + * @param array $fields The fields to filter. + * @param array $context Additional context for the filter. + * @return array The filtered fields. */ - protected $asset_data_registry; + public function filter_fields_for_order_confirmation($fields, $context = array()) + { + } /** - * Holds the registered blocks that have WooCommerce blocks as their parents. + * Get additional fields for an order. * - * @var array List of registered blocks. + * @param WC_Order $order Order object. + * @param string $location The location to get fields for (address|contact|order). + * @param string $group The group to get the field value for (shipping|billing|other). + * @param string $context The context to get the field value for (edit|view). + * @return array An array of fields definitions as well as their values formatted for display. */ - private $registered_blocks_with_woocommerce_parents; + public function get_order_additional_fields_with_values(\WC_Order $order, string $location, string $group = 'other', string $context = 'edit') + { + } /** - * Constructor. + * Formats a raw field value for display based on its type definition. * - * @param AssetApi $asset_api Instance of the asset API. - * @param AssetDataRegistry $asset_data_registry Instance of the asset data registry. + * @param string $value Value to format. + * @param array $field Additional field definition. + * @return string */ - public function __construct(\Automattic\WooCommerce\Blocks\Assets\Api $asset_api, \Automattic\WooCommerce\Blocks\Assets\AssetDataRegistry $asset_data_registry) + public function format_additional_field_value($value, $field) { } /** - * Initialize class features. + * Prepares a group name for use. + * + * @param string $group The group name to prepare. + * @return string The prepared group name. */ - protected function init() + private function prepare_group_name($group) { } /** - * Get registered blocks that have WooCommerce blocks as their parents. Adds the value to the - * `registered_blocks_with_woocommerce_parents` cache if `init` has been fired. + * Prepares a location name for use. * - * @return array Registered blocks with WooCommerce blocks as parents. + * @param string $location The location name to prepare. + * @return string The prepared location name. */ - public function get_registered_blocks_with_woocommerce_parent() + private function prepare_location_name($location) { } /** - * Register blocks, hooking up assets and render functions as needed. + * Returns a group meta prefix based on its name. + * + * @param string $group_name The group name (billing|shipping|other). + * @return string The group meta prefix. */ - public function register_blocks() + public static function get_group_key($group_name) { } /** - * Register block metadata collections for WooCommerce blocks. - * - * This method handles the registration of block metadata by using WordPress's block metadata - * collection registration system. It includes a temporary workaround for WordPress 6.7's - * strict path validation that might fail for sites using symlinked plugins. + * Returns a group name based on passed group key. * - * If the registration fails due to path validation, blocks will fall back to regular - * registration without affecting functionality. + * @param string $group_key The group name (_wc_billing|_wc_shipping|_wc_other). + * @return string The group meta prefix. */ - public function register_block_metadata() + public static function get_group_name($group_key) { } + } + /** + * Service class managing checkout fields and its related extensibility points in the admin area. + */ + class CheckoutFieldsAdmin + { /** - * Temporarily bypasses _doing_it_wrong() notices for block metadata collection registration. + * Checkout field controller. * - * WordPress 6.7 introduced block metadata collections (with strict path validation). - * Any sites using symlinks for plugins will fail the validation which causes the metadata - * collection to not be registered. However, the blocks will still fall back to the regular - * registration and no functionality is affected. - * While this validation is being discussed in WordPress Core (#62140), - * this method allows registration to proceed by temporarily disabling - * the relevant notice. + * @var CheckoutFields + */ + private $checkout_fields_controller; + /** + * Sets up core fields. * - * @param bool $trigger Whether to trigger the error. - * @param string $function The function that was called. - * @param string $message A message explaining what was done incorrectly. - * @param string $version The version of WordPress where the message was added. - * @return bool Whether to trigger the error. + * @param CheckoutFields $checkout_fields_controller Instance of the checkout field controller. */ - public static function bypass_block_metadata_doing_it_wrong($trigger, $function, $message, $version) + public function __construct(\Automattic\WooCommerce\Blocks\Domain\Services\CheckoutFields $checkout_fields_controller) { } /** - * Register block patterns + * Initialize hooks. This is not run Store API requests. */ - public function register_block_patterns() + public function init() { } /** - * Register block categories - * - * Used in combination with the `block_categories_all` filter, to append - * WooCommerce Blocks related categories to the Gutenberg editor. + * Converts the shape of a checkout field to match whats needed in the WooCommerce meta boxes. * - * @param array $categories The array of already registered categories. + * @param array $field The field to format. + * @param string $key The field key. This will be used for the ID of the field when passed to the meta box. + * @return array Formatted field. */ - public function register_block_categories($categories) + protected function format_field_for_meta_box($field, $key) { } /** - * Check if a block should have data attributes appended on render. If it's in an allowed namespace, or the block - * has explicitly been added to the allowed block list, or if one of the block's parents is in the WooCommerce - * namespace it can have data attributes. - * - * @param string $block_name Name of the block to check. + * Updates a field value for an order. * - * @return boolean + * @param string $key The field key. + * @param mixed $value The field value. + * @param \WC_Order $order The order to update the field for. */ - public function block_should_have_data_attributes($block_name) + public function update_callback($key, $value, $order) { } /** - * Add data- attributes to blocks when rendered if the block is under the woocommerce/ namespace. + * Injects address fields in WC admin orders screen. * - * @param string $content Block content. - * @param array $block Parsed block data. - * @return string + * @param array $fields The fields to show. + * @param \WC_Order|boolean $order The order to show the fields for. + * @param string $context The context to show the fields for. + * @return array */ - public function add_data_attributes($content, $block) + public function admin_address_fields($fields, $order = null, $context = 'edit') { } /** - * Adds a redirect field to the login form so blocks can redirect users after login. + * Injects contact fields in WC admin orders screen. + * + * @param array $fields The fields to show. + * @param \WC_Order|boolean $order The order to show the fields for. + * @param string $context The context to show the fields for. + * @return array */ - public function redirect_to_field() + public function admin_contact_fields($fields, $order = null, $context = 'edit') { } /** - * Hide legacy widgets with a feature complete block equivalent in the inserter - * and prevent them from showing as an option in the Legacy Widget block. + * Injects additional fields in WC admin orders screen. * - * @param array $widget_types An array of widgets hidden in core. - * @return array $widget_types An array including the WooCommerce widgets to hide. + * @param array $fields The fields to show. + * @param \WC_Order|boolean $order The order to show the fields for. + * @param string $context The context to show the fields for. + * @return array */ - public function hide_legacy_widgets_with_block_equivalent($widget_types) + public function admin_order_fields($fields, $order = null, $context = 'edit') { } + } + /** + * Service class managing checkout fields and its related extensibility points on the frontend. + */ + class CheckoutFieldsFrontend + { /** - * Delete product transients when a product is deleted. + * Checkout field controller. + * + * @var CheckoutFields */ - public function delete_product_transients() + private $checkout_fields_controller; + /** + * Sets up core fields. + * + * @param CheckoutFields $checkout_fields_controller Instance of the checkout field controller. + */ + public function __construct(\Automattic\WooCommerce\Blocks\Domain\Services\CheckoutFields $checkout_fields_controller) { } /** - * Get list of block types allowed in Widget Areas. New blocks won't be - * exposed in the Widget Area unless specifically added here. - * - * @return array Array of block types. + * Initialize hooks. This is not run Store API requests. */ - protected function get_widget_area_block_types() + public function init() { } /** - * Get list of block types. + * Render custom fields. * - * @return array + * @param array $fields List of additional fields with values. + * @return string */ - protected function get_block_types() + protected function render_additional_fields($fields) { } /** - * By default, when the classic theme is used, block style is always - * enqueued even if the block is not used on the page. We want WooCommerce - * store to always performant so we have to manually enqueue the block style - * on-demand for classic themes. - * - * @internal - * - * @param array $args Block metadata. - * @param string $block_name Block name. + * Render custom field. * - * @return array Block metadata. + * @param array $field An additional field and value. + * @return string */ - public function enqueue_block_style_for_classic_themes($args, $block_name) + protected function render_additional_field($field) { } - } -} -namespace Automattic\WooCommerce\Blocks\Domain { - /** - * Takes care of bootstrapping the plugin. - * - * @since 2.5.0 - */ - class Bootstrap - { /** - * Holds the Dependency Injection Container + * Renders address fields on the order details page. * - * @var Container + * @param string $address_type Type of address (billing or shipping). + * @param WC_Order $order Order object. */ - private $container; + public function render_order_address_fields($address_type, $order) + { + } /** - * Holds the Package instance + * Renders additional fields on the order details page. * - * @var Package + * @param WC_Order $order Order object. */ - private $package; + public function render_order_other_fields($order) + { + } /** - * Constructor + * Renders address fields on the account page. * - * @param Container $container The Dependency Injection Container. + * @param string $address_type Type of address (billing or shipping). */ - public function __construct(\Automattic\WooCommerce\Blocks\Registry\Container $container) + public function render_address_fields($address_type) { } /** - * Init the package - load the blocks library and define constants. + * Adds additional contact fields to the My Account edit account form. */ - protected function init() + public function edit_account_form_fields() { } /** - * See if files have been built or not. + * Adds additional address fields to the My Account edit address form. * - * @return bool + * @param array $address Address fields. + * @param string $address_type Type of address (billing or shipping). + * @return array Updated address fields. */ - protected function is_built() + public function edit_address_fields($address, $address_type) { } /** - * Add a notice stating that the build has not been done yet. + * Validates and saves additional address fields to the customer object on the My Account page. + * + * Customer is not provided by this hook so we handle save here. + * + * @param integer $user_id User ID. */ - protected function add_build_notice() + public function save_account_form_fields($user_id) { } /** - * Register core dependencies with the container. + * For the My Account page, save address fields. This uses the Store API endpoint for saving addresses so + * extensibility hooks are consistent across the codebase. + * + * The caller saves the customer object if there are no errors. Nonces are checked before this method executes. + * + * @param integer $user_id User ID. + * @param string $address_type Type of address (billing or shipping). + * @param array $address Address fields. + * @param WC_Customer $customer Customer object. */ - protected function register_dependencies() + public function save_address_fields($user_id, $address_type, $address = [], $customer = null) { } /** - * Throws a deprecation notice for a dependency without breaking requests. + * Get posted additional field values. * - * @param string $function Class or function being deprecated. - * @param string $version Version in which it was deprecated. - * @param string $replacement Replacement class or function, if applicable. - * @param string $trigger_error_version Optional version to start surfacing this as a PHP error rather than a log. Defaults to $version. + * @param string $location The location to get fields for. + * @param string $group The group to get fields for. + * @param boolean $sanitize Whether to sanitize the field values. + * @return array The posted field values and sanitized field values. */ - protected function deprecated_dependency($function, $version, $replacement = '', $trigger_error_version = '') + protected function get_posted_additional_field_values($location, $group, $sanitize = true) { } /** - * Register payment method integrations with the container. + * Validate and save additional fields for a given customer. + * + * @param WC_Customer $customer Customer object. + * @param string $location Location to save fields for. + * @param string $group Group to save fields for. + * @return true|\WP_Error True if successful, \WP_Error if there are errors. */ - protected function register_payment_methods() + protected function update_additional_fields_for_customer($customer, $location, $group) { } } +} +namespace Automattic\WooCommerce\Blocks\Domain\Services\CheckoutFieldsSchema { /** - * Main package class. - * - * Returns information about the package and handles init. + * DocumentObject class. * - * @since 2.5.0 + * This will combine and format given cart/customer/checkout data into a standard object format that can be queried through + * JSON. This is used for conditional fields and validation during checkout. */ - class Package + class DocumentObject { /** - * Holds the current version of the blocks plugin. + * Docuemnt object context which may adjust the schema response. * - * @var string + * @var null|string */ - private $version; + protected $context = null; /** - * Holds the main path to the blocks plugin directory. + * Valid contexts. * - * @var string + * @var array */ - private $path; + protected $valid_contexts = ['shipping_address', 'billing_address', 'contact', 'order']; /** - * Holds locally the plugin_dir_url to avoid recomputing it. + * The cart object. * - * @var string + * @var WC_Cart|null */ - private $plugin_dir_url; + protected $cart = null; /** - * Holds the feature gating class instance. + * The customer object. * - * @var FeatureGating + * @var WC_Customer|null */ - private $feature_gating; + protected $customer = null; /** - * Constructor + * Cart controller class instance. * - * @param string $version Version of the plugin. - * @param string $plugin_path Path to the main plugin file. - * @param FeatureGating $deprecated Deprecated Feature gating class. + * @var CartController */ - public function __construct($version, $plugin_path, $deprecated = null) - { - } + protected $cart_controller; /** - * Returns the version of WooCommerce Blocks. + * Schema controller class instance. * - * Note: since Blocks was merged into WooCommerce Core, the version of - * WC Blocks doesn't update anymore. Use - * `Constants::get_constant( 'WC_VERSION' )` when possible to get the - * WooCommerce Core version. + * @var SchemaController + */ + protected $schema_controller; + /** + * The request data. * - * @return string + * @var array */ - public function get_version() - { - } + protected $request_data = []; /** - * Returns the version of WooCommerce Blocks stored in the database. + * The constructor. * - * @return string + * @param array $request_data Data that overrides the default values. */ - public function get_version_stored_on_db() + public function __construct(array $request_data = []) { } /** - * Sets the version of WooCommerce Blocks in the database. - * This is useful during the first installation or after the upgrade process. + * Set document object context. + * + * @param null|string $context Context to set. */ - public function set_version_stored_on_db() + public function set_context($context = null) { } /** - * Returns the path to the plugin directory. - * - * @param string $relative_path If provided, the relative path will be - * appended to the plugin path. + * Set the customer object. * - * @return string + * @param WC_Customer $customer The customer object. */ - public function get_path($relative_path = '') + public function set_customer(\WC_Customer $customer) { } /** - * Returns the url to the blocks plugin directory. - * - * @param string $relative_url If provided, the relative url will be - * appended to the plugin url. + * Set the cart object. * - * @return string + * @param WC_Cart $cart The cart object. */ - public function get_url($relative_url = '') + public function set_cart(\WC_Cart $cart) { } /** - * Returns an instance of the FeatureGating class. + * Gets a subset of cart data. * - * @return FeatureGating + * @return array The cart data. */ - public function feature() + protected function get_cart_data() { } - } -} -namespace Automattic\WooCommerce\Blocks\Domain\Services { - /** - * Service class managing checkout fields and its related extensibility points. - */ - class CheckoutFields - { /** - * Additional checkout fields. + * Get checkout data. * - * @var array + * @return array Checkout data context. */ - private $additional_fields = []; + protected function get_checkout_data() + { + } /** - * Fields locations. + * Get the customer data. * - * @var array + * @return array The customer data. */ - private $fields_locations; + protected function get_customer_data() + { + } /** - * Supported field types + * Get the data for the document object. * - * @var array + * This isn't a 1:1 match with Store API because some data is simplified to make it easier to parse as JSON. + * + * @return array The data for the document object. */ - private $supported_field_types = ['text', 'select', 'checkbox']; + public function get_data() + { + } /** - * Groups of fields to be saved. + * Get the current context. * - * @var array + * @return null|string The context. */ - private $groups = ['billing', 'shipping', 'other']; + public function get_context() + { + } + } + /** + * Service class validating checkout field schema. + */ + class Validation + { /** - * Instance of the asset data registry. + * Meta schema. * - * @var AssetDataRegistry + * @var string */ - private $asset_data_registry; + private static $meta_schema_json = ''; /** - * Billing fields meta key. + * Get the field schema with context. * - * @var string + * @param string $field_id The field ID. + * @param array $field_schema The field schema. + * @param string $context The context. + * @return array */ - const BILLING_FIELDS_PREFIX = '_wc_billing/'; + public static function get_field_schema_with_context($field_id, $field_schema, $context) + { + } /** - * Shipping fields meta key. + * Check if the schema is unwrapped (has cart, checkout, customer, as top level keys). * - * @var string + * @param array $schema The schema to check. + * @return bool */ - const SHIPPING_FIELDS_PREFIX = '_wc_shipping/'; + private static function schema_is_unwrapped($schema) + { + } /** - * Additional fields meta key. + * Validate the field rules. * - * @var string - * @deprecated 8.9.0 Use OTHER_FIELDS_PREFIX instead. + * @param DocumentObject $document_object The document object to validate. + * @param array $rules The rules to validate against. + * @return bool|WP_Error */ - const ADDITIONAL_FIELDS_PREFIX = '_wc_additional/'; + public static function validate_document_object(\Automattic\WooCommerce\Blocks\Domain\Services\CheckoutFieldsSchema\DocumentObject $document_object, $rules) + { + } /** - * Other fields meta key. + * Check if the fields have defined schema. * - * @var string + * @param array $fields The fields. + * @return bool */ - const OTHER_FIELDS_PREFIX = '_wc_other/'; + public static function has_field_schema($fields) + { + } /** - * Sets up core fields. + * Validate meta schema for field rules. * - * @param AssetDataRegistry $asset_data_registry Instance of the asset data registry. + * @param mixed $rules The rules to validate. + * @return bool|WP_Error True if the field options are valid, a WP_Error otherwise. */ - public function __construct(\Automattic\WooCommerce\Blocks\Assets\AssetDataRegistry $asset_data_registry) + public static function is_valid_schema($rules) { } + } +} +namespace Automattic\WooCommerce\Blocks\Domain\Services { + /** + * Checkout Link class. + */ + class CheckoutLink + { /** - * Initialize hooks. + * Initialize the checkout link service. */ public function init() { } /** - * Add fields data to the asset data registry. + * Add the checkout link endpoint. */ - public function add_fields_data() + public function add_checkout_link_endpoint() { } /** - * Add session meta keys. - * - * This is an allow-list of meta data keys which we want to store in session. + * Add the checkout link query var. * - * @param array $keys Session meta keys. - * @return array + * @param array $vars The query vars. + * @return array The query vars. */ - public function add_session_meta_keys($keys) + public function add_query_vars($vars) { } /** - * If a field does not declare a sanitization callback, this is the default sanitization callback. + * Handle the checkout link endpoint. * - * @param mixed $value Value to sanitize. - * @param array $field Field data. - * @return mixed + * @return void */ - public function default_sanitize_callback($value, $field) + public function handle_checkout_link_endpoint() { } /** - * If a field does not declare a validation callback, this is the default validation callback. + * Validate the checkout link. * - * @param mixed $value Value to sanitize. - * @param array $field Field data. - * @return WP_Error|void If there is a validation error, return an WP_Error object. + * @return bool True if the checkout link is valid, false otherwise. */ - public function default_validate_callback($value, $field) + protected function validate_checkout_link() { } /** - * Registers an additional field for Checkout. - * - * @param array $options The field options. + * Get the products from the checkout link. * - * @return WP_Error|void True if the field was registered, a WP_Error otherwise. + * @return array The products (keys) and their quantities (values). */ - public function register_checkout_field($options) + protected function get_products_from_checkout_link() { } /** - * Returns true if the field is required. Takes rules into consideration if a document object is provided. + * Add error notices to the cart. * - * @param array|string $field The field array or field key. - * @param DocumentObject|null $document_object The document object. - * @return bool + * @param \WP_Error $errors The errors. + * @return void */ - public function is_required_field($field, $document_object = null) + protected function add_error_notices(\WP_Error $errors) { } /** - * Returns true if the field is hidden. Takes rules into consideration if a document object is provided. + * Process the query params and return the checkout link to redirect to complete with session token. * - * @param array|string $field The field array or field key. - * @param DocumentObject|null $document_object The document object. - * @return bool + * @return string The checkout link. */ - public function is_hidden_field($field, $document_object = null) + protected function get_checkout_link() { } + } + /** + * Service class implementing new create account emails used for order processing via the Block Based Checkout. + * + * @deprecated This class can't be removed due to https://github.com/woocommerce/woocommerce/issues/52311. + */ + class CreateAccount + { /** - * Returns true if the field is conditionally required or rendered. + * Reference to the Package instance * - * @param array|string $field The field array or field key. - * @return bool + * @var Package */ - public function is_conditional_field($field) - { - } + private $package; /** - * Validates a field against the given document object and context. + * Constructor. * - * @param array $field The field. - * @param DocumentObject|null $document_object The document object. - * @return bool|\WP_Error True if the field is valid, a WP_Error otherwise. + * @param Package $package An instance of (Woo Blocks) Package. */ - public function is_valid_field($field, $document_object = null) + public function __construct(\Automattic\WooCommerce\Blocks\Domain\Package $package) { } /** - * Returns true if the property is an array and not empty. - * - * @param mixed $property The property to check. - * @return bool + * Init - register handlers for WooCommerce core email hooks. */ - protected function contains_valid_rules($property) + public function init() { } /** - * Returns the validate callback for a given field. + * Trigger new account email. * - * @param array $field The field. - * @param DocumentObject|null $document_object The document object. - * @return callable The validate callback. + * @param int $customer_id The ID of the new customer account. + * @param array $new_customer_data Assoc array of data for the new account. */ - public function get_validate_callback($field, $document_object = null) + public function customer_new_account($customer_id = 0, array $new_customer_data = array()) { } + } + /** + * Service class for adding DraftOrder functionality to WooCommerce core. + * + * Sets up all logic related to the Checkout Draft Orders service + * + * @internal + */ + class DraftOrders + { + const DB_STATUS = 'wc-checkout-draft'; + const STATUS = 'checkout-draft'; + const DRAFT_CLEANUP_EVENT_HOOK = 'woocommerce_cleanup_draft_orders'; /** - * Deregister a checkout field. + * Holds the Package instance * - * @param string $field_id The field ID. + * @var Package + */ + private $package; + /** + * Constructor * - * @internal + * @param Package $package An instance of the package class. */ - public function deregister_checkout_field($field_id) + public function __construct(\Automattic\WooCommerce\Blocks\Domain\Package $package) { } /** - * Validates the "base" options (id, label, location) and shows warnings if they're not supplied. - * - * @param array $options The options supplied during field registration. - * @return bool false if an error was encountered, true otherwise. + * Set all hooks related to adding Checkout Draft order functionality to Woo Core. */ - private function validate_options(&$options) + public function init() { } /** - * Processes the options for a field type and returns the new field_options array. + * Installation related logic for Draft order functionality. * - * @param array $field_data The field data array to be updated. - * @param array $options The options supplied during field registration. - * @return array The updated $field_data array. + * @internal */ - private function process_field_options($field_data, $options) + public function install() { } /** - * Processes the options for a select field and returns the new field_options array. - * - * @param array $field_data The field data array to be updated. - * @param array $options The options supplied during field registration. + * Unschedule recurring actions when plugin is deactivated. * - * @return array|false The updated $field_data array or false if an error was encountered. + * @since 10.0.0 + * @internal */ - private function process_select_field($field_data, $options) + public function unschedule_cronjobs() { } /** - * Processes the options for a checkbox field and returns the new field_options array. - * - * @param array $field_data The field data array to be updated. - * @param array $options The options supplied during field registration. - * - * @return array|false The updated $field_data array or false if an error was encountered. + * Maybe create cron events. */ - private function process_checkbox_field($field_data, $options) + protected function maybe_create_cronjobs() { } /** - * Processes the attributes supplied during field registration. + * Register custom order status for orders created via the API during checkout. * - * @param array $id The field ID. - * @param array $attributes The attributes supplied during field registration. + * Draft order status is used before payment is attempted, during checkout, when a cart is converted to an order. * - * @return array The processed attributes. + * @param array $statuses Array of statuses. + * @internal + * @return array */ - private function register_field_attributes($id, $attributes) + public function register_draft_order_status(array $statuses) { } /** - * Returns the keys of all core fields. + * Register custom order post status for orders created via the API during checkout. * - * @return array An array of field keys. + * @param array $statuses Array of statuses. + * @internal + * @return array */ - public function get_core_fields_keys() + public function register_draft_order_post_status(array $statuses) { } /** - * Returns an array of all core fields. + * Returns the properties of this post status for registration. * - * @return array An array of fields. + * @return array */ - public function get_core_fields() + private function get_post_status_properties() { } /** - * Returns an array of all additional fields. + * Remove draft status from the 'status' argument of an $args array. * - * @return array An array of fields. + * @param array $args Array of arguments containing statuses in the status key. + * @internal + * @return array */ - public function get_additional_fields() + public function delete_draft_order_post_status_from_args($args) { } /** - * Gets the location of a field. + * Append draft status to a list of statuses. * - * @param string $field_key The key of the field to get the location for. - * @return string The location of the field. + * @param array $statuses Array of statuses. + * @internal + * @return array */ - public function get_field_location($field_key) + public function append_draft_order_post_status($statuses) { } /** - * Sanitize an additional field against any custom sanitization rules. + * Delete draft orders older than a day in batches of 20. * - * @since 8.7.0 - * @param string $field_key The key of the field. - * @param mixed $field_value The value of the field. - * @return mixed + * Ran on a daily cron schedule. + * + * @internal */ - public function sanitize_field($field_key, $field_value) + public function delete_expired_draft_orders() { } /** - * Validate an additional field. - * - * @since 8.6.0 - * - * @param array $field The field. - * @param mixed $field_value The value of the field. - * @return WP_Error + * Since it's possible for third party code to clobber the `$wp_post_statuses` global, + * we need to do a final check here to make sure the draft post status is + * registered with the global so that it is not removed by WP_Query status + * validation checks. */ - public function validate_field($field, $field_value) + private function ensure_draft_status_registered() { } /** - * Update the default locale with additional fields without country limitations. + * Asserts whether incoming order results are expected given the query + * this service class executes. * - * @param array $locale The locale to update. - * @return mixed + * @param WC_Order[] $order_results The order results being asserted. + * @param int $expected_batch_size The expected batch size for the results. + * @throws Exception If any assertions fail, an exception is thrown. */ - public function update_default_locale_with_fields($locale) + private function assert_order_results($order_results, $expected_batch_size) { } + } +} +namespace Automattic\WooCommerce\Blocks\Domain\Services\Email { + /** + * Customer New Account. Previously used for blocks, but now replaced by the core email. + * + * @deprecated This class can't be removed due to https://github.com/woocommerce/woocommerce/issues/52311. + */ + class CustomerNewAccount extends \WC_Email + { /** - * Returns an array of fields keys for the address location. + * Constructor. * - * @return array An array of fields keys. + * @param Package $package An instance of (Woo Blocks) Package. */ - public function get_address_fields_keys() + public function __construct(\Automattic\WooCommerce\Blocks\Domain\Package $package) { } + } +} +namespace Automattic\WooCommerce\Blocks\Domain\Services { + /** + * Service class that used to handle feature flags. That functionality + * is removed now and it is only used to determine "environment". + * + * @internal + * + * @deprecated since 9.6.0, use wp_get_environment_type() instead. + */ + class FeatureGating extends \Automattic\WooCommerce\Admin\DeprecatedClassFacade + { /** - * Returns an array of fields keys for the contact location. + * The version that this class was deprecated in. * - * @return array An array of fields keys. + * @var string */ - public function get_contact_fields_keys() - { - } + protected static $deprecated_in_version = '9.6.0'; /** - * Returns an array of fields keys for the additional area location. + * Constructor * - * @return array An array of fields keys. - * @deprecated 8.9.0 Use get_order_fields_keys instead. + * @param string $environment Hardcoded environment value. Useful for tests. */ - public function get_additional_fields_keys() + public function __construct($environment = 'unset') { } + } + /** + * Service class to integrate Blocks with the Google Analytics extension, + */ + class GoogleAnalytics + { /** - * Returns an array of fields keys for the additional area group. + * Instance of the asset API. * - * @return array An array of fields keys. + * @var AssetApi */ - public function get_order_fields_keys() - { - } + protected $asset_api; /** - * Returns an array of fields for a given location. + * Constructor. * - * @param string $location The location to get fields for (address|contact|order). - * @return array An array of fields definitions. + * @param AssetApi $asset_api Instance of the asset API. */ - public function get_fields_for_location($location) + public function __construct(\Automattic\WooCommerce\Blocks\Assets\Api $asset_api) { } /** - * Returns an array of fields for a given location and uses context to evaluate hidden and required fields. - * - * @param string $location The location to get fields for (address|contact|order). - * @param DocumentObject|null $document_object The document object. - * @return array An array of fields definitions. + * Hook into WP. */ - public function get_contextual_fields_for_location($location, $document_object = null) + public function init() { } /** - * Validates a set of fields for a given location against custom validation rules. - * - * @param array $fields Array of key value pairs of field values to validate. - * @param string $location The location being validated (address|contact|order). - * @param string $group The group to get the field value for (shipping|billing|other). - * @return WP_Error + * Register scripts. */ - public function validate_fields_for_location($fields, $location, $group = 'other') + public function register_assets() { } /** - * Validates a field to check it belongs to the given location and is valid according to its registration. - * - * This does not apply any custom validation rules on the value. - * - * @param string $key The field key. - * @param mixed $value The field value. - * @param string $location The location to validate the field for (address|contact|order). - * - * @return true|WP_Error True if the field is valid, a WP_Error otherwise. + * Enqueue the Google Tag Manager script if prerequisites are met. */ - public function validate_field_for_location($key, $value, $location) + public function enqueue_scripts() { } /** - * Returns all fields key for a given group. - * - * @param string $group The group to get the key for (shipping|billing|other). + * Get settings from the GA integration extension. * - * @return string[] Field keys. + * @return array */ - public function get_fields_for_group($group = 'other') + private function get_google_analytics_settings() { } /** - * Returns true if the given key is a valid field. - * - * @param string $key The field key. + * Add async to script tags with defined handles. * - * @return bool True if the field is valid, false otherwise. + * @param string $tag HTML for the script tag. + * @param string $handle Handle of script. + * @param string $src Src of script. + * @return string */ - public function is_field($key) + public function async_script_loader_tags($tag, $handle, $src) { } + } + /** + * Service class that handles hydration of API data for blocks. + */ + class Hydration + { /** - * Returns true if the given key is a valid customer field. + * Instance of the asset data registry. * - * Customer fields are fields saved to the customer data, like address and contact fields. + * @var AssetDataRegistry + */ + protected $asset_data_registry; + /** + * Cached notices to restore after hydrating the API. * - * @param string $key The field key. + * @var array + */ + protected $cached_store_notices = array(); + /** + * Constructor. * - * @return bool True if the field is valid, false otherwise. + * @param AssetDataRegistry $asset_data_registry Instance of the asset data registry. */ - public function is_customer_field($key) + public function __construct(\Automattic\WooCommerce\Blocks\Assets\AssetDataRegistry $asset_data_registry) { } /** - * Persists a field value for a given order. This would also optionally set the field value on the customer object if the order is linked to a registered customer. - * - * @param string $key The field key. - * @param mixed $value The field value. - * @param WC_Order $order The order to persist the field for. - * @param string $group The group to persist the field for (shipping|billing|other). - * @param bool $set_customer Whether to set the field value on the customer or not. + * Hydrates the asset data registry with data from the API. Disables notices and nonces so requests contain valid + * data that is not polluted by the current session. * - * @return void + * @param array $path API paths to hydrate e.g. '/wc/store/v1/cart'. + * @return array Response data. */ - public function persist_field_for_order(string $key, $value, \WC_Order $order, string $group = 'other', bool $set_customer = true) + public function get_rest_api_response_data($path = '') { } /** - * Persists a field value for a given customer. + * Helper method to generate GET response from a controller. Also fires the `rest_request_after_callbacks` for backward compatibility. * - * @param string $key The field key. - * @param mixed $value The field value. - * @param WC_Customer $customer The customer to persist the field for. - * @param string $group The group to persist the field for (shipping|billing|other). + * @param string $controller_class Controller class FQN that will respond to the request. + * @param string $path Request path regex. * - * @return void + * @return false|mixed|null Response */ - public function persist_field_for_customer(string $key, $value, \WC_Customer $customer, string $group = 'other') + private function get_response_from_controller($controller_class, $path) { } /** - * Sets a field value in an array meta, supporting routing things to billing, shipping, or additional fields, based on a prefix for the key. + * Inspired from WP core's `match_request_to_handler`, this matches a given path from available route regexes. + * However, unlike WP core, this does not check against query params, request method etc. * - * @param string $key The field key. - * @param mixed $value The field value. - * @param WC_Customer|WC_Order $wc_object The object to set the field value for. - * @param string $group The group to set the field value for (shipping|billing|other). + * @param string $path The path to match. + * @param array $available_routes Available routes in { $regex1 => $contoller_class1, ... } format. * - * @return void + * @return string|null */ - private function set_array_meta(string $key, $value, \WC_Data $wc_object, string $group) + private function match_route_to_handler($path, $available_routes) { } /** - * Returns a field value for a given object. - * - * @param string $key The field key. - * @param WC_Customer|WC_Order $wc_object The customer or order to get the field value for. - * @param string $group The group to get the field value for (shipping|billing|other). - * - * @return mixed The field value. + * Disable the nonce check temporarily. */ - public function get_field_from_object(string $key, \WC_Data $wc_object, string $group = 'other') + protected function disable_nonce_check() { } /** - * Returns an array of all fields values for a given object in a group. - * - * @param WC_Data $wc_object The object or order to get the fields for. - * @param string $group The group to get the fields for (shipping|billing|other). - * @param bool $all Whether to return all fields or only the ones that are still registered. Default false. - * @return array An array of fields. + * Callback to disable the nonce check. While we could use `__return_true`, we use a custom named callback so that + * we can remove it later without affecting other filters. */ - public function get_all_fields_from_object(\WC_Data $wc_object, string $group = 'other', bool $all = false) + public function disable_nonce_check_callback() { } /** - * Copies additional fields from an order to a customer. - * - * @param WC_Order $order The order to sync the fields for. - * @param WC_Customer $customer The customer to sync the fields for. + * Restore the nonce check. */ - public function sync_customer_additional_fields_with_order(\WC_Order $order, \WC_Customer $customer) + protected function restore_nonce_check() { } /** - * Copies additional fields from a customer to an order. - * - * @param WC_Order $order The order to sync the fields for. - * @param WC_Customer $customer The customer to sync the fields for. + * Cache notices before hydrating the API if the customer has a session. */ - public function sync_order_additional_fields_with_customer(\WC_Order $order, \WC_Customer $customer) + protected function cache_store_notices() { } /** - * From a set of fields, returns only the ones for a given location. - * - * @param array $fields The fields to filter. - * @param string $location The location to validate the field for (address|contact|order). - * @return array The filtered fields. + * Restore notices into current session from cache. */ - public function filter_fields_for_location(array $fields, string $location) + protected function restore_cached_store_notices() { } + } + /** + * Service class for adding new-style Notices to WooCommerce core. + * + * @internal + */ + class Notices + { /** - * Filter fields for order confirmation. + * Holds the Package instance * - * @param array $fields The fields to filter. - * @param array $context Additional context for the filter. - * @return array The filtered fields. + * @var Package */ - public function filter_fields_for_order_confirmation($fields, $context = array()) - { - } + private $package; /** - * Get additional fields for an order. + * Templates used for notices. * - * @param WC_Order $order Order object. - * @param string $location The location to get fields for (address|contact|order). - * @param string $group The group to get the field value for (shipping|billing|other). - * @param string $context The context to get the field value for (edit|view). - * @return array An array of fields definitions as well as their values formatted for display. + * @var array */ - public function get_order_additional_fields_with_values(\WC_Order $order, string $location, string $group = 'other', string $context = 'edit') - { - } + private $notice_templates = array('notices/error.php', 'notices/notice.php', 'notices/success.php'); /** - * Formats a raw field value for display based on its type definition. + * Constructor * - * @param string $value Value to format. - * @param array $field Additional field definition. - * @return string + * @param Package $package An instance of the package class. */ - public function format_additional_field_value($value, $field) + public function __construct(\Automattic\WooCommerce\Blocks\Domain\Package $package) { } /** - * Prepares a group name for use. - * - * @param string $group The group name to prepare. - * @return string The prepared group name. + * Initialize notice hooks. */ - private function prepare_group_name($group) + public function init() { } /** - * Prepares a location name for use. + * Allow SVG icon in notices. * - * @param string $location The location name to prepare. - * @return string The prepared location name. + * @param array $allowed_tags Allowed tags. + * @return array */ - private function prepare_location_name($location) + public function add_kses_notice_allowed_tags($allowed_tags) { } /** - * Returns a group meta prefix based on its name. + * Replaces core notice templates with those from blocks. * - * @param string $group_name The group name (billing|shipping|other). - * @return string The group meta prefix. + * The new notice templates match block components with matching icons and styling. The differences are: + * 1. Core has notices for info, success, and error notices, blocks has notices for info, success, error, + * warning, and a default notice type. + * 2. The block notices use different CSS classes to the core notices. Core uses `woocommerce-message`, `is-info` + * and `is-error` classes, blocks uses `wc-block-components-notice-banner is-error`, + * `wc-block-components-notice-banner is-info`, and `wc-block-components-notice-banner is-success`. + * 3. The markup of the notices is different, with the block notices using SVG icons and a slightly different + * structure to accommodate this. + * + * @param string $template Located template path. + * @param string $template_name Template name. + * @param array $args Template arguments. + * @param string $template_path Template path. + * @param string $default_path Default path. + * @return string */ - public static function get_group_key($group_name) + public function get_notices_template($template, $template_name, $args, $template_path, $default_path) { } /** - * Returns a group name based on passed group key. + * Replaces all notices with the new block-based notices. * - * @param string $group_key The group name (_wc_billing|_wc_shipping|_wc_other). - * @return string The group meta prefix. + * @return void */ - public static function get_group_name($group_key) + public function enqueue_notice_styles() { } } +} +namespace Automattic\WooCommerce\Blocks\Images { /** - * Service class managing checkout fields and its related extensibility points in the admin area. + * Pexels API client. + * + * @internal + * @deprecated This class can't be removed due https://github.com/woocommerce/woocommerce/issues/52311. */ - class CheckoutFieldsAdmin + class Pexels { + } +} +namespace Automattic\WooCommerce\Blocks { + /** + * A class used to display inbox messages to merchants in the WooCommerce Admin dashboard. + * + * @package Automattic\WooCommerce\Blocks + * @since x.x.x + */ + class InboxNotifications + { + const SURFACE_CART_CHECKOUT_NOTE_NAME = 'surface_cart_checkout'; /** - * Checkout field controller. - * - * @var CheckoutFields - */ - private $checkout_fields_controller; - /** - * Sets up core fields. - * - * @param CheckoutFields $checkout_fields_controller Instance of the checkout field controller. + * Deletes the note. */ - public function __construct(\Automattic\WooCommerce\Blocks\Domain\Services\CheckoutFields $checkout_fields_controller) + public static function delete_surface_cart_checkout_blocks_notification() { } + } + /** + * Installer class. + * Handles installation of Blocks plugin dependencies. + * + * @internal + */ + class Installer + { /** - * Initialize hooks. This is not run Store API requests. + * Initialize class features. */ public function init() { } /** - * Converts the shape of a checkout field to match whats needed in the WooCommerce meta boxes. - * - * @param array $field The field to format. - * @param string $key The field key. This will be used for the ID of the field when passed to the meta box. - * @return array Formatted field. + * Installation tasks ran on admin_init callback. */ - protected function format_field_for_meta_box($field, $key) + public function install() { } /** - * Updates a field value for an order. + * Modifies default page content replacing it with classic shortcode block. + * We check for shortcode as default because after WooCommerce 8.3, block-based checkout is used by default. + * This only runs on Tools > Create Pages as the filter is not applied on WooCommerce plugin activation. * - * @param string $key The field key. - * @param mixed $value The field value. - * @param \WC_Order $order The order to update the field for. + * @param array $pages Default pages. + * @return array */ - public function update_callback($key, $value, $order) + public function create_pages($pages) { } /** - * Injects address fields in WC admin orders screen. - * - * @param array $fields The fields to show. - * @param \WC_Order|boolean $order The order to show the fields for. - * @param string $context The context to show the fields for. - * @return array + * Set up the database tables which the plugin needs to function. */ - public function admin_address_fields($fields, $order = null, $context = 'edit') + public function maybe_create_tables() { } /** - * Injects contact fields in WC admin orders screen. + * Create database table, if it doesn't already exist. * - * @param array $fields The fields to show. - * @param \WC_Order|boolean $order The order to show the fields for. - * @param string $context The context to show the fields for. - * @return array + * Based on admin/install-helper.php maybe_create_table function. + * + * @param string $table_name Database table name. + * @param string $create_sql Create database table SQL. + * @return bool False on error, true if already exists or success. */ - public function admin_contact_fields($fields, $order = null, $context = 'edit') + protected function maybe_create_table($table_name, $create_sql) { } /** - * Injects additional fields in WC admin orders screen. + * Add a notice if table creation fails. * - * @param array $fields The fields to show. - * @param \WC_Order|boolean $order The order to show the fields for. - * @param string $context The context to show the fields for. - * @return array + * @param string $table_name Name of the missing table. */ - public function admin_order_fields($fields, $order = null, $context = 'edit') + protected function add_create_table_notice($table_name) { } } +} +namespace Automattic\WooCommerce\Blocks\Integrations { /** - * Service class managing checkout fields and its related extensibility points on the frontend. + * Integration.Interface + * + * Integrations must use this interface when registering themselves with blocks, */ - class CheckoutFieldsFrontend + interface IntegrationInterface { /** - * Checkout field controller. + * The name of the integration. * - * @var CheckoutFields + * @return string */ - private $checkout_fields_controller; + public function get_name(); /** - * Sets up core fields. + * When called invokes any initialization/setup for the integration. + */ + public function initialize(); + /** + * Returns an array of script handles to enqueue in the frontend context. * - * @param CheckoutFields $checkout_fields_controller Instance of the checkout field controller. + * @return string[] */ - public function __construct(\Automattic\WooCommerce\Blocks\Domain\Services\CheckoutFields $checkout_fields_controller) - { - } + public function get_script_handles(); /** - * Initialize hooks. This is not run Store API requests. + * Returns an array of script handles to enqueue in the editor context. + * + * @return string[] */ - public function init() - { - } + public function get_editor_script_handles(); /** - * Render custom fields. + * An array of key, value pairs of data made available to the block on the client side. * - * @param array $fields List of additional fields with values. - * @return string + * @return array */ - protected function render_additional_fields($fields) - { - } + public function get_script_data(); + } + /** + * Class used for tracking registered integrations with various Block types. + */ + class IntegrationRegistry + { /** - * Render custom field. + * Integration identifier is used to construct hook names and is given when the integration registry is initialized. * - * @param array $field An additional field and value. - * @return string + * @var string */ - protected function render_additional_field($field) - { - } + protected $registry_identifier = ''; /** - * Renders address fields on the order details page. + * Registered integrations, as `$name => $instance` pairs. * - * @param string $address_type Type of address (billing or shipping). - * @param WC_Order $order Order object. + * @var IntegrationInterface[] */ - public function render_order_address_fields($address_type, $order) + protected $registered_integrations = []; + /** + * Initializes all registered integrations. + * + * Integration identifier is used to construct hook names and is given when the integration registry is initialized. + * + * @param string $registry_identifier Identifier for this registry. + */ + public function initialize($registry_identifier = '') { } /** - * Renders additional fields on the order details page. + * Registers an integration. * - * @param WC_Order $order Order object. + * @param IntegrationInterface $integration An instance of IntegrationInterface. + * + * @return boolean True means registered successfully. */ - public function render_order_other_fields($order) + public function register(\Automattic\WooCommerce\Blocks\Integrations\IntegrationInterface $integration) { } /** - * Renders address fields on the account page. + * Checks if an integration is already registered. * - * @param string $address_type Type of address (billing or shipping). + * @param string $name Integration name. + * @return bool True if the integration is registered, false otherwise. */ - public function render_address_fields($address_type) + public function is_registered($name) { } /** - * Adds additional contact fields to the My Account edit account form. + * Un-register an integration. + * + * @param string|IntegrationInterface $name Integration name, or alternatively a IntegrationInterface instance. + * @return boolean|IntegrationInterface Returns the unregistered integration instance if unregistered successfully. */ - public function edit_account_form_fields() + public function unregister($name) { } /** - * Adds additional address fields to the My Account edit address form. + * Retrieves a registered Integration by name. * - * @param array $address Address fields. - * @param string $address_type Type of address (billing or shipping). - * @return array Updated address fields. + * @param string $name Integration name. + * @return IntegrationInterface|null The registered integration, or null if it is not registered. */ - public function edit_address_fields($address, $address_type) + public function get_registered($name) { } /** - * Validates and saves additional address fields to the customer object on the My Account page. - * - * Customer is not provided by this hook so we handle save here. + * Retrieves all registered integrations. * - * @param integer $user_id User ID. + * @return IntegrationInterface[] */ - public function save_account_form_fields($user_id) + public function get_all_registered() { } /** - * For the My Account page, save address fields. This uses the Store API endpoint for saving addresses so - * extensibility hooks are consistent across the codebase. - * - * The caller saves the customer object if there are no errors. Nonces are checked before this method executes. + * Gets an array of all registered integration's script handles for the editor. * - * @param integer $user_id User ID. - * @param string $address_type Type of address (billing or shipping). - * @param array $address Address fields. - * @param WC_Customer $customer Customer object. + * @return string[] */ - public function save_address_fields($user_id, $address_type, $address = [], $customer = null) + public function get_all_registered_editor_script_handles() { } /** - * Get posted additional field values. + * Gets an array of all registered integration's script handles. * - * @param string $location The location to get fields for. - * @param string $group The group to get fields for. - * @param boolean $sanitize Whether to sanitize the field values. - * @return array The posted field values and sanitized field values. + * @return string[] */ - protected function get_posted_additional_field_values($location, $group, $sanitize = true) + public function get_all_registered_script_handles() { } /** - * Validate and save additional fields for a given customer. + * Gets an array of all registered integration's script data. * - * @param WC_Customer $customer Customer object. - * @param string $location Location to save fields for. - * @param string $group Group to save fields for. - * @return true|\WP_Error True if successful, \WP_Error if there are errors. + * @return array */ - protected function update_additional_fields_for_customer($customer, $location, $group) + public function get_all_registered_script_data() { } } } -namespace Automattic\WooCommerce\Blocks\Domain\Services\CheckoutFieldsSchema { +namespace Automattic\WooCommerce\Blocks { /** - * DocumentObject class. + * Library class. * - * This will combine and format given cart/customer/checkout data into a standard object format that can be queried through - * JSON. This is used for conditional fields and validation during checkout. + * @deprecated 5.0.0 This class will be removed in a future release. This has been replaced by BlockTypesController. + * @internal */ - class DocumentObject - { - /** - * Docuemnt object context which may adjust the schema response. - * - * @var null|string - */ - protected $context = null; - /** - * Valid contexts. - * - * @var array - */ - protected $valid_contexts = ['shipping_address', 'billing_address', 'contact', 'order']; - /** - * The cart object. - * - * @var WC_Cart|null - */ - protected $cart = null; - /** - * The customer object. - * - * @var WC_Customer|null - */ - protected $customer = null; + class Library + { /** - * Cart controller class instance. + * Initialize block library features. * - * @var CartController + * @deprecated 5.0.0 */ - protected $cart_controller; + public static function init() + { + } /** - * Schema controller class instance. + * Register custom tables within $wpdb object. * - * @var SchemaController + * @deprecated 5.0.0 */ - protected $schema_controller; + public static function define_tables() + { + } /** - * The request data. + * Register blocks, hooking up assets and render functions as needed. * - * @var array + * @deprecated 5.0.0 */ - protected $request_data = []; + public static function register_blocks() + { + } + } + /** + * Contains all the option names used by the plugin. + */ + class Options + { + const WC_BLOCK_VERSION = 'wc_blocks_version'; + const WC_BLOCK_USE_BLOCKIFIED_PRODUCT_GRID_BLOCK_AS_TEMPLATE = 'wc_blocks_use_blockified_product_grid_block_as_template'; + } + /** + * 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. + * + * @since 2.5.0 + */ + class Package + { /** - * The constructor. + * For back compat this is provided. Ideally, you should register your + * class with Automattic\Woocommerce\Blocks\Container and make Package a + * dependency. * - * @param array $request_data Data that overrides the default values. + * @since 2.5.0 + * @return Package The Package instance class */ - public function __construct(array $request_data = []) + protected static function get_package() { } /** - * Set document object context. + * Init the package - load the blocks library and define constants. * - * @param null|string $context Context to set. + * @since 2.5.0 Handled by new NewPackage. */ - public function set_context($context = null) + public static function init() { } /** - * Set the customer object. + * Return the version of the package. * - * @param WC_Customer $customer The customer object. + * @return string */ - public function set_customer(\WC_Customer $customer) + public static function get_version() { } /** - * Set the cart object. + * Return the path to the package. * - * @param WC_Cart $cart The cart object. + * @return string */ - public function set_cart(\WC_Cart $cart) + public static function get_path() { } /** - * Gets a subset of cart data. + * Returns an instance of the FeatureGating class. * - * @return array The cart data. + * @return FeatureGating + * @deprecated since 9.6, use wp_get_environment_type() instead. */ - protected function get_cart_data() + public static function feature() { } /** - * Get checkout data. + * Loads the dependency injection container for woocommerce blocks. * - * @return array Checkout data context. + * @param boolean $reset Used to reset the container to a fresh instance. + * Note: this means all dependencies will be + * reconstructed. */ - protected function get_checkout_data() + public static function container($reset = false) { } + } +} +namespace Automattic\WooCommerce\Blocks\Patterns { + /** + * AIPatterns class. + * + * @internal + * @deprecated This class can't be removed due https://github.com/woocommerce/woocommerce/issues/52311. + */ + class AIPatterns + { + } + /** + * PatternsToolkit class. + * + * @internal + */ + class PTKClient + { /** - * Get the customer data. + * The Patterns Toolkit API URL + */ + const PATTERNS_TOOLKIT_URL = 'https://public-api.wordpress.com/rest/v1/ptk/patterns/'; + /** + * The schema for the patterns toolkit. * - * @return array The customer data. + * @var array */ - protected function get_customer_data() + private $schema; + /** + * Constructor. + */ + public function __construct() { } /** - * Get the data for the document object. - * - * This isn't a 1:1 match with Store API because some data is simplified to make it easier to parse as JSON. + * Fetch the WooCommerce patterns from the Patterns Toolkit (PTK) API. * - * @return array The data for the document object. + * @param array $options Options for fetching patterns. + * @return array|WP_Error */ - public function get_data() + public function fetch_patterns(array $options = array()) { } /** - * Get the current context. + * Validate the patterns toolkit patterns. * - * @return null|string The context. + * @param array $patterns The patterns to validate. + * @return bool */ - public function get_context() + public function is_valid_schema($patterns) { } } /** - * Service class validating checkout field schema. + * PTKPatterns class. + * + * @internal */ - class Validation + class PTKPatternsStore { + const OPTION_NAME = 'ptk_patterns'; + const LAST_FETCH_PATTERNS_REQUEST_OPTION_NAME = 'last_fetch_patterns_request'; + const CATEGORY_MAPPING = array('testimonials' => 'reviews'); /** - * Meta schema. + * PatternsToolkit instance. * - * @var string + * @var PTKClient $ptk_client */ - private static $meta_schema_json = ''; + private \Automattic\WooCommerce\Blocks\Patterns\PTKClient $ptk_client; /** - * Get the field schema with context. + * Constructor for the class. * - * @param string $field_id The field ID. - * @param array $field_schema The field schema. - * @param string $context The context. - * @return array + * @param PTKClient $ptk_client An instance of PatternsToolkit. */ - public static function get_field_schema_with_context($field_id, $field_schema, $context) + public function __construct(\Automattic\WooCommerce\Blocks\Patterns\PTKClient $ptk_client) { } /** - * Check if the schema is unwrapped (has cart, checkout, customer, as top level keys). + * Resets the cached patterns when the `woocommerce_allow_tracking` option is disabled. + * Resets and fetch the patterns from the PTK when it is enabled (if the scheduler + * is initialized, it's done asynchronously via a scheduled action). * - * @param array $schema The schema to check. - * @return bool + * @return void */ - private static function schema_is_unwrapped($schema) + public function flush_or_fetch_patterns() { } /** - * Validate the field rules. + * Schedule an async action to fetch the PTK patterns when the scheduler is initialized. * - * @param DocumentObject $document_object The document object to validate. - * @param array $rules The rules to validate against. - * @return bool|WP_Error + * @return void */ - public static function validate_document_object(\Automattic\WooCommerce\Blocks\Domain\Services\CheckoutFieldsSchema\DocumentObject $document_object, $rules) + private function schedule_fetch_patterns() { } /** - * Check if the fields have defined schema. + * Check if the last request was more than one day ago. * - * @param array $fields The fields. + * @param int $last_request The last request time. * @return bool */ - public static function has_field_schema($fields) + private function is_older_than_one_day($last_request) { } /** - * Validate meta schema for field rules. + * Schedule an action if it's not already pending. * - * @param mixed $rules The rules to validate. - * @return bool|WP_Error True if the field options are valid, a WP_Error otherwise. + * @param string $action The action name to schedule. + * @return void */ - public static function is_valid_schema($rules) + private function schedule_action_if_not_pending($action) { } - } -} -namespace Automattic\WooCommerce\Blocks\Domain\Services { - /** - * Checkout Link class. - */ - class CheckoutLink - { /** - * Initialize the checkout link service. + * Get the patterns from the Patterns Toolkit cache. + * + * @return array */ - public function init() + public function get_patterns() { } /** - * Add the checkout link endpoint. + * Filter the patterns that have external dependencies. + * + * @param array $patterns The patterns to filter. + * @return array */ - public function add_checkout_link_endpoint() + private function filter_patterns(array $patterns) { } /** - * Add the checkout link query var. + * Re-fetch the patterns when the WooCommerce plugin is updated. * - * @param array $vars The query vars. - * @return array The query vars. + * @param WP_Upgrader $upgrader_object WP_Upgrader instance. + * @param array $options Array of bulk item update data. + * + * @return void */ - public function add_query_vars($vars) + public function fetch_patterns_on_plugin_update($upgrader_object, $options) { } /** - * Handle the checkout link endpoint. + * Reset the cached patterns to fetch them again from the PTK. * * @return void */ - public function handle_checkout_link_endpoint() + public function flush_cached_patterns() { } /** - * Validate the checkout link. + * Reset the cached patterns and fetch them again from the PTK API. * - * @return bool True if the checkout link is valid, false otherwise. + * @return void */ - protected function validate_checkout_link() + public function fetch_patterns() { } /** - * Get the products from the checkout link. + * Check if the user allowed tracking. * - * @return array The products (keys) and their quantities (values). + * @return bool */ - protected function get_products_from_checkout_link() + private function allowed_tracking_is_enabled(): bool { } /** - * Add error notices to the cart. + * Change the categories of the patterns to match the ones used in the CYS flow * - * @param \WP_Error $errors The errors. - * @return void + * @param array $patterns The patterns to map categories for. + * @return array The patterns with the categories mapped. */ - protected function add_error_notices(\WP_Error $errors) + private function map_categories(array $patterns) { } /** - * Process the query params and return the checkout link to redirect to complete with session token. + * Check if the pattern has external dependencies. * - * @return string The checkout link. + * @param array $pattern The pattern to check. + * + * @return bool */ - protected function get_checkout_link() + private function has_external_dependencies($pattern) { } } /** - * Service class implementing new create account emails used for order processing via the Block Based Checkout. + * PatternRegistry class. * - * @deprecated This class can't be removed due to https://github.com/woocommerce/woocommerce/issues/52311. + * @internal */ - class CreateAccount + class PatternRegistry { + const SLUG_REGEX = '/^[A-z0-9\/_-]+$/'; + const COMMA_SEPARATED_REGEX = '/[\s,]+/'; /** - * Reference to the Package instance + * Returns pattern slugs with their localized labels for categorization. * - * @var Package - */ - private $package; - /** - * Constructor. + * Each key represents a unique pattern slug, while the value is the localized label. * - * @param Package $package An instance of (Woo Blocks) Package. + * @return array */ - public function __construct(\Automattic\WooCommerce\Blocks\Domain\Package $package) + private function get_category_labels() { } /** - * Init - register handlers for WooCommerce core email hooks. + * Register a block pattern. + * + * @param string $source The pattern source. + * @param array $pattern_data The pattern data. + * + * @return void */ - public function init() + public function register_block_pattern($source, $pattern_data) { } /** - * Trigger new account email. + * Convert a kebab-case string to capital case. * - * @param int $customer_id The ID of the new customer account. - * @param array $new_customer_data Assoc array of data for the new account. + * @param string $value The kebab-case string. + * + * @return string */ - public function customer_new_account($customer_id = 0, array $new_customer_data = array()) + private static function kebab_to_capital_case($value) { } } +} +namespace Automattic\WooCommerce\Blocks\Payments { /** - * Service class for adding DraftOrder functionality to WooCommerce core. - * - * Sets up all logic related to the Checkout Draft Orders service + * The Api class provides an interface to payment method registration. * - * @internal + * @since 2.6.0 */ - class DraftOrders + class Api { - const DB_STATUS = 'wc-checkout-draft'; - const STATUS = 'checkout-draft'; - const DRAFT_CLEANUP_EVENT_HOOK = 'woocommerce_cleanup_draft_orders'; /** - * Holds the Package instance + * Reference to the PaymentMethodRegistry instance. * - * @var Package + * @var PaymentMethodRegistry */ - private $package; + private $payment_method_registry; + /** + * Reference to the AssetDataRegistry instance. + * + * @var AssetDataRegistry + */ + private $asset_registry; /** * Constructor * - * @param Package $package An instance of the package class. + * @param PaymentMethodRegistry $payment_method_registry An instance of Payment Method Registry. + * @param AssetDataRegistry $asset_registry Used for registering data to pass along to the request. */ - public function __construct(\Automattic\WooCommerce\Blocks\Domain\Package $package) + public function __construct(\Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry, \Automattic\WooCommerce\Blocks\Assets\AssetDataRegistry $asset_registry) { } /** - * Set all hooks related to adding Checkout Draft order functionality to Woo Core. + * Initialize class features. */ public function init() { } /** - * Installation related logic for Draft order functionality. + * Add payment method script handles as script dependencies. * - * @internal + * @param array $dependencies Array of script dependencies. + * @param string $handle Script handle. + * @return array */ - public function install() + public function add_payment_method_script_dependencies($dependencies, $handle) { } /** - * Unschedule recurring actions when plugin is deactivated. + * Returns true if the payment gateway is enabled. * - * @since 10.0.0 - * @internal + * @param object $gateway Payment gateway. + * @return boolean */ - public function unschedule_cronjobs() + private function is_payment_gateway_enabled($gateway) { } /** - * Maybe create cron events. + * Add payment method data to Asset Registry. */ - protected function maybe_create_cronjobs() + public function add_payment_method_script_data() { } /** - * Register custom order status for orders created via the API during checkout. - * - * Draft order status is used before payment is attempted, during checkout, when a cart is converted to an order. + * Register payment method integrations bundled with blocks. * - * @param array $statuses Array of statuses. - * @internal - * @return array + * @param PaymentMethodRegistry $payment_method_registry Payment method registry instance. */ - public function register_draft_order_status(array $statuses) + public function register_payment_method_integrations(\Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry) { } /** - * Register custom order post status for orders created via the API during checkout. - * - * @param array $statuses Array of statuses. - * @internal - * @return array + * Verify all dependencies of registered payment methods have been registered. + * If not, remove that payment method script from the list of dependencies + * of Cart and Checkout block scripts so it doesn't break the blocks and show + * an error in the admin. */ - public function register_draft_order_post_status(array $statuses) + public function verify_payment_methods_dependencies() { } + } + interface PaymentMethodTypeInterface extends \Automattic\WooCommerce\Blocks\Integrations\IntegrationInterface + { /** - * Returns the properties of this post status for registration. + * Returns if this payment method should be active. If false, the scripts will not be enqueued. + * + * @return boolean + */ + public function is_active(); + /** + * Returns an array of script handles to enqueue for this payment method in + * the frontend context + * + * @return string[] + */ + public function get_payment_method_script_handles(); + /** + * Returns an array of script handles to enqueue for this payment method in + * the admin context + * + * @return string[] + */ + public function get_payment_method_script_handles_for_admin(); + /** + * An array of key, value pairs of data made available to payment methods + * client side. * * @return array */ - private function get_post_status_properties() + public function get_payment_method_data(); + /** + * Get array of supported features. + * + * @return string[] + */ + public function get_supported_features(); + } +} +namespace Automattic\WooCommerce\Blocks\Payments\Integrations { + /** + * AbstractPaymentMethodType class. + * + * @since 2.6.0 + */ + abstract class AbstractPaymentMethodType implements \Automattic\WooCommerce\Blocks\Payments\PaymentMethodTypeInterface + { + /** + * Payment method name defined by payment methods extending this class. + * + * @var string + */ + protected $name = ''; + /** + * Settings from the WP options table + * + * @var array + */ + protected $settings = []; + /** + * Get a setting from the settings array if set. + * + * @param string $name Setting name. + * @param mixed $default Value that is returned if the setting does not exist. + * @return mixed + */ + protected function get_setting($name, $default = '') { } /** - * Remove draft status from the 'status' argument of an $args array. - * - * @param array $args Array of arguments containing statuses in the status key. - * @internal - * @return array + * Returns the name of the payment method. */ - public function delete_draft_order_post_status_from_args($args) + public function get_name() { } /** - * Append draft status to a list of statuses. + * Returns if this payment method should be active. If false, the scripts will not be enqueued. * - * @param array $statuses Array of statuses. - * @internal - * @return array + * @return boolean */ - public function append_draft_order_post_status($statuses) + public function is_active() { } /** - * Delete draft orders older than a day in batches of 20. - * - * Ran on a daily cron schedule. + * Returns an array of script handles to enqueue for this payment method in + * the frontend context * - * @internal + * @return string[] */ - public function delete_expired_draft_orders() + public function get_payment_method_script_handles() { } /** - * Since it's possible for third party code to clobber the `$wp_post_statuses` global, - * we need to do a final check here to make sure the draft post status is - * registered with the global so that it is not removed by WP_Query status - * validation checks. + * Returns an array of script handles to enqueue for this payment method in + * the admin context + * + * @return string[] */ - private function ensure_draft_status_registered() + public function get_payment_method_script_handles_for_admin() { } /** - * Asserts whether incoming order results are expected given the query - * this service class executes. + * Returns an array of supported features. * - * @param WC_Order[] $order_results The order results being asserted. - * @param int $expected_batch_size The expected batch size for the results. - * @throws Exception If any assertions fail, an exception is thrown. + * @return string[] */ - private function assert_order_results($order_results, $expected_batch_size) + public function get_supported_features() { } - } -} -namespace Automattic\WooCommerce\Blocks\Domain\Services\Email { - /** - * Customer New Account. Previously used for blocks, but now replaced by the core email. - * - * @deprecated This class can't be removed due to https://github.com/woocommerce/woocommerce/issues/52311. - */ - class CustomerNewAccount extends \WC_Email - { /** - * Constructor. + * An array of key, value pairs of data made available to payment methods + * client side. * - * @param Package $package An instance of (Woo Blocks) Package. + * @return array */ - public function __construct(\Automattic\WooCommerce\Blocks\Domain\Package $package) + public function get_payment_method_data() + { + } + /** + * Returns an array of script handles to enqueue in the frontend context. + * + * Alias of get_payment_method_script_handles. Defined by IntegrationInterface. + * + * @return string[] + */ + public function get_script_handles() { } - } -} -namespace Automattic\WooCommerce\Blocks\Domain\Services { - /** - * Service class that used to handle feature flags. That functionality - * is removed now and it is only used to determine "environment". - * - * @internal - * - * @deprecated since 9.6.0, use wp_get_environment_type() instead. - */ - class FeatureGating extends \Automattic\WooCommerce\Admin\DeprecatedClassFacade - { /** - * The version that this class was deprecated in. + * Returns an array of script handles to enqueue in the admin context. * - * @var string + * Alias of get_payment_method_script_handles_for_admin. Defined by IntegrationInterface. + * + * @return string[] */ - protected static $deprecated_in_version = '9.6.0'; + public function get_editor_script_handles() + { + } /** - * Constructor + * An array of key, value pairs of data made available to the block on the client side. * - * @param string $environment Hardcoded environment value. Useful for tests. + * Alias of get_payment_method_data. Defined by IntegrationInterface. + * + * @return array */ - public function __construct($environment = 'unset') + public function get_script_data() { } } /** - * Service class to integrate Blocks with the Google Analytics extension, + * Bank Transfer (BACS) payment method integration + * + * @since 3.0.0 */ - class GoogleAnalytics + final class BankTransfer extends \Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType { /** - * Instance of the asset API. + * Payment method name/id/slug (matches id in WC_Gateway_BACS in core). * - * @var AssetApi + * @var string */ - protected $asset_api; + protected $name = \WC_Gateway_BACS::ID; /** - * Constructor. + * An instance of the Asset Api * - * @param AssetApi $asset_api Instance of the asset API. + * @var Api */ - public function __construct(\Automattic\WooCommerce\Blocks\Assets\Api $asset_api) - { - } + private $asset_api; /** - * Hook into WP. + * Constructor + * + * @param Api $asset_api An instance of Api. */ - public function init() + public function __construct(\Automattic\WooCommerce\Blocks\Assets\Api $asset_api) { } /** - * Register scripts. + * Initializes the payment method type. */ - public function register_assets() + public function initialize() { } /** - * Enqueue the Google Tag Manager script if prerequisites are met. + * Returns if this payment method should be active. If false, the scripts will not be enqueued. + * + * @return boolean */ - public function enqueue_scripts() + public function is_active() { } /** - * Get settings from the GA integration extension. + * Returns an array of scripts/handles to be registered for this payment method. * * @return array */ - private function get_google_analytics_settings() + public function get_payment_method_script_handles() { } /** - * Add async to script tags with defined handles. + * Returns an array of key=>value pairs of data made available to the payment methods script. * - * @param string $tag HTML for the script tag. - * @param string $handle Handle of script. - * @param string $src Src of script. - * @return string + * @return array */ - public function async_script_loader_tags($tag, $handle, $src) + public function get_payment_method_data() { } } /** - * Service class that handles hydration of API data for blocks. + * Cash on Delivery (COD) payment method integration + * + * @since 3.0.0 */ - class Hydration + final class CashOnDelivery extends \Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType { /** - * Instance of the asset data registry. + * Payment method name/id/slug (matches id in WC_Gateway_COD in core). * - * @var AssetDataRegistry + * @var string */ - protected $asset_data_registry; + protected $name = \WC_Gateway_COD::ID; /** - * Cached notices to restore after hydrating the API. + * An instance of the Asset Api * - * @var array + * @var Api */ - protected $cached_store_notices = array(); + private $asset_api; /** - * Constructor. + * Constructor * - * @param AssetDataRegistry $asset_data_registry Instance of the asset data registry. + * @param Api $asset_api An instance of Api. */ - public function __construct(\Automattic\WooCommerce\Blocks\Assets\AssetDataRegistry $asset_data_registry) + public function __construct(\Automattic\WooCommerce\Blocks\Assets\Api $asset_api) { } /** - * Hydrates the asset data registry with data from the API. Disables notices and nonces so requests contain valid - * data that is not polluted by the current session. - * - * @param array $path API paths to hydrate e.g. '/wc/store/v1/cart'. - * @return array Response data. + * Initializes the payment method type. */ - public function get_rest_api_response_data($path = '') + public function initialize() { } /** - * Helper method to generate GET response from a controller. Also fires the `rest_request_after_callbacks` for backward compatibility. - * - * @param string $controller_class Controller class FQN that will respond to the request. - * @param string $path Request path regex. + * Returns if this payment method should be active. If false, the scripts will not be enqueued. * - * @return false|mixed|null Response + * @return boolean */ - private function get_response_from_controller($controller_class, $path) + public function is_active() { } /** - * Inspired from WP core's `match_request_to_handler`, this matches a given path from available route regexes. - * However, unlike WP core, this does not check against query params, request method etc. - * - * @param string $path The path to match. - * @param array $available_routes Available routes in { $regex1 => $contoller_class1, ... } format. + * Return enable_for_virtual option. * - * @return string|null - */ - private function match_route_to_handler($path, $available_routes) - { - } - /** - * Disable the nonce check temporarily. - */ - protected function disable_nonce_check() - { - } - /** - * Callback to disable the nonce check. While we could use `__return_true`, we use a custom named callback so that - * we can remove it later without affecting other filters. + * @return boolean True if store allows COD payment for orders containing only virtual products. */ - public function disable_nonce_check_callback() + private function get_enable_for_virtual() { } /** - * Restore the nonce check. + * Return enable_for_methods option. + * + * @return array Array of shipping methods (string ids) that allow COD. (If empty, all support COD.) */ - protected function restore_nonce_check() + private function get_enable_for_methods() { } /** - * Cache notices before hydrating the API if the customer has a session. + * Returns an array of scripts/handles to be registered for this payment method. + * + * @return array */ - protected function cache_store_notices() + public function get_payment_method_script_handles() { } /** - * Restore notices into current session from cache. + * Returns an array of key=>value pairs of data made available to the payment methods script. + * + * @return array */ - protected function restore_cached_store_notices() + public function get_payment_method_data() { } } /** - * Service class for adding new-style Notices to WooCommerce core. + * Cheque payment method integration * - * @internal + * @since 2.6.0 */ - class Notices + final class Cheque extends \Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType { /** - * Holds the Package instance + * Payment method name defined by payment methods extending this class. * - * @var Package + * @var string */ - private $package; + protected $name = \WC_Gateway_Cheque::ID; /** - * Templates used for notices. + * An instance of the Asset Api * - * @var array + * @var Api */ - private $notice_templates = array('notices/error.php', 'notices/notice.php', 'notices/success.php'); + private $asset_api; /** * Constructor * - * @param Package $package An instance of the package class. + * @param Api $asset_api An instance of Api. */ - public function __construct(\Automattic\WooCommerce\Blocks\Domain\Package $package) + public function __construct(\Automattic\WooCommerce\Blocks\Assets\Api $asset_api) { } /** - * Initialize notice hooks. + * Initializes the payment method type. */ - public function init() + public function initialize() { } /** - * Allow SVG icon in notices. + * Returns if this payment method should be active. If false, the scripts will not be enqueued. * - * @param array $allowed_tags Allowed tags. - * @return array + * @return boolean */ - public function add_kses_notice_allowed_tags($allowed_tags) + public function is_active() { } /** - * Replaces core notice templates with those from blocks. - * - * The new notice templates match block components with matching icons and styling. The differences are: - * 1. Core has notices for info, success, and error notices, blocks has notices for info, success, error, - * warning, and a default notice type. - * 2. The block notices use different CSS classes to the core notices. Core uses `woocommerce-message`, `is-info` - * and `is-error` classes, blocks uses `wc-block-components-notice-banner is-error`, - * `wc-block-components-notice-banner is-info`, and `wc-block-components-notice-banner is-success`. - * 3. The markup of the notices is different, with the block notices using SVG icons and a slightly different - * structure to accommodate this. + * Returns an array of scripts/handles to be registered for this payment method. * - * @param string $template Located template path. - * @param string $template_name Template name. - * @param array $args Template arguments. - * @param string $template_path Template path. - * @param string $default_path Default path. - * @return string + * @return array */ - public function get_notices_template($template, $template_name, $args, $template_path, $default_path) + public function get_payment_method_script_handles() { } /** - * Replaces all notices with the new block-based notices. + * Returns an array of key=>value pairs of data made available to the payment methods script. * - * @return void + * @return array */ - public function enqueue_notice_styles() + public function get_payment_method_data() { } } -} -namespace Automattic\WooCommerce\Blocks\Images { - /** - * Pexels API client. - * - * @internal - * @deprecated This class can't be removed due https://github.com/woocommerce/woocommerce/issues/52311. - */ - class Pexels - { - } -} -namespace Automattic\WooCommerce\Blocks { /** - * A class used to display inbox messages to merchants in the WooCommerce Admin dashboard. + * PayPal Standard payment method integration * - * @package Automattic\WooCommerce\Blocks - * @since x.x.x + * @since 2.6.0 */ - class InboxNotifications + final class PayPal extends \Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType { - const SURFACE_CART_CHECKOUT_NOTE_NAME = 'surface_cart_checkout'; /** - * Deletes the note. + * Payment method name defined by payment methods extending this class. + * + * @var string */ - public static function delete_surface_cart_checkout_blocks_notification() - { - } - } - /** - * Installer class. - * Handles installation of Blocks plugin dependencies. - * - * @internal - */ - class Installer - { + protected $name = \WC_Gateway_Paypal::ID; /** - * Initialize class features. + * An instance of the Asset Api + * + * @var Api */ - public function init() + private $asset_api; + /** + * Constructor + * + * @param Api $asset_api An instance of Api. + */ + public function __construct(\Automattic\WooCommerce\Blocks\Assets\Api $asset_api) { } /** - * Installation tasks ran on admin_init callback. + * Initializes the payment method type. */ - public function install() + public function initialize() { } /** - * Modifies default page content replacing it with classic shortcode block. - * We check for shortcode as default because after WooCommerce 8.3, block-based checkout is used by default. - * This only runs on Tools > Create Pages as the filter is not applied on WooCommerce plugin activation. + * Returns if this payment method should be active. If false, the scripts will not be enqueued. * - * @param array $pages Default pages. - * @return array + * @return boolean */ - public function create_pages($pages) + public function is_active() { } /** - * Set up the database tables which the plugin needs to function. + * Returns an array of scripts/handles to be registered for this payment method. + * + * @return array */ - public function maybe_create_tables() + public function get_payment_method_script_handles() { } /** - * Create database table, if it doesn't already exist. - * - * Based on admin/install-helper.php maybe_create_table function. + * Returns an array of key=>value pairs of data made available to the payment methods script. * - * @param string $table_name Database table name. - * @param string $create_sql Create database table SQL. - * @return bool False on error, true if already exists or success. + * @return array */ - protected function maybe_create_table($table_name, $create_sql) + public function get_payment_method_data() { } /** - * Add a notice if table creation fails. + * Returns an array of supported features. * - * @param string $table_name Name of the missing table. + * @return string[] */ - protected function add_create_table_notice($table_name) + public function get_supported_features() { } } } -namespace Automattic\WooCommerce\Blocks\Integrations { +namespace Automattic\WooCommerce\Blocks\Payments { /** - * Integration.Interface + * Class used for interacting with payment method types. * - * Integrations must use this interface when registering themselves with blocks, + * @since 2.6.0 */ - interface IntegrationInterface + final class PaymentMethodRegistry extends \Automattic\WooCommerce\Blocks\Integrations\IntegrationRegistry { /** - * The name of the integration. + * Integration identifier is used to construct hook names and is given when the integration registry is initialized. * - * @return string - */ - public function get_name(); - /** - * When called invokes any initialization/setup for the integration. + * @var string */ - public function initialize(); + protected $registry_identifier = 'payment_method_type'; /** - * Returns an array of script handles to enqueue in the frontend context. + * Retrieves all registered payment methods that are also active. * - * @return string[] + * @return PaymentMethodTypeInterface[] */ - public function get_script_handles(); + public function get_all_active_registered() + { + } /** - * Returns an array of script handles to enqueue in the editor context. + * Gets an array of all registered payment method script handles, but only for active payment methods. * * @return string[] */ - public function get_editor_script_handles(); + public function get_all_active_payment_method_script_dependencies() + { + } /** - * An array of key, value pairs of data made available to the block on the client side. + * Gets an array of all registered payment method script data, but only for active payment methods. * * @return array */ - public function get_script_data(); + public function get_all_registered_script_data() + { + } } +} +namespace Automattic\WooCommerce\Blocks { /** - * Class used for tracking registered integrations with various Block types. + * Process the query data for filtering purposes. */ - class IntegrationRegistry + final class QueryFilters { /** - * Integration identifier is used to construct hook names and is given when the integration registry is initialized. - * - * @var string - */ - protected $registry_identifier = ''; - /** - * Registered integrations, as `$name => $instance` pairs. - * - * @var IntegrationInterface[] - */ - protected $registered_integrations = []; - /** - * Initializes all registered integrations. - * - * Integration identifier is used to construct hook names and is given when the integration registry is initialized. + * Initialization method. * - * @param string $registry_identifier Identifier for this registry. + * @internal */ - public function initialize($registry_identifier = '') + public function init() { } /** - * Registers an integration. - * - * @param IntegrationInterface $integration An instance of IntegrationInterface. + * Filter the posts clauses of the main query to support global filters. * - * @return boolean True means registered successfully. + * @param array $args Query args. + * @param \WP_Query $wp_query WP_Query object. + * @return array */ - public function register(\Automattic\WooCommerce\Blocks\Integrations\IntegrationInterface $integration) + public function main_query_filter($args, $wp_query) { } /** - * Checks if an integration is already registered. + * Add conditional query clauses based on the filter params in query vars. * - * @param string $name Integration name. - * @return bool True if the integration is registered, false otherwise. + * @param array $args Query args. + * @param \WP_Query $wp_query WP_Query object. + * @return array */ - public function is_registered($name) + public function add_query_clauses($args, $wp_query) { } /** - * Un-register an integration. + * Get price data for current products. * - * @param string|IntegrationInterface $name Integration name, or alternatively a IntegrationInterface instance. - * @return boolean|IntegrationInterface Returns the unregistered integration instance if unregistered successfully. + * @param array $query_vars The WP_Query arguments. + * @return object */ - public function unregister($name) + public function get_filtered_price($query_vars) { } /** - * Retrieves a registered Integration by name. + * Get stock status counts for the current products. * - * @param string $name Integration name. - * @return IntegrationInterface|null The registered integration, or null if it is not registered. + * @param array $query_vars The WP_Query arguments. + * @return array status=>count pairs. */ - public function get_registered($name) + public function get_stock_status_counts($query_vars) { } /** - * Retrieves all registered integrations. + * Get rating counts for the current products. * - * @return IntegrationInterface[] + * @param array $query_vars The WP_Query arguments. + * @return array rating=>count pairs. */ - public function get_all_registered() + public function get_rating_counts($query_vars) { } /** - * Gets an array of all registered integration's script handles for the editor. + * Get attribute counts for the current products. * - * @return string[] + * @param array $query_vars The WP_Query arguments. + * @param string $attribute_to_count Attribute taxonomy name. + * @return array termId=>count pairs. */ - public function get_all_registered_editor_script_handles() + public function get_attribute_counts($query_vars, $attribute_to_count) { } /** - * Gets an array of all registered integration's script handles. + * Add query clauses for stock filter. * - * @return string[] + * @param array $args Query args. + * @param \WP_Query $wp_query WP_Query object. + * @return array */ - public function get_all_registered_script_handles() + private function stock_filter_clauses($args, $wp_query) { } /** - * Gets an array of all registered integration's script data. + * Add query clauses for price filter. * + * @param array $args Query args. + * @param \WP_Query $wp_query WP_Query object. * @return array */ - public function get_all_registered_script_data() + private function price_filter_clauses($args, $wp_query) { } - } -} -namespace Automattic\WooCommerce\Blocks { - /** - * Library class. - * - * @deprecated 5.0.0 This class will be removed in a future release. This has been replaced by BlockTypesController. - * @internal - */ - class Library - { /** - * Initialize block library features. + * Join wc_product_meta_lookup to posts if not already joined. * - * @deprecated 5.0.0 + * @param string $sql SQL join. + * @return string */ - public static function init() + private function append_product_sorting_table_join($sql) { } /** - * Register custom tables within $wpdb object. + * Generate calculate query by stock status. * - * @deprecated 5.0.0 - */ - public static function define_tables() - { - } - /** - * Register blocks, hooking up assets and render functions as needed. + * @param string $status status to calculate. + * @param string $product_query_sql product query for current filter state. + * @param array $stock_status_options available stock status options. * - * @deprecated 5.0.0 + * @return false|string */ - public static function register_blocks() + private function generate_stock_status_count_query($status, $product_query_sql, $stock_status_options) { } - } - /** - * Contains all the option names used by the plugin. - */ - class Options - { - const WC_BLOCK_VERSION = 'wc_blocks_version'; - const WC_BLOCK_USE_BLOCKIFIED_PRODUCT_GRID_BLOCK_AS_TEMPLATE = 'wc_blocks_use_blockified_product_grid_block_as_template'; - } - /** - * 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. - * - * @since 2.5.0 - */ - class Package - { /** - * For back compat this is provided. Ideally, you should register your - * class with Automattic\Woocommerce\Blocks\Container and make Package a - * dependency. + * Get query for price filters when dealing with displayed taxes. * - * @since 2.5.0 - * @return Package The Package instance class + * @param float $price_filter Price filter to apply. + * @param string $column Price being filtered (min or max). + * @param string $operator Comparison operator for column. + * @return string Constructed query. */ - protected static function get_package() + private function get_price_filter_query_for_displayed_taxes($price_filter, $column = 'min_price', $operator = '>=') { } /** - * Init the package - load the blocks library and define constants. + * If price filters need adjustment to work with displayed taxes, this returns true. * - * @since 2.5.0 Handled by new NewPackage. + * This logic is used when prices are stored in the database differently to how they are being displayed, with regards + * to taxes. + * + * @return boolean */ - public static function init() + private function adjust_price_filters_for_displayed_taxes() { } /** - * Return the version of the package. + * Adjusts a price filter based on a tax class and whether or not the amount includes or excludes taxes. * - * @return string + * This calculation logic is based on `wc_get_price_excluding_tax` and `wc_get_price_including_tax` in core. + * + * @param float $price_filter Price filter amount as entered. + * @param string $tax_class Tax class for adjustment. + * @return float */ - public static function get_version() + private function adjust_price_filter_for_tax_class($price_filter, $tax_class) { } /** - * Return the path to the package. + * Get attribute lookup table name. * * @return string */ - public static function get_path() + private function get_lookup_table_name() { } /** - * Returns an instance of the FeatureGating class. + * Add query clauses for attribute filter. * - * @return FeatureGating - * @deprecated since 9.6, use wp_get_environment_type() instead. + * @param array $args Query args. + * @param \WP_Query $wp_query WP_Query object. + * @return array */ - public static function feature() + private function attribute_filter_clauses($args, $wp_query) { } /** - * Loads the dependency injection container for woocommerce blocks. + * Get an array of attributes and terms selected from query arguments. * - * @param boolean $reset Used to reset the container to a fresh instance. - * Note: this means all dependencies will be - * reconstructed. + * @param array $query_vars The WP_Query arguments. + * @return array */ - public static function container($reset = false) + private function get_chosen_attributes($query_vars) { } } } -namespace Automattic\WooCommerce\Blocks\Patterns { +namespace Automattic\WooCommerce\Blocks\Registry { /** - * AIPatterns class. + * An abstract class for dependency types. * - * @internal - * @deprecated This class can't be removed due https://github.com/woocommerce/woocommerce/issues/52311. - */ - class AIPatterns - { - } - /** - * PatternsToolkit class. + * Dependency types are instances of a dependency used by the + * Dependency Injection Container for storing dependencies to invoke as they + * are needed. * - * @internal + * @since 2.5.0 */ - class PTKClient + abstract class AbstractDependencyType { /** - * The Patterns Toolkit API URL - */ - const PATTERNS_TOOLKIT_URL = 'https://public-api.wordpress.com/rest/v1/ptk/patterns/'; - /** - * The schema for the patterns toolkit. + * Holds a callable or value provided for this type. * - * @var array + * @var mixed */ - private $schema; + private $callable_or_value; /** - * Constructor. + * Constructor + * + * @param mixed $callable_or_value A callable or value for the dependency + * type instance. */ - public function __construct() + public function __construct($callable_or_value) { } /** - * Fetch the WooCommerce patterns from the Patterns Toolkit (PTK) API. + * Resolver for the internal dependency value. * - * @param array $options Options for fetching patterns. - * @return array|WP_Error + * @param Container $container The Dependency Injection Container. + * + * @return mixed */ - public function fetch_patterns(array $options = array()) + protected function resolve_value(\Automattic\WooCommerce\Blocks\Registry\Container $container) { } /** - * Validate the patterns toolkit patterns. + * Retrieves the value stored internally for this DependencyType * - * @param array $patterns The patterns to validate. - * @return bool + * @param Container $container The Dependency Injection Container. + * + * @return void */ - public function is_valid_schema($patterns) - { - } + abstract public function get(\Automattic\WooCommerce\Blocks\Registry\Container $container); } /** - * PTKPatterns class. + * A simple Dependency Injection Container * - * @internal + * This is used to manage dependencies used throughout the plugin. + * + * @since 2.5.0 */ - class PTKPatternsStore + class Container { - const OPTION_NAME = 'ptk_patterns'; - const LAST_FETCH_PATTERNS_REQUEST_OPTION_NAME = 'last_fetch_patterns_request'; - const CATEGORY_MAPPING = array('testimonials' => 'reviews'); /** - * PatternsToolkit instance. + * A map of Dependency Type objects used to resolve dependencies. * - * @var PTKClient $ptk_client + * @var AbstractDependencyType[] */ - private \Automattic\WooCommerce\Blocks\Patterns\PTKClient $ptk_client; + private $registry = []; /** - * Constructor for the class. + * Public api for adding a factory to the container. * - * @param PTKClient $ptk_client An instance of PatternsToolkit. + * Factory dependencies will have the instantiation callback invoked + * every time the dependency is requested. + * + * Typical Usage: + * + * ``` + * $container->register( MyClass::class, $container->factory( $mycallback ) ); + * ``` + * + * @param Closure $instantiation_callback This will be invoked when the + * dependency is required. It will + * receive an instance of this + * container so the callback can + * retrieve dependencies from the + * container. + * + * @return FactoryType An instance of the FactoryType dependency. */ - public function __construct(\Automattic\WooCommerce\Blocks\Patterns\PTKClient $ptk_client) + public function factory(\Closure $instantiation_callback) { } /** - * Resets the cached patterns when the `woocommerce_allow_tracking` option is disabled. - * Resets and fetch the patterns from the PTK when it is enabled (if the scheduler - * is initialized, it's done asynchronously via a scheduled action). + * Interface for registering a new dependency with the container. * - * @return void + * By default, the $value will be added as a shared dependency. This means + * that it will be a single instance shared among any other classes having + * that dependency. + * + * If you want a new instance every time it's required, then wrap the value + * in a call to the factory method (@see Container::factory for example) + * + * Note: Currently if the provided id already is registered in the container, + * the provided value is ignored. + * + * @param string $id A unique string identifier for the provided value. + * Typically it's the fully qualified name for the + * dependency. + * @param mixed $value The value for the dependency. Typically, this is a + * closure that will create the class instance needed. */ - public function flush_or_fetch_patterns() + public function register($id, $value) { } /** - * Schedule an async action to fetch the PTK patterns when the scheduler is initialized. + * Interface for retrieving the dependency stored in the container for the + * given identifier. * - * @return void + * @param string $id The identifier for the dependency being retrieved. + * @throws Exception If there is no dependency for the given identifier in + * the container. + * + * @return mixed Typically a class instance. */ - private function schedule_fetch_patterns() + public function get($id) { } + } + /** + * Definition for the FactoryType dependency type. + * + * @since 2.5.0 + */ + class FactoryType extends \Automattic\WooCommerce\Blocks\Registry\AbstractDependencyType + { /** - * Check if the last request was more than one day ago. + * Invokes and returns the value from the stored internal callback. * - * @param int $last_request The last request time. - * @return bool + * @param Container $container An instance of the dependency injection + * container. + * + * @return mixed */ - private function is_older_than_one_day($last_request) + public function get(\Automattic\WooCommerce\Blocks\Registry\Container $container) { } + } + /** + * A definition for the SharedType dependency type. + * + * @since 2.5.0 + */ + class SharedType extends \Automattic\WooCommerce\Blocks\Registry\AbstractDependencyType + { /** - * Schedule an action if it's not already pending. + * Holds a cached instance of the value stored (or returned) internally. * - * @param string $action The action name to schedule. - * @return void + * @var mixed */ - private function schedule_action_if_not_pending($action) - { - } + private $shared_instance; /** - * Get the patterns from the Patterns Toolkit cache. + * Returns the internal stored and shared value after initial generation. * - * @return array + * @param Container $container An instance of the dependency injection + * container. + * + * @return mixed */ - public function get_patterns() + public function get(\Automattic\WooCommerce\Blocks\Registry\Container $container) { } + } +} +namespace Automattic\WooCommerce\Blocks\Shipping { + /** + * Local Pickup Shipping Method. + */ + class PickupLocation extends \WC_Shipping_Method + { /** - * Filter the patterns that have external dependencies. + * Pickup locations. * - * @param array $patterns The patterns to filter. - * @return array + * @var array */ - private function filter_patterns(array $patterns) + protected $pickup_locations = []; + /** + * Cost + * + * @var string + */ + protected $cost = ''; + /** + * Constructor. + */ + public function __construct() { } /** - * Re-fetch the patterns when the WooCommerce plugin is updated. - * - * @param WP_Upgrader $upgrader_object WP_Upgrader instance. - * @param array $options Array of bulk item update data. - * - * @return void + * Init function. */ - public function fetch_patterns_on_plugin_update($upgrader_object, $options) + public function init() { } /** - * Reset the cached patterns to fetch them again from the PTK. + * Checks if a given address is complete. * - * @return void + * @param array $address Address. + * @return bool */ - public function flush_cached_patterns() + protected function has_valid_pickup_location($address) { } /** - * Reset the cached patterns and fetch them again from the PTK API. + * Calculate shipping. * - * @return void + * @param array $package Package information. */ - public function fetch_patterns() + public function calculate_shipping($package = array()) { } /** - * Check if the user allowed tracking. + * See if the method is available. * + * @param array $package Package information. * @return bool */ - private function allowed_tracking_is_enabled(): bool + public function is_available($package) { } /** - * Change the categories of the patterns to match the ones used in the CYS flow + * Translates meta data for the shipping method. * - * @param array $patterns The patterns to map categories for. - * @return array The patterns with the categories mapped. + * @param string $label Meta label. + * @param string $name Meta key. + * @param mixed $product Product if applicable. + * @return string */ - private function map_categories(array $patterns) + public function translate_meta_data($label, $name, $product) { } /** - * Check if the pattern has external dependencies. - * - * @param array $pattern The pattern to check. + * Admin options screen. * - * @return bool + * See also WC_Shipping_Method::admin_options(). */ - private function has_external_dependencies($pattern) + public function admin_options() { } } /** - * PatternRegistry class. + * ShippingController class. * * @internal */ - class PatternRegistry + class ShippingController { - const SLUG_REGEX = '/^[A-z0-9\/_-]+$/'; - const COMMA_SEPARATED_REGEX = '/[\s,]+/'; /** - * Returns pattern slugs with their localized labels for categorization. + * Script handle used for enqueueing the scripts needed for managing the Local Pickup Shipping Settings. + */ + private const LOCAL_PICKUP_ADMIN_JS_HANDLE = 'wc-shipping-method-pickup-location'; + /** + * Instance of the asset API. * - * Each key represents a unique pattern slug, while the value is the localized label. + * @var AssetApi + */ + protected $asset_api; + /** + * Instance of the asset data registry. * - * @return array + * @var AssetDataRegistry */ - private function get_category_labels() - { - } + protected $asset_data_registry; /** - * Register a block pattern. + * Whether local pickup is enabled. * - * @param string $source The pattern source. - * @param array $pattern_data The pattern data. + * @var bool + */ + private $local_pickup_enabled; + /** + * Constructor. * - * @return void + * @param AssetApi $asset_api Instance of the asset API. + * @param AssetDataRegistry $asset_data_registry Instance of the asset data registry. */ - public function register_block_pattern($source, $pattern_data) + public function __construct(\Automattic\WooCommerce\Blocks\Assets\Api $asset_api, \Automattic\WooCommerce\Blocks\Assets\AssetDataRegistry $asset_data_registry) { } /** - * Convert a kebab-case string to capital case. - * - * @param string $value The kebab-case string. - * - * @return string + * Initialization method. */ - private static function kebab_to_capital_case($value) + public function init() { } - } -} -namespace Automattic\WooCommerce\Blocks\Payments { - /** - * The Api class provides an interface to payment method registration. - * - * @since 2.6.0 - */ - class Api - { /** - * Reference to the PaymentMethodRegistry instance. + * Inject collection details onto the order received page. * - * @var PaymentMethodRegistry + * @param string $return_value Return value. + * @param \WC_Order $order Order object. + * @return string */ - private $payment_method_registry; + public function show_local_pickup_details($return_value, $order) + { + } /** - * Reference to the AssetDataRegistry instance. + * When using the cart and checkout blocks this method is used to adjust core shipping settings via a filter hook. * - * @var AssetDataRegistry + * @param array $settings The default WC shipping settings. + * @return array|mixed The filtered settings. */ - private $asset_registry; + public function remove_shipping_settings($settings) + { + } /** - * Constructor - * - * @param PaymentMethodRegistry $payment_method_registry An instance of Payment Method Registry. - * @param AssetDataRegistry $asset_registry Used for registering data to pass along to the request. + * Register Local Pickup settings for rest api. */ - public function __construct(\Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry, \Automattic\WooCommerce\Blocks\Assets\AssetDataRegistry $asset_registry) + public function register_settings() { } /** - * Initialize class features. + * Hydrate client settings */ - public function init() + public function hydrate_client_settings() { } /** - * Add payment method script handles as script dependencies. - * - * @param array $dependencies Array of script dependencies. - * @param string $handle Script handle. - * @return array + * Load admin scripts. */ - public function add_payment_method_script_dependencies($dependencies, $handle) + public function admin_scripts() { } /** - * Returns true if the payment gateway is enabled. - * - * @param object $gateway Payment gateway. - * @return boolean + * Registers the Local Pickup shipping method used by the Checkout Block. */ - private function is_payment_gateway_enabled($gateway) + public function register_local_pickup() { } /** - * Add payment method data to Asset Registry. + * Declares the Pickup Location shipping method as a Local Pickup method for WooCommerce. + * + * @param array $methods Shipping method ids. + * @return array */ - public function add_payment_method_script_data() + public function register_local_pickup_method($methods) { } /** - * Register payment method integrations bundled with blocks. + * Hides the shipping address on the order confirmation page when local pickup is selected. * - * @param PaymentMethodRegistry $payment_method_registry Payment method registry instance. + * @param array $pickup_methods Method ids. + * @return array */ - public function register_payment_method_integrations(\Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry) + public function hide_shipping_address_for_local_pickup($pickup_methods) { } /** - * Verify all dependencies of registered payment methods have been registered. - * If not, remove that payment method script from the list of dependencies - * of Cart and Checkout block scripts so it doesn't break the blocks and show - * an error in the admin. + * Everytime we save or update local pickup settings, we flush the shipping + * transient group. + * + * @param array $settings The setting array we're saving. + * @return array $settings The setting array we're saving. */ - public function verify_payment_methods_dependencies() + public function flush_cache($settings) { } - } - interface PaymentMethodTypeInterface extends \Automattic\WooCommerce\Blocks\Integrations\IntegrationInterface - { /** - * Returns if this payment method should be active. If false, the scripts will not be enqueued. + * Filter the location used for taxes based on the chosen pickup location. * - * @return boolean + * @param array $address Location args. + * @return array */ - public function is_active(); + public function filter_taxable_address($address) + { + } /** - * Returns an array of script handles to enqueue for this payment method in - * the frontend context + * Local Pickup requires all packages to support local pickup. This is because the entire order must be picked up + * so that all packages get the same tax rates applied during checkout. * - * @return string[] + * If a shipping package does not support local pickup (e.g. if disabled by an extension), this filters the option + * out for all packages. This will in turn disable the "pickup" toggle in Block Checkout. + * + * @param array $packages Array of shipping packages. + * @return array */ - public function get_payment_method_script_handles(); + public function filter_shipping_packages($packages) + { + } /** - * Returns an array of script handles to enqueue for this payment method in - * the admin context + * Remove shipping (i.e. delivery, not local pickup) if "Hide shipping costs until an address is entered" is enabled, + * and no address has been entered yet. * - * @return string[] + * Only applies to block checkout because pickup is chosen separately to shipping in that context. + * + * @param array $packages Array of shipping packages. + * @return array */ - public function get_payment_method_script_handles_for_admin(); + public function remove_shipping_if_no_address($packages) + { + } /** - * An array of key, value pairs of data made available to payment methods - * client side. + * Track local pickup settings changes via Store API * - * @return array + * @param bool $served Whether the request has already been served. + * @param \WP_REST_Response $result The response object. + * @param \WP_REST_Request $request The request object. + * @return bool */ - public function get_payment_method_data(); + public function track_local_pickup($served, $result, $request) + { + } /** - * Get array of supported features. + * Check if legacy local pickup is activated in any of the shipping zones or in the Rest of the World zone. * - * @return string[] + * @since 8.8.0 + * + * @return bool */ - public function get_supported_features(); + public static function is_legacy_local_pickup_active() + { + } } } -namespace Automattic\WooCommerce\Blocks\Payments\Integrations { +namespace Automattic\WooCommerce\Blocks { /** - * AbstractPaymentMethodType class. + * TemplateOptions class. * - * @since 2.6.0 + * @internal */ - abstract class AbstractPaymentMethodType implements \Automattic\WooCommerce\Blocks\Payments\PaymentMethodTypeInterface + class TemplateOptions { /** - * Payment method name defined by payment methods extending this class. - * - * @var string + * Initialization method. */ - protected $name = ''; + public function init() + { + } /** - * Settings from the WP options table + * Checks the old and current themes and determines if the "wc_blocks_use_blockified_product_grid_block_as_template" + * option need to be updated accordingly. * - * @var array + * @param string $old_name Old theme name. + * @param \WP_Theme $old_theme Instance of the old theme. + * @return void */ - protected $settings = []; + public function check_should_use_blockified_product_grid_templates($old_name, $old_theme) + { + } + } +} +namespace Automattic\WooCommerce\Blocks\Templates { + /** + * AbstractTemplate class. + * + * Shared logic for templates. + * + * @internal + */ + abstract class AbstractTemplate + { /** - * Get a setting from the settings array if set. + * The slug of the template. * - * @param string $name Setting name. - * @param mixed $default Value that is returned if the setting does not exist. - * @return mixed + * @var string */ - protected function get_setting($name, $default = '') - { - } + const SLUG = ''; /** - * Returns the name of the payment method. + * Whether this is a taxonomy template. + * + * @var bool */ - public function get_name() - { - } + public bool $is_taxonomy_template = false; /** - * Returns if this payment method should be active. If false, the scripts will not be enqueued. - * - * @return boolean + * Initialization method. */ - public function is_active() - { - } + abstract public function init(); /** - * Returns an array of script handles to enqueue for this payment method in - * the frontend context + * Should return the title of the template. * - * @return string[] + * @return string */ - public function get_payment_method_script_handles() - { - } + abstract public function get_template_title(); /** - * Returns an array of script handles to enqueue for this payment method in - * the admin context + * Should return the description of the template. * - * @return string[] + * @return string */ - public function get_payment_method_script_handles_for_admin() - { - } + abstract public function get_template_description(); + } + /** + * AbstractPageTemplate class. + * + * Shared logic for page templates. + * + * @internal + */ + abstract class AbstractPageTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplate + { /** - * Returns an array of supported features. - * - * @return string[] + * Initialization method. */ - public function get_supported_features() + public function init() { } /** - * An array of key, value pairs of data made available to payment methods - * client side. + * Returns the page object assigned to this template/page. * - * @return array + * @return \WP_Post|null Post object or null. */ - public function get_payment_method_data() - { - } + abstract protected function get_placeholder_page(); /** - * Returns an array of script handles to enqueue in the frontend context. - * - * Alias of get_payment_method_script_handles. Defined by IntegrationInterface. + * Should return true on pages/endpoints/routes where the template should be shown. * - * @return string[] + * @return boolean */ - public function get_script_handles() - { - } + abstract protected function is_active_template(); /** - * Returns an array of script handles to enqueue in the admin context. + * When the page should be displaying the template, add it to the hierarchy. * - * Alias of get_payment_method_script_handles_for_admin. Defined by IntegrationInterface. + * This places the template name e.g. `cart`, at the beginning of the template hierarchy array. The hook priority + * is 1 to ensure it runs first; other consumers e.g. extensions, could therefore inject their own template instead + * of this one when using the default priority of 10. * - * @return string[] + * @param array $templates Templates that match the pages_template_hierarchy. */ - public function get_editor_script_handles() + public function page_template_hierarchy($templates) { } /** - * An array of key, value pairs of data made available to the block on the client side. + * Forces the page title to match the template title when this template is active. * - * Alias of get_payment_method_data. Defined by IntegrationInterface. + * Only applies when hooked into `pre_get_document_title`. Most templates used for pages will not require this because + * the page title should be used instead. * - * @return array + * @param string $title Page title. + * @return string */ - public function get_script_data() + public function page_template_title($title) { } } /** - * Bank Transfer (BACS) payment method integration + * AbstractTemplateCompatibility class. * - * @since 3.0.0 + * To bridge the gap on compatibility with PHP hooks and blockified templates. + * + * @internal */ - final class BankTransfer extends \Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType + abstract class AbstractTemplateCompatibility { /** - * Payment method name/id/slug (matches id in WC_Gateway_BACS in core). - * - * @var string - */ - protected $name = \WC_Gateway_BACS::ID; - /** - * An instance of the Asset Api + * The data of supported hooks, containing the hook name, the block name, + * position, and the callbacks. * - * @var Api + * @var array $hook_data The hook data. */ - private $asset_api; + protected $hook_data; /** - * Constructor - * - * @param Api $asset_api An instance of Api. + * Initialization method. */ - public function __construct(\Automattic\WooCommerce\Blocks\Assets\Api $asset_api) + public function init() { } /** - * Initializes the payment method type. + * Update the render block data to inject our custom attribute needed to + * determine which blocks belong to an inherited Products block. + * + * @param array $parsed_block The block being rendered. + * @param array $source_block An un-modified copy of $parsed_block, as it appeared in the source content. + * @param WP_Block|null $parent_block If this is a nested block, a reference to the parent block. + * + * @return array */ - public function initialize() - { - } + abstract public function update_render_block_data($parsed_block, $source_block, $parent_block); /** - * Returns if this payment method should be active. If false, the scripts will not be enqueued. + * Inject hooks to rendered content of corresponding blocks. * - * @return boolean + * @param mixed $block_content The rendered block content. + * @param mixed $block The parsed block data. + * @return string */ - public function is_active() - { - } + abstract public function inject_hooks($block_content, $block); /** - * Returns an array of scripts/handles to be registered for this payment method. + * The hook data to inject to the rendered content of blocks. This also + * contains hooked functions that will be removed by remove_default_hooks. * - * @return array + * The array format: + * [ + * => [ + * block_names => [ , ... ], + * position => before|after, + * hooked => [ + * => , + * ... + * ], + * ], + * ] + * Where: + * - hook-name is the name of the hook that will be replaced. + * - block-names is the array block names that hook will be attached to. + * - position is the position of the block relative to the hook. + * - hooked is an array of functions hooked to the hook that will be + * replaced. The key is the function name and the value is the + * priority. */ - public function get_payment_method_script_handles() + abstract protected function set_hook_data(); + /** + * Remove the default callback added by WooCommerce. We replaced these + * callbacks by blocks so we have to remove them to prevent duplicated + * content. + */ + protected function remove_default_hooks() { } /** - * Returns an array of key=>value pairs of data made available to the payment methods script. + * Get the buffer content of the hooks to append/prepend to render content. * - * @return array + * @param array $hooks The hooks to be rendered. + * @param string $position The position of the hooks. + * + * @return string */ - public function get_payment_method_data() + protected function get_hooks_buffer($hooks, $position) { } } /** - * Cash on Delivery (COD) payment method integration + * AbstractTemplatePart class. * - * @since 3.0.0 + * Shared logic for templates parts. + * + * @internal */ - final class CashOnDelivery extends \Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType + abstract class AbstractTemplatePart extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplate { /** - * Payment method name/id/slug (matches id in WC_Gateway_COD in core). + * The template part area where the template part belongs. * * @var string */ - protected $name = \WC_Gateway_COD::ID; + public $template_area; + } + /** + * AbstractTemplateWithFallback class. + * + * Shared logic for templates with fallbacks. + * + * @internal + */ + abstract class AbstractTemplateWithFallback extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplate + { /** - * An instance of the Asset Api + * The fallback template to render if the existing template is not available. * - * @var Api + * @var string */ - private $asset_api; + public string $fallback_template; /** - * Constructor - * - * @param Api $asset_api An instance of Api. + * Initialization method. */ - public function __construct(\Automattic\WooCommerce\Blocks\Assets\Api $asset_api) + public function init() { } /** - * Initializes the payment method type. + * Add the fallback template to the hierarchy, right after the current template. + * + * @param array $templates Templates that match the taxonomy_template_hierarchy. */ - public function initialize() + public function template_hierarchy($templates) { } /** - * Returns if this payment method should be active. If false, the scripts will not be enqueued. - * - * @return boolean + * Render the block template. */ - public function is_active() - { - } + abstract public function render_block_template(); + } + /** + * ArchiveProductTemplatesCompatibility class. + * + * To bridge the gap on compatibility with PHP hooks and Product Archive blockified templates. + * + * @internal + */ + class ArchiveProductTemplatesCompatibility extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplateCompatibility + { /** - * Return enable_for_virtual option. - * - * @return boolean True if store allows COD payment for orders containing only virtual products. + * The custom ID of the loop item block as the replacement of the core/null block. */ - private function get_enable_for_virtual() - { - } + const LOOP_ITEM_ID = 'product-loop-item'; /** - * Return enable_for_methods option. + * The data of supported hooks, containing the hook name, the block name, + * position, and the callbacks. * - * @return array Array of shipping methods (string ids) that allow COD. (If empty, all support COD.) + * @var array $hook_data The hook data. */ - private function get_enable_for_methods() - { - } + protected $hook_data; /** - * Returns an array of scripts/handles to be registered for this payment method. + * Update the render block data to inject our custom attribute needed to + * determine which blocks belong to an inherited Products block. + * + * @param array $parsed_block The block being rendered. + * @param array $source_block An un-modified copy of $parsed_block, as it appeared in the source content. + * @param WP_Block|null $parent_block If this is a nested block, a reference to the parent block. * * @return array */ - public function get_payment_method_script_handles() + public function update_render_block_data($parsed_block, $source_block, $parent_block) { } /** - * Returns an array of key=>value pairs of data made available to the payment methods script. + * Inject hooks to rendered content of corresponding blocks. * - * @return array + * @param mixed $block_content The rendered block content. + * @param mixed $block The parsed block data. + * @return string */ - public function get_payment_method_data() + public function inject_hooks($block_content, $block) { } - } - /** - * Cheque payment method integration - * - * @since 2.6.0 - */ - final class Cheque extends \Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType - { - /** - * Payment method name defined by payment methods extending this class. - * - * @var string - */ - protected $name = \WC_Gateway_Cheque::ID; - /** - * An instance of the Asset Api - * - * @var Api - */ - private $asset_api; /** - * Constructor + * The hook data to inject to the rendered content of blocks. This also + * contains hooked functions that will be removed by remove_default_hooks. * - * @param Api $asset_api An instance of Api. + * The array format: + * [ + * => [ + * block_name => , + * position => before|after, + * hooked => [ + * => , + * ... + * ], + * permanently_removed_actions => [ + * + * ] + * ], + * ] + * Where: + * - hook-name is the name of the hook that will be replaced. + * - block-name is the name of the block that will replace the hook. + * - position is the position of the block relative to the hook. + * - hooked is an array of functions hooked to the hook that will be + * replaced. The key is the function name and the value is the + * priority. + * - permanently_removed_actions is an array of functions that we do not want to re-add after they have been removed to avoid duplicate content with the Products block and its inner blocks. */ - public function __construct(\Automattic\WooCommerce\Blocks\Assets\Api $asset_api) + protected function set_hook_data() { } /** - * Initializes the payment method type. + * Check if current page is a product archive template. */ - public function initialize() + private function is_archive_template() { } /** - * Returns if this payment method should be active. If false, the scripts will not be enqueued. + * Loop through inner blocks recursively to find the Products blocks that + * inherits query from template. * - * @return boolean + * @param array $block Parsed block data. */ - public function is_active() + private function inner_blocks_walker(&$block) { } /** - * Returns an array of scripts/handles to be registered for this payment method. - * - * @return array + * Restore default hooks except the ones that are not supposed to be re-added. */ - public function get_payment_method_script_handles() + private function restore_default_hooks() { } /** - * Returns an array of key=>value pairs of data made available to the payment methods script. + * Check whether block is within the product-query namespace. * - * @return array + * @param array $block Parsed block data. */ - public function get_payment_method_data() + private function is_block_within_namespace($block) { } - } - /** - * PayPal Standard payment method integration - * - * @since 2.6.0 - */ - final class PayPal extends \Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType - { /** - * Payment method name defined by payment methods extending this class. + * Check whether block has isInherited attribute assigned. * - * @var string + * @param array $block Parsed block data. */ - protected $name = \WC_Gateway_Paypal::ID; + private function is_block_inherited($block) + { + } /** - * An instance of the Asset Api + * The core/post-template has two different block names: + * - core/post-template when the wrapper is rendered. + * - core/null when the loop item is rendered. * - * @var Api + * @param array $block Parsed block data. */ - private $asset_api; + private function is_null_post_template($block) + { + } /** - * Constructor + * Check whether block is a Post template. * - * @param Api $asset_api An instance of Api. + * @param string $block_name Block name. */ - public function __construct(\Automattic\WooCommerce\Blocks\Assets\Api $asset_api) + private function is_post_template($block_name) { } /** - * Initializes the payment method type. + * Check whether block is a Product Template. + * + * @param string $block_name Block name. */ - public function initialize() + private function is_product_template($block_name) { } /** - * Returns if this payment method should be active. If false, the scripts will not be enqueued. + * Check if block is either a Post template or a Product Template * - * @return boolean + * @param string $block_name Block name. */ - public function is_active() + private function is_post_or_product_template($block_name) { } /** - * Returns an array of scripts/handles to be registered for this payment method. + * Check if the block is a Products block that inherits query from template. * - * @return array + * @param array $block Parsed block data. */ - public function get_payment_method_script_handles() + private function is_products_block_with_inherit_query($block) { } /** - * Returns an array of key=>value pairs of data made available to the payment methods script. + * Check if the block is a Product Collection block that inherits query from template. * - * @return array + * @param array $block Parsed block data. */ - public function get_payment_method_data() + private function is_product_collection_block_with_inherit_query($block) { } /** - * Returns an array of supported features. + * Recursively inject the custom attribute to all nested blocks. * - * @return string[] + * @param array $block Parsed block data. */ - public function get_supported_features() + private function inject_attribute(&$block) { } } -} -namespace Automattic\WooCommerce\Blocks\Payments { /** - * Class used for interacting with payment method types. + * CartTemplate class. * - * @since 2.6.0 + * @internal */ - final class PaymentMethodRegistry extends \Automattic\WooCommerce\Blocks\Integrations\IntegrationRegistry + class CartTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractPageTemplate { /** - * Integration identifier is used to construct hook names and is given when the integration registry is initialized. + * The slug of the template. * * @var string */ - protected $registry_identifier = 'payment_method_type'; + const SLUG = 'page-cart'; /** - * Retrieves all registered payment methods that are also active. + * Returns the title of the template. * - * @return PaymentMethodTypeInterface[] + * @return string */ - public function get_all_active_registered() + public function get_template_title() { } /** - * Gets an array of all registered payment method script handles, but only for active payment methods. + * Returns the description of the template. * - * @return string[] + * @return string */ - public function get_all_active_payment_method_script_dependencies() + public function get_template_description() { } /** - * Gets an array of all registered payment method script data, but only for active payment methods. + * Returns the page object assigned to this template/page. * - * @return array + * @return \WP_Post|null Post object or null. */ - public function get_all_registered_script_data() + protected function get_placeholder_page() { } - } -} -namespace Automattic\WooCommerce\Blocks { - /** - * Process the query data for filtering purposes. - */ - final class QueryFilters - { /** - * Initialization method. + * True when viewing the cart page or cart endpoint. * - * @internal + * @return boolean */ - public function init() + protected function is_active_template() { } /** - * Filter the posts clauses of the main query to support global filters. + * When the page should be displaying the template, add it to the hierarchy. * - * @param array $args Query args. - * @param \WP_Query $wp_query WP_Query object. - * @return array + * This places the template name e.g. `cart`, at the beginning of the template hierarchy array. The hook priority + * is 1 to ensure it runs first; other consumers e.g. extensions, could therefore inject their own template instead + * of this one when using the default priority of 10. + * + * @param array $templates Templates that match the pages_template_hierarchy. */ - public function main_query_filter($args, $wp_query) + public function page_template_hierarchy($templates) { } + } + /** + * CheckoutHeader Template class. + * + * @internal + */ + class CheckoutHeaderTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplatePart + { /** - * Add conditional query clauses based on the filter params in query vars. + * The slug of the template. * - * @param array $args Query args. - * @param \WP_Query $wp_query WP_Query object. - * @return array + * @var string */ - public function add_query_clauses($args, $wp_query) - { - } + const SLUG = 'checkout-header'; /** - * Get price data for current products. + * The template part area where the template part belongs. * - * @param array $query_vars The WP_Query arguments. - * @return object + * @var string */ - public function get_filtered_price($query_vars) + public $template_area = 'header'; + /** + * Initialization method. + */ + public function init() { } /** - * Get stock status counts for the current products. + * Returns the title of the template. * - * @param array $query_vars The WP_Query arguments. - * @return array status=>count pairs. + * @return string */ - public function get_stock_status_counts($query_vars) + public function get_template_title() { } /** - * Get rating counts for the current products. + * Returns the description of the template. * - * @param array $query_vars The WP_Query arguments. - * @return array rating=>count pairs. + * @return string */ - public function get_rating_counts($query_vars) + public function get_template_description() { } + } + /** + * CheckoutTemplate class. + * + * @internal + */ + class CheckoutTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractPageTemplate + { /** - * Get attribute counts for the current products. + * The slug of the template. * - * @param array $query_vars The WP_Query arguments. - * @param string $attribute_to_count Attribute taxonomy name. - * @return array termId=>count pairs. + * @var string + */ + const SLUG = 'page-checkout'; + /** + * Returns the title of the template. + * + * @return string */ - public function get_attribute_counts($query_vars, $attribute_to_count) + public function get_template_title() { } /** - * Add query clauses for stock filter. + * Returns the description of the template. * - * @param array $args Query args. - * @param \WP_Query $wp_query WP_Query object. - * @return array + * @return string */ - private function stock_filter_clauses($args, $wp_query) + public function get_template_description() { } /** - * Add query clauses for price filter. + * Returns the page object assigned to this template/page. * - * @param array $args Query args. - * @param \WP_Query $wp_query WP_Query object. - * @return array + * @return \WP_Post|null Post object or null. */ - private function price_filter_clauses($args, $wp_query) + protected function get_placeholder_page() { } /** - * Join wc_product_meta_lookup to posts if not already joined. + * True when viewing the checkout page or checkout endpoint. * - * @param string $sql SQL join. - * @return string + * @return boolean */ - private function append_product_sorting_table_join($sql) + protected function is_active_template() { } /** - * Generate calculate query by stock status. + * When the page should be displaying the template, add it to the hierarchy. * - * @param string $status status to calculate. - * @param string $product_query_sql product query for current filter state. - * @param array $stock_status_options available stock status options. + * This places the template name e.g. `cart`, at the beginning of the template hierarchy array. The hook priority + * is 1 to ensure it runs first; other consumers e.g. extensions, could therefore inject their own template instead + * of this one when using the default priority of 10. * - * @return false|string + * @param array $templates Templates that match the pages_template_hierarchy. */ - private function generate_stock_status_count_query($status, $product_query_sql, $stock_status_options) + public function page_template_hierarchy($templates) { } + } + /** + * ClassicTemplatesCompatibility class. + * + * To bridge the gap on compatibility with widget blocks and classic PHP core templates. + * + * @internal + */ + class ClassicTemplatesCompatibility + { /** - * Get query for price filters when dealing with displayed taxes. + * Instance of the asset data registry. * - * @param float $price_filter Price filter to apply. - * @param string $column Price being filtered (min or max). - * @param string $operator Comparison operator for column. - * @return string Constructed query. + * @var AssetDataRegistry */ - private function get_price_filter_query_for_displayed_taxes($price_filter, $column = 'min_price', $operator = '>=') - { - } + protected $asset_data_registry; /** - * If price filters need adjustment to work with displayed taxes, this returns true. - * - * This logic is used when prices are stored in the database differently to how they are being displayed, with regards - * to taxes. + * Constructor. * - * @return boolean + * @param AssetDataRegistry $asset_data_registry Instance of the asset data registry. */ - private function adjust_price_filters_for_displayed_taxes() + public function __construct(\Automattic\WooCommerce\Blocks\Assets\AssetDataRegistry $asset_data_registry) { } /** - * Adjusts a price filter based on a tax class and whether or not the amount includes or excludes taxes. - * - * This calculation logic is based on `wc_get_price_excluding_tax` and `wc_get_price_including_tax` in core. - * - * @param float $price_filter Price filter amount as entered. - * @param string $tax_class Tax class for adjustment. - * @return float + * Initialization method. */ - private function adjust_price_filter_for_tax_class($price_filter, $tax_class) + protected function init() { } /** - * Get attribute lookup table name. + * Executes the methods which set the necessary data needed for filter blocks to work correctly as widgets in Classic templates. * - * @return string + * @return void */ - private function get_lookup_table_name() + public function set_classic_template_data() { } /** - * Add query clauses for attribute filter. + * This method passes the value `has_filterable_products` to the front-end for product archive pages, + * so that widget product filter blocks are aware of the context they are in and can render accordingly. * - * @param array $args Query args. - * @param \WP_Query $wp_query WP_Query object. - * @return array + * @return void */ - private function attribute_filter_clauses($args, $wp_query) + public function set_filterable_product_data() { } /** - * Get an array of attributes and terms selected from query arguments. + * This method passes the value `is_rendering_php_template` to the front-end of Classic themes, + * so that widget product filter blocks are aware of how to filter the products. * - * @param array $query_vars The WP_Query arguments. - * @return array + * This data only matters on WooCommerce product archive pages. + * On non-archive pages the merchant could be using the All Products block which is not a PHP template. + * + * @return void */ - private function get_chosen_attributes($query_vars) + public function set_php_template_data() { } } -} -namespace Automattic\WooCommerce\Blocks\Registry { /** - * An abstract class for dependency types. - * - * Dependency types are instances of a dependency used by the - * Dependency Injection Container for storing dependencies to invoke as they - * are needed. + * ComingSoonSocialLinksTemplate class. * - * @since 2.5.0 + * @internal */ - abstract class AbstractDependencyType + class ComingSoonSocialLinksTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplatePart { /** - * Holds a callable or value provided for this type. + * The slug of the template. * - * @var mixed + * @var string */ - private $callable_or_value; + const SLUG = 'coming-soon-social-links'; /** - * Constructor + * The template part area where the template part belongs. * - * @param mixed $callable_or_value A callable or value for the dependency - * type instance. + * @var string */ - public function __construct($callable_or_value) + public $template_area = 'uncategorized'; + /** + * Initialization method. + */ + public function init() { } /** - * Resolver for the internal dependency value. - * - * @param Container $container The Dependency Injection Container. + * Returns the title of the template. * - * @return mixed + * @return string */ - protected function resolve_value(\Automattic\WooCommerce\Blocks\Registry\Container $container) + public function get_template_title() { } /** - * Retrieves the value stored internally for this DependencyType + * Returns the description of the template. * - * @param Container $container The Dependency Injection Container. + * @return string + */ + public function get_template_description() + { + } + /** + * Returns the page object assigned to this template/page. * - * @return void + * @return \WP_Post|null Post object or null. */ - abstract public function get(\Automattic\WooCommerce\Blocks\Registry\Container $container); + protected function get_placeholder_page() + { + } } /** - * A simple Dependency Injection Container - * - * This is used to manage dependencies used throughout the plugin. + * ComingSoonTemplate class. * - * @since 2.5.0 + * @internal */ - class Container + class ComingSoonTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractPageTemplate { /** - * A map of Dependency Type objects used to resolve dependencies. + * The slug of the template. * - * @var AbstractDependencyType[] + * @var string */ - private $registry = []; + const SLUG = 'coming-soon'; /** - * Public api for adding a factory to the container. - * - * Factory dependencies will have the instantiation callback invoked - * every time the dependency is requested. - * - * Typical Usage: - * - * ``` - * $container->register( MyClass::class, $container->factory( $mycallback ) ); - * ``` - * - * @param Closure $instantiation_callback This will be invoked when the - * dependency is required. It will - * receive an instance of this - * container so the callback can - * retrieve dependencies from the - * container. + * Returns the title of the template. * - * @return FactoryType An instance of the FactoryType dependency. + * @return string */ - public function factory(\Closure $instantiation_callback) + public function get_template_title() { } /** - * Interface for registering a new dependency with the container. - * - * By default, the $value will be added as a shared dependency. This means - * that it will be a single instance shared among any other classes having - * that dependency. - * - * If you want a new instance every time it's required, then wrap the value - * in a call to the factory method (@see Container::factory for example) - * - * Note: Currently if the provided id already is registered in the container, - * the provided value is ignored. + * Returns the description of the template. * - * @param string $id A unique string identifier for the provided value. - * Typically it's the fully qualified name for the - * dependency. - * @param mixed $value The value for the dependency. Typically, this is a - * closure that will create the class instance needed. + * @return string */ - public function register($id, $value) + public function get_template_description() { } /** - * Interface for retrieving the dependency stored in the container for the - * given identifier. - * - * @param string $id The identifier for the dependency being retrieved. - * @throws Exception If there is no dependency for the given identifier in - * the container. + * Returns the page object assigned to this template/page. * - * @return mixed Typically a class instance. + * @return \WP_Post|null Post object or null. */ - public function get($id) + protected function get_placeholder_page() { } - } - /** - * Definition for the FactoryType dependency type. - * - * @since 2.5.0 - */ - class FactoryType extends \Automattic\WooCommerce\Blocks\Registry\AbstractDependencyType - { /** - * Invokes and returns the value from the stored internal callback. - * - * @param Container $container An instance of the dependency injection - * container. + * True when viewing the coming soon page. * - * @return mixed + * @return boolean */ - public function get(\Automattic\WooCommerce\Blocks\Registry\Container $container) + protected function is_active_template() { } - } - /** - * A definition for the SharedType dependency type. - * - * @since 2.5.0 - */ - class SharedType extends \Automattic\WooCommerce\Blocks\Registry\AbstractDependencyType - { - /** - * Holds a cached instance of the value stored (or returned) internally. - * - * @var mixed - */ - private $shared_instance; /** - * Returns the internal stored and shared value after initial generation. + * Returns the font family for the body and heading. * - * @param Container $container An instance of the dependency injection - * container. + * When the current theme is not an FSE theme, we use the default fonts. + * When the current theme is an FSE theme, we use the fonts from the theme.json file if available except for the 'twentytwentyfour' theme. * - * @return mixed + * @return array */ - public function get(\Automattic\WooCommerce\Blocks\Registry\Container $container) + public static function get_font_families() { } } -} -namespace Automattic\WooCommerce\Blocks\Shipping { /** - * Local Pickup Shipping Method. + * ExternalProductAddToCartWithOptionsTemplate class. + * + * @internal */ - class PickupLocation extends \WC_Shipping_Method + class ExternalProductAddToCartWithOptionsTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplatePart { /** - * Pickup locations. + * The slug of the template. * - * @var array + * @var string */ - protected $pickup_locations = []; + const SLUG = 'external-product-add-to-cart-with-options'; /** - * Cost + * The template part area where the template part belongs. * * @var string */ - protected $cost = ''; + public $template_area = 'add-to-cart-with-options'; /** - * Constructor. + * Initialization method. */ - public function __construct() + public function init() { } /** - * Init function. + * Returns the title of the template. + * + * @return string */ - public function init() + public function get_template_title() { } /** - * Checks if a given address is complete. + * Returns the description of the template. * - * @param array $address Address. - * @return bool + * @return string */ - protected function has_valid_pickup_location($address) + public function get_template_description() { } + } + /** + * GroupedProductAddToCartWithOptionsTemplate class. + * + * @internal + */ + class GroupedProductAddToCartWithOptionsTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplatePart + { /** - * Calculate shipping. + * The slug of the template. * - * @param array $package Package information. + * @var string */ - public function calculate_shipping($package = array()) - { - } + const SLUG = 'grouped-product-add-to-cart-with-options'; /** - * See if the method is available. + * The template part area where the template part belongs. * - * @param array $package Package information. - * @return bool + * @var string */ - public function is_available($package) + public $template_area = 'add-to-cart-with-options'; + /** + * Initialization method. + */ + public function init() { } /** - * Translates meta data for the shipping method. + * Returns the title of the template. * - * @param string $label Meta label. - * @param string $name Meta key. - * @param mixed $product Product if applicable. * @return string */ - public function translate_meta_data($label, $name, $product) + public function get_template_title() { } /** - * Admin options screen. + * Returns the description of the template. * - * See also WC_Shipping_Method::admin_options(). + * @return string */ - public function admin_options() + public function get_template_description() { } } /** - * ShippingController class. + * MiniCartTemplate class. * * @internal */ - class ShippingController + class MiniCartTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplatePart { /** - * Script handle used for enqueueing the scripts needed for managing the Local Pickup Shipping Settings. + * The slug of the template. + * + * @var string */ - private const LOCAL_PICKUP_ADMIN_JS_HANDLE = 'wc-shipping-method-pickup-location'; + const SLUG = 'mini-cart'; /** - * Instance of the asset API. + * The template part area where the template part belongs. * - * @var AssetApi + * @var string */ - protected $asset_api; + public $template_area = 'mini-cart'; /** - * Instance of the asset data registry. + * Initialization method. + */ + public function init() + { + } + /** + * Returns the title of the template. * - * @var AssetDataRegistry + * @return string */ - protected $asset_data_registry; + public function get_template_title() + { + } /** - * Whether local pickup is enabled. + * Returns the description of the template. * - * @var bool + * @return string */ - private $local_pickup_enabled; + public function get_template_description() + { + } /** - * Constructor. + * Add Mini-Cart to the default template part areas. * - * @param AssetApi $asset_api Instance of the asset API. - * @param AssetDataRegistry $asset_data_registry Instance of the asset data registry. + * @param array $default_area_definitions An array of supported area objects. + * @return array The supported template part areas including the Mini-Cart one. */ - public function __construct(\Automattic\WooCommerce\Blocks\Assets\Api $asset_api, \Automattic\WooCommerce\Blocks\Assets\AssetDataRegistry $asset_data_registry) + public function register_mini_cart_template_part_area($default_area_definitions) { } + } + /** + * OrderConfirmationTemplate class. + * + * @internal + */ + class OrderConfirmationTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractPageTemplate + { + /** + * The slug of the template. + * + * @var string + */ + const SLUG = 'order-confirmation'; /** * Initialization method. */ @@ -102055,141 +105258,155 @@ public function init() { } /** - * Inject collection details onto the order received page. + * Returns the title of the template. * - * @param string $return_value Return value. - * @param \WC_Order $order Order object. * @return string */ - public function show_local_pickup_details($return_value, $order) + public function get_template_title() { } /** - * When using the cart and checkout blocks this method is used to adjust core shipping settings via a filter hook. + * Returns the description of the template. * - * @param array $settings The default WC shipping settings. - * @return array|mixed The filtered settings. + * @return string */ - public function remove_shipping_settings($settings) + public function get_template_description() { } /** - * Register Local Pickup settings for rest api. + * Remove edit page from admin bar. */ - public function register_settings() + public function remove_edit_page_link() { } /** - * Hydrate client settings + * Returns the page object assigned to this template/page. + * + * @return \WP_Post|null Post object or null. */ - public function hydrate_client_settings() + protected function get_placeholder_page() { } /** - * Load admin scripts. + * True when viewing the Order Received endpoint. + * + * @return boolean */ - public function admin_scripts() + protected function is_active_template() { } + } + /** + * ProductAttributeTemplate class. + * + * @internal + */ + class ProductAttributeTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplateWithFallback + { /** - * Registers the Local Pickup shipping method used by the Checkout Block. + * The slug of the template. + * + * @var string */ - public function register_local_pickup() - { - } + const SLUG = 'taxonomy-product_attribute'; /** - * Declares the Pickup Location shipping method as a Local Pickup method for WooCommerce. + * The template used as a fallback if that one is customized. * - * @param array $methods Shipping method ids. - * @return array + * @var string */ - public function register_local_pickup_method($methods) + public string $fallback_template = \Automattic\WooCommerce\Blocks\Templates\ProductCatalogTemplate::SLUG; + /** + * Returns the title of the template. + * + * @return string + */ + public function get_template_title() { } /** - * Hides the shipping address on the order confirmation page when local pickup is selected. + * Returns the description of the template. * - * @param array $pickup_methods Method ids. - * @return array + * @return string */ - public function hide_shipping_address_for_local_pickup($pickup_methods) + public function get_template_description() { } /** - * Everytime we save or update local pickup settings, we flush the shipping - * transient group. - * - * @param array $settings The setting array we're saving. - * @return array $settings The setting array we're saving. + * Renders the default block template from Woo Blocks if no theme templates exist. */ - public function flush_cache($settings) + public function render_block_template() { } /** - * Filter the location used for taxes based on the chosen pickup location. + * Renders the Product by Attribute template for product attributes taxonomy pages. * - * @param array $address Location args. - * @return array + * @param array $templates Templates that match the product attributes taxonomy. */ - public function filter_taxable_address($address) + public function template_hierarchy($templates) { } + } + /** + * ProductBrandTemplate class. + * + * @internal + */ + class ProductBrandTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplateWithFallback + { /** - * Local Pickup requires all packages to support local pickup. This is because the entire order must be picked up - * so that all packages get the same tax rates applied during checkout. + * The slug of the template. * - * If a shipping package does not support local pickup (e.g. if disabled by an extension), this filters the option - * out for all packages. This will in turn disable the "pickup" toggle in Block Checkout. + * @var string + */ + const SLUG = 'taxonomy-product_brand'; + /** + * The template used as a fallback if that one is customized. * - * @param array $packages Array of shipping packages. - * @return array + * @var string */ - public function filter_shipping_packages($packages) - { - } + public string $fallback_template = \Automattic\WooCommerce\Blocks\Templates\ProductCatalogTemplate::SLUG; /** - * Remove shipping (i.e. delivery, not local pickup) if "Hide shipping costs until an address is entered" is enabled, - * and no address has been entered yet. + * Whether this is a taxonomy template. * - * Only applies to block checkout because pickup is chosen separately to shipping in that context. + * @var bool + */ + public bool $is_taxonomy_template = true; + /** + * Returns the title of the template. * - * @param array $packages Array of shipping packages. - * @return array + * @return string */ - public function remove_shipping_if_no_address($packages) + public function get_template_title() { } /** - * Track local pickup settings changes via Store API + * Returns the description of the template. * - * @param bool $served Whether the request has already been served. - * @param \WP_REST_Response $result The response object. - * @param \WP_REST_Request $request The request object. - * @return bool + * @return string */ - public function track_local_pickup($served, $result, $request) + public function get_template_description() { } /** - * Check if legacy local pickup is activated in any of the shipping zones or in the Rest of the World zone. - * - * @since 8.8.0 - * - * @return bool + * Renders the default block template from Woo Blocks if no theme templates exist. */ - public static function is_legacy_local_pickup_active() + public function render_block_template() { } } -} -namespace Automattic\WooCommerce\Blocks { /** - * TemplateOptions class. + * ProductCatalogTemplate class. * * @internal */ - class TemplateOptions + class ProductCatalogTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplate { + /** + * The slug of the template. + * + * @var string + */ + const SLUG = 'archive-product'; /** * Initialization method. */ @@ -102197,66 +105414,102 @@ public function init() { } /** - * Checks the old and current themes and determines if the "wc_blocks_use_blockified_product_grid_block_as_template" - * option need to be updated accordingly. + * Returns the title of the template. * - * @param string $old_name Old theme name. - * @param \WP_Theme $old_theme Instance of the old theme. - * @return void + * @return string */ - public function check_should_use_blockified_product_grid_templates($old_name, $old_theme) + public function get_template_title() + { + } + /** + * Returns the description of the template. + * + * @return string + */ + public function get_template_description() + { + } + /** + * Renders the default block template from Woo Blocks if no theme templates exist. + */ + public function render_block_template() + { + } + /** + * Remove the template panel from the Sidebar of the Shop page because + * the Site Editor handles it. + * + * @see https://github.com/woocommerce/woocommerce-gutenberg-products-block/issues/6278 + * + * @param bool $is_support Whether the active theme supports block templates. + * + * @return bool + */ + public function remove_block_template_support_for_shop_page($is_support) { } } -} -namespace Automattic\WooCommerce\Blocks\Templates { /** - * AbstractTemplate class. - * - * Shared logic for templates. + * ProductCategoryTemplate class. * * @internal */ - abstract class AbstractTemplate + class ProductCategoryTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplateWithFallback { /** * The slug of the template. * * @var string */ - const SLUG = ''; + const SLUG = 'taxonomy-product_cat'; /** - * Whether this is a taxonomy template. + * The template used as a fallback if that one is customized. * - * @var bool + * @var string */ - public bool $is_taxonomy_template = false; + public string $fallback_template = \Automattic\WooCommerce\Blocks\Templates\ProductCatalogTemplate::SLUG; /** - * Initialization method. + * Whether this is a taxonomy template. + * + * @var bool */ - abstract public function init(); + public bool $is_taxonomy_template = true; /** - * Should return the title of the template. + * Returns the title of the template. * * @return string */ - abstract public function get_template_title(); + public function get_template_title() + { + } /** - * Should return the description of the template. + * Returns the description of the template. * * @return string */ - abstract public function get_template_description(); + public function get_template_description() + { + } + /** + * Renders the default block template from Woo Blocks if no theme templates exist. + */ + public function render_block_template() + { + } } /** - * AbstractPageTemplate class. - * - * Shared logic for page templates. + * ProductSearchResultsTemplate class. * * @internal */ - abstract class AbstractPageTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplate + class ProductSearchResultsTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplate { + /** + * The slug of the template. + * + * @var string + */ + const SLUG = 'product-search-results'; /** * Initialization method. */ @@ -102264,158 +105517,103 @@ public function init() { } /** - * Returns the page object assigned to this template/page. + * Returns the title of the template. * - * @return \WP_Post|null Post object or null. + * @return string */ - abstract protected function get_placeholder_page(); + public function get_template_title() + { + } /** - * Should return true on pages/endpoints/routes where the template should be shown. + * Returns the description of the template. * - * @return boolean + * @return string */ - abstract protected function is_active_template(); + public function get_template_description() + { + } /** - * When the page should be displaying the template, add it to the hierarchy. - * - * This places the template name e.g. `cart`, at the beginning of the template hierarchy array. The hook priority - * is 1 to ensure it runs first; other consumers e.g. extensions, could therefore inject their own template instead - * of this one when using the default priority of 10. - * - * @param array $templates Templates that match the pages_template_hierarchy. + * Renders the default block template from Woo Blocks if no theme templates exist. */ - public function page_template_hierarchy($templates) + public function render_block_template() { } /** - * Forces the page title to match the template title when this template is active. - * - * Only applies when hooked into `pre_get_document_title`. Most templates used for pages will not require this because - * the page title should be used instead. + * When the search is for products and a block theme is active, render the Product Search Template. * - * @param string $title Page title. - * @return string + * @param array $templates Templates that match the search hierarchy. */ - public function page_template_title($title) + public function update_search_template_hierarchy($templates) { } } /** - * AbstractTemplateCompatibility class. - * - * To bridge the gap on compatibility with PHP hooks and blockified templates. + * ProductTagTemplate class. * * @internal */ - abstract class AbstractTemplateCompatibility + class ProductTagTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplateWithFallback { /** - * The data of supported hooks, containing the hook name, the block name, - * position, and the callbacks. + * The slug of the template. * - * @var array $hook_data The hook data. + * @var string */ - protected $hook_data; + const SLUG = 'taxonomy-product_tag'; /** - * Initialization method. + * The template used as a fallback if that one is customized. + * + * @var string */ - public function init() - { - } + public string $fallback_template = \Automattic\WooCommerce\Blocks\Templates\ProductCatalogTemplate::SLUG; /** - * Update the render block data to inject our custom attribute needed to - * determine which blocks belong to an inherited Products block. - * - * @param array $parsed_block The block being rendered. - * @param array $source_block An un-modified copy of $parsed_block, as it appeared in the source content. - * @param WP_Block|null $parent_block If this is a nested block, a reference to the parent block. + * Whether this is a taxonomy template. * - * @return array + * @var bool */ - abstract public function update_render_block_data($parsed_block, $source_block, $parent_block); + public bool $is_taxonomy_template = true; /** - * Inject hooks to rendered content of corresponding blocks. + * Returns the title of the template. * - * @param mixed $block_content The rendered block content. - * @param mixed $block The parsed block data. * @return string */ - abstract public function inject_hooks($block_content, $block); + public function get_template_title() + { + } /** - * The hook data to inject to the rendered content of blocks. This also - * contains hooked functions that will be removed by remove_default_hooks. + * Returns the description of the template. * - * The array format: - * [ - * => [ - * block_names => [ , ... ], - * position => before|after, - * hooked => [ - * => , - * ... - * ], - * ], - * ] - * Where: - * - hook-name is the name of the hook that will be replaced. - * - block-names is the array block names that hook will be attached to. - * - position is the position of the block relative to the hook. - * - hooked is an array of functions hooked to the hook that will be - * replaced. The key is the function name and the value is the - * priority. - */ - abstract protected function set_hook_data(); - /** - * Remove the default callback added by WooCommerce. We replaced these - * callbacks by blocks so we have to remove them to prevent duplicated - * content. + * @return string */ - protected function remove_default_hooks() + public function get_template_description() { } /** - * Get the buffer content of the hooks to append/prepend to render content. - * - * @param array $hooks The hooks to be rendered. - * @param string $position The position of the hooks. - * - * @return string + * Renders the default block template from Woo Blocks if no theme templates exist. */ - protected function get_hooks_buffer($hooks, $position) + public function render_block_template() { } } /** - * AbstractTemplatePart class. - * - * Shared logic for templates parts. + * SimpleProductAddToCartWithOptionsTemplate class. * * @internal */ - abstract class AbstractTemplatePart extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplate + class SimpleProductAddToCartWithOptionsTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplatePart { /** - * The template part area where the template part belongs. + * The slug of the template. * * @var string */ - public $template_area; - } - /** - * AbstractTemplateWithFallback class. - * - * Shared logic for templates with fallbacks. - * - * @internal - */ - abstract class AbstractTemplateWithFallback extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplate - { + const SLUG = 'simple-product-add-to-cart-with-options'; /** - * The fallback template to render if the existing template is not available. + * The template part area where the template part belongs. * * @var string */ - public string $fallback_template; + public $template_area = 'add-to-cart-with-options'; /** * Initialization method. */ @@ -102423,264 +105621,261 @@ public function init() { } /** - * Add the fallback template to the hierarchy, right after the current template. + * Returns the title of the template. * - * @param array $templates Templates that match the taxonomy_template_hierarchy. + * @return string */ - public function template_hierarchy($templates) + public function get_template_title() { } /** - * Render the block template. + * Returns the description of the template. + * + * @return string */ - abstract public function render_block_template(); + public function get_template_description() + { + } } /** - * ArchiveProductTemplatesCompatibility class. - * - * To bridge the gap on compatibility with PHP hooks and Product Archive blockified templates. + * SingleProductTemplate class. * * @internal */ - class ArchiveProductTemplatesCompatibility extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplateCompatibility + class SingleProductTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplate { + use \Automattic\WooCommerce\Blocks\Utils\BlocksSharedState; /** - * The custom ID of the loop item block as the replacement of the core/null block. - */ - const LOOP_ITEM_ID = 'product-loop-item'; - /** - * The data of supported hooks, containing the hook name, the block name, - * position, and the callbacks. + * The slug of the template. * - * @var array $hook_data The hook data. + * @var string */ - protected $hook_data; + const SLUG = 'single-product'; /** - * Update the render block data to inject our custom attribute needed to - * determine which blocks belong to an inherited Products block. - * - * @param array $parsed_block The block being rendered. - * @param array $source_block An un-modified copy of $parsed_block, as it appeared in the source content. - * @param WP_Block|null $parent_block If this is a nested block, a reference to the parent block. - * - * @return array + * Initialization method. */ - public function update_render_block_data($parsed_block, $source_block, $parent_block) + public function init() { } /** - * Inject hooks to rendered content of corresponding blocks. + * Returns the title of the template. * - * @param mixed $block_content The rendered block content. - * @param mixed $block The parsed block data. * @return string */ - public function inject_hooks($block_content, $block) + public function get_template_title() { } /** - * The hook data to inject to the rendered content of blocks. This also - * contains hooked functions that will be removed by remove_default_hooks. + * Returns the description of the template. * - * The array format: - * [ - * => [ - * block_name => , - * position => before|after, - * hooked => [ - * => , - * ... - * ], - * permanently_removed_actions => [ - * - * ] - * ], - * ] - * Where: - * - hook-name is the name of the hook that will be replaced. - * - block-name is the name of the block that will replace the hook. - * - position is the position of the block relative to the hook. - * - hooked is an array of functions hooked to the hook that will be - * replaced. The key is the function name and the value is the - * priority. - * - permanently_removed_actions is an array of functions that we do not want to re-add after they have been removed to avoid duplicate content with the Products block and its inner blocks. + * @return string */ - protected function set_hook_data() + public function get_template_description() { } /** - * Check if current page is a product archive template. + * Renders the default block template from Woo Blocks if no theme templates exist. */ - private function is_archive_template() + public function render_block_template() { } /** - * Loop through inner blocks recursively to find the Products blocks that - * inherits query from template. + * Add the block template objects to be used. * - * @param array $block Parsed block data. + * @param array $query_result Array of template objects. + * @return array */ - private function inner_blocks_walker(&$block) + public function update_single_product_content($query_result) { } /** - * Restore default hooks except the ones that are not supposed to be re-added. + * Replace the first single product template block with the password form. Remove all other single product template blocks. + * + * @param array $parsed_blocks Array of parsed block objects. + * @param boolean $is_already_replaced If the password form has already been added. + * @return array Parsed blocks */ - private function restore_default_hooks() + private static function replace_first_single_product_template_block_with_password_form($parsed_blocks, $is_already_replaced) { } /** - * Check whether block is within the product-query namespace. + * Add password form to the Single Product Template. * - * @param array $block Parsed block data. + * @param string $content The content of the template. + * @return string */ - private function is_block_within_namespace($block) + public static function add_password_form($content) { } + } + /** + * SingleProductTemplateCompatibility class. + * + * To bridge the gap on compatibility with PHP hooks and Single Product templates. + * + * @internal + */ + class SingleProductTemplateCompatibility extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplateCompatibility + { + const IS_FIRST_BLOCK = '__wooCommerceIsFirstBlock'; + const IS_LAST_BLOCK = '__wooCommerceIsLastBlock'; /** - * Check whether block has isInherited attribute assigned. + * Inject hooks to rendered content of corresponding blocks. * - * @param array $block Parsed block data. + * @param mixed $block_content The rendered block content. + * @param mixed $block The parsed block data. + * + * @return string */ - private function is_block_inherited($block) + public function inject_hooks($block_content, $block) { } /** - * The core/post-template has two different block names: - * - core/post-template when the wrapper is rendered. - * - core/null when the loop item is rendered. + * Inject custom hooks to the first and last blocks. + * Since that there is a custom logic for the first and last block, we have to inject the hooks manually. + * The first block supports the following hooks: + * woocommerce_before_single_product + * woocommerce_before_single_product_summary * - * @param array $block Parsed block data. + * The last block supports the following hooks: + * woocommerce_after_single_product + * + * @param mixed $block_content The rendered block content. + * @param mixed $block The parsed block data. + * @param array $block_hooks The hooks that should be injected to the block. + * + * @return string */ - private function is_null_post_template($block) + private function inject_hook_to_first_and_last_blocks($block_content, $block, $block_hooks) { } /** - * Check whether block is a Post template. + * Update the render block data to inject our custom attribute needed to + * determine which is the first block of the Single Product Template. * - * @param string $block_name Block name. + * @param array $parsed_block The block being rendered. + * @param array $source_block An un-modified copy of $parsed_block, as it appeared in the source content. + * @param WP_Block|null $parent_block If this is a nested block, a reference to the parent block. + * + * @return array */ - private function is_post_template($block_name) + public function update_render_block_data($parsed_block, $source_block, $parent_block) { } /** - * Check whether block is a Product Template. - * - * @param string $block_name Block name. + * Set supported hooks. */ - private function is_product_template($block_name) + protected function set_hook_data() { } /** - * Check if block is either a Post template or a Product Template + * Add compatibility layer to the first and last block of the Single Product Template. * - * @param string $block_name Block name. + * @param string $template_content Template. + * @return string */ - private function is_post_or_product_template($block_name) + public static function add_compatibility_layer($template_content) { } /** - * Check if the block is a Products block that inherits query from template. + * For compatibility reason, we need to wrap the Single Product template in a div with specific class. + * For more details, see https://github.com/woocommerce/woocommerce-blocks/issues/8314. * - * @param array $block Parsed block data. + * @param string $template_content Template Content. + * @return array Wrapped template content inside a div. */ - private function is_products_block_with_inherit_query($block) + private static function wrap_single_product_template($template_content) { } /** - * Check if the block is a Product Collection block that inherits query from template. + * Add custom attributes to the first group block and last group block that wrap Single Product Template blocks. * - * @param array $block Parsed block data. + * @param array $wrapped_blocks Wrapped blocks. + * @return array */ - private function is_product_collection_block_with_inherit_query($block) + private static function inject_custom_attributes_to_first_and_last_block_single_product_template($wrapped_blocks) { } /** - * Recursively inject the custom attribute to all nested blocks. + * Wrap all the blocks inside the template in a group block. * - * @param array $block Parsed block data. + * @param array $blocks Array of parsed block objects. + * @return array Group block with the blocks inside. */ - private function inject_attribute(&$block) + private static function create_wrap_block_group($blocks) { } - } - /** - * CartTemplate class. - * - * @internal - */ - class CartTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractPageTemplate - { - /** - * The slug of the template. - * - * @var string - */ - const SLUG = 'page-cart'; /** - * Returns the title of the template. + * Check if the Single Product template has a single product template block: + * woocommerce/product-gallery-image, woocommerce/product-details, woocommerce/add-to-cart-form, etc. * - * @return string + * @param array $parsed_blocks Array of parsed block objects. + * @return bool True if the template has a single product template block, false otherwise. */ - public function get_template_title() + private static function has_single_product_template_blocks($parsed_blocks) { } /** - * Returns the description of the template. + * Group blocks in this way: + * B1 + TP1 + B2 + B3 + B4 + TP2 + B5 + * (B = Block, TP = Template Part) + * becomes: + * [[B1], [TP1], [B2, B3, B4], [TP2], [B5]] * - * @return string + * @param array $parsed_blocks Array of parsed block objects. + * @return array Array of blocks grouped by template part. */ - public function get_template_description() + private static function group_blocks($parsed_blocks) { } /** - * Returns the page object assigned to this template/page. + * Inject the hooks after the div wrapper. * - * @return \WP_Post|null Post object or null. + * @param string $block_content Block Content. + * @param array $hooks Hooks to inject. + * @return array */ - protected function get_placeholder_page() + private function inject_hooks_after_the_wrapper($block_content, $hooks) { } /** - * True when viewing the cart page or cart endpoint. + * Plain custom HTML block is parsed as block with an empty blockName with a filled innerHTML. * - * @return boolean + * @param array $block Parse block. + * @return bool */ - protected function is_active_template() + private static function is_custom_html($block) { } /** - * When the page should be displaying the template, add it to the hierarchy. - * - * This places the template name e.g. `cart`, at the beginning of the template hierarchy array. The hook priority - * is 1 to ensure it runs first; other consumers e.g. extensions, could therefore inject their own template instead - * of this one when using the default priority of 10. + * Serialize template. * - * @param array $templates Templates that match the pages_template_hierarchy. + * @param array $parsed_blocks Parsed blocks. + * @return string */ - public function page_template_hierarchy($templates) + private static function serialize_blocks($parsed_blocks) { } } /** - * CheckoutHeader Template class. + * VariableProductAddToCartWithOptionsTemplate class. * * @internal */ - class CheckoutHeaderTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplatePart + class VariableProductAddToCartWithOptionsTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplatePart { /** * The slug of the template. * * @var string */ - const SLUG = 'checkout-header'; + const SLUG = 'variable-product-add-to-cart-with-options'; /** * The template part area where the template part belongs. * * @var string */ - public $template_area = 'header'; + public $template_area = 'add-to-cart-with-options'; /** * Initialization method. */ @@ -102704,6272 +105899,6798 @@ public function get_template_description() { } } +} +namespace Automattic\WooCommerce\Blocks\Utils { /** - * CheckoutTemplate class. - * - * @internal + * Utility methods used for serving block templates from WooCommerce Blocks. + * {@internal This class and its methods should only be used within the BlockTemplateController.php and is not intended for public use.} */ - class CheckoutTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractPageTemplate + class BlockTemplateUtils { /** - * The slug of the template. + * Directory names for block templates * - * @var string + * Directory names conventions for block templates have changed with Gutenberg 12.1.0, + * however, for backwards-compatibility, we also keep the older conventions, prefixed + * with `DEPRECATED_`. + * + * @var array { + * @var string DEPRECATED_TEMPLATES Old directory name of the block templates directory. + * @var string DEPRECATED_TEMPLATE_PARTS Old directory name of the block template parts directory. + * @var string TEMPLATES_DIR_NAME Directory name of the block templates directory. + * @var string TEMPLATE_PARTS_DIR_NAME Directory name of the block template parts directory. + * } */ - const SLUG = 'page-checkout'; + const DIRECTORY_NAMES = array('DEPRECATED_TEMPLATES' => 'block-templates', 'DEPRECATED_TEMPLATE_PARTS' => 'block-template-parts', 'TEMPLATES' => 'templates', 'TEMPLATE_PARTS' => 'parts'); + const TEMPLATES_ROOT_DIR = 'templates'; /** - * Returns the title of the template. + * WooCommerce plugin slug * - * @return string + * This is used to save templates to the DB which are stored against this value in the wp_terms table. + * + * @var string */ - public function get_template_title() - { - } + const PLUGIN_SLUG = 'woocommerce/woocommerce'; /** - * Returns the description of the template. + * Deprecated WooCommerce plugin slug * - * @return string + * For supporting users who have customized templates under the incorrect plugin slug during the first release. + * More context found here: https://github.com/woocommerce/woocommerce-gutenberg-products-block/issues/5423. + * + * @var string */ - public function get_template_description() - { - } + const DEPRECATED_PLUGIN_SLUG = 'woocommerce'; /** - * Returns the page object assigned to this template/page. + * Returns the template matching the slug * - * @return \WP_Post|null Post object or null. + * @param string $template_slug Slug of the template to retrieve. + * + * @return AbstractTemplate|AbstractTemplatePart|null */ - protected function get_placeholder_page() + public static function get_template($template_slug) { } /** - * True when viewing the checkout page or checkout endpoint. + * Returns an array containing the references of + * the passed blocks and their inner blocks. * - * @return boolean + * @param array $blocks array of blocks. + * + * @return array block references to the passed blocks and their inner blocks. */ - protected function is_active_template() + public static function flatten_blocks(&$blocks) { } /** - * When the page should be displaying the template, add it to the hierarchy. + * Parses wp_template content and injects the current theme's + * stylesheet as a theme attribute into each wp_template_part * - * This places the template name e.g. `cart`, at the beginning of the template hierarchy array. The hook priority - * is 1 to ensure it runs first; other consumers e.g. extensions, could therefore inject their own template instead - * of this one when using the default priority of 10. + * @param string $template_content serialized wp_template content. * - * @param array $templates Templates that match the pages_template_hierarchy. + * @return string Updated wp_template content. */ - public function page_template_hierarchy($templates) + public static function inject_theme_attribute_in_content($template_content) { } - } - /** - * ClassicTemplatesCompatibility class. - * - * To bridge the gap on compatibility with widget blocks and classic PHP core templates. - * - * @internal - */ - class ClassicTemplatesCompatibility - { /** - * Instance of the asset data registry. + * Build a unified template object based a post Object. + * Important: This method is an almost identical duplicate from wp-includes/block-template-utils.php as it was not intended for public use. It has been modified to build templates from plugins rather than themes. * - * @var AssetDataRegistry - */ - protected $asset_data_registry; - /** - * Constructor. + * @param \WP_Post $post Template post. * - * @param AssetDataRegistry $asset_data_registry Instance of the asset data registry. + * @return \WP_Block_Template|\WP_Error Template. */ - public function __construct(\Automattic\WooCommerce\Blocks\Assets\AssetDataRegistry $asset_data_registry) + public static function build_template_result_from_post($post) { } /** - * Initialization method. + * Build a unified template object based on a theme file. + * + * @internal Important: This method is an almost identical duplicate from wp-includes/block-template-utils.php as it was not intended for public use. It has been modified to build templates from plugins rather than themes. + * + * @param array|object $template_file Theme file. + * @param string $template_type wp_template or wp_template_part. + * + * @return \WP_Block_Template Template. */ - protected function init() + public static function build_template_result_from_file($template_file, $template_type) { } /** - * Executes the methods which set the necessary data needed for filter blocks to work correctly as widgets in Classic templates. + * Build a new template object so that we can make Woo Blocks default templates available in the current theme should they not have any. * - * @return void + * @param string $template_file Block template file path. + * @param string $template_type wp_template or wp_template_part. + * @param string $template_slug Block template slug e.g. single-product. + * @param bool $template_is_from_theme If the block template file is being loaded from the current theme instead of Woo Blocks. + * + * @return object Block template object. */ - public function set_classic_template_data() + public static function create_new_block_template_object($template_file, $template_type, $template_slug, $template_is_from_theme = false) { } /** - * This method passes the value `has_filterable_products` to the front-end for product archive pages, - * so that widget product filter blocks are aware of the context they are in and can render accordingly. + * Finds all nested template part file paths in a theme's directory. * - * @return void + * @param string $template_type wp_template or wp_template_part. + * @return array $path_list A list of paths to all template part files. */ - public function set_filterable_product_data() + public static function get_template_paths($template_type) { } /** - * This method passes the value `is_rendering_php_template` to the front-end of Classic themes, - * so that widget product filter blocks are aware of how to filter the products. + * Gets the directory where templates of a specific template type can be found. * - * This data only matters on WooCommerce product archive pages. - * On non-archive pages the merchant could be using the All Products block which is not a PHP template. + * @param string $template_type wp_template or wp_template_part. * - * @return void + * @return string */ - public function set_php_template_data() + public static function get_templates_directory($template_type = 'wp_template') { } - } - /** - * ComingSoonSocialLinksTemplate class. - * - * @internal - */ - class ComingSoonSocialLinksTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplatePart - { - /** - * The slug of the template. - * - * @var string - */ - const SLUG = 'coming-soon-social-links'; /** - * The template part area where the template part belongs. + * Returns template title. * - * @var string - */ - public $template_area = 'uncategorized'; - /** - * Initialization method. + * @param string $template_slug The template slug (e.g. single-product). + * @return string Human friendly title. */ - public function init() + public static function get_block_template_title($template_slug) { } /** - * Returns the title of the template. + * Returns template description. * - * @return string + * @param string $template_slug The template slug (e.g. single-product). + * @return string Template description. */ - public function get_template_title() + public static function get_block_template_description($template_slug) { } /** - * Returns the description of the template. + * Returns area for template parts. * - * @return string + * @param string $template_slug The template part slug (e.g. mini-cart). + * @param string $template_type Either `wp_template` or `wp_template_part`. + * @return string Template part area. */ - public function get_template_description() + public static function get_block_template_area($template_slug, $template_type) { } /** - * Returns the page object assigned to this template/page. + * Converts template paths into a slug * - * @return \WP_Post|null Post object or null. + * @param string $path The template's path. + * @return string slug */ - protected function get_placeholder_page() + public static function generate_template_slug_from_path($path) { } - } - /** - * ComingSoonTemplate class. - * - * @internal - */ - class ComingSoonTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractPageTemplate - { /** - * The slug of the template. + * Gets the first matching template part within themes directories * - * @var string - */ - const SLUG = 'coming-soon'; - /** - * Returns the title of the template. + * Since [Gutenberg 12.1.0](https://github.com/WordPress/gutenberg/releases/tag/v12.1.0), the conventions for + * block templates and parts directory has changed from `block-templates` and `block-templates-parts` + * to `templates` and `parts` respectively. * - * @return string + * This function traverses all possible combinations of directory paths where a template or part + * could be located and returns the first one which is readable, prioritizing the new convention + * over the deprecated one, but maintaining that one for backwards compatibility. + * + * @param string $template_slug The slug of the template (i.e. without the file extension). + * @param string $template_type Either `wp_template` or `wp_template_part`. + * + * @return string|null The matched path or `null` if no match was found. */ - public function get_template_title() + public static function get_theme_template_path($template_slug, $template_type = 'wp_template') { } /** - * Returns the description of the template. + * Check if the theme has a template. So we know if to load our own in or not. * - * @return string + * @param string $template_name name of the template file without .html extension e.g. 'single-product'. + * @return boolean */ - public function get_template_description() + public static function theme_has_template($template_name) { } /** - * Returns the page object assigned to this template/page. + * Check if the theme has a template. So we know if to load our own in or not. * - * @return \WP_Post|null Post object or null. + * @param string $template_name name of the template file without .html extension e.g. 'single-product'. + * @return boolean */ - protected function get_placeholder_page() + public static function theme_has_template_part($template_name) { } /** - * True when viewing the coming soon page. + * Checks to see if they are using a compatible version of WP, or if not they have a compatible version of the Gutenberg plugin installed. * + * @param string $template_type Optional. Template type: `wp_template` or `wp_template_part`. + * Default `wp_template`. * @return boolean */ - protected function is_active_template() + public static function supports_block_templates($template_type = 'wp_template') { } /** - * Returns the font family for the body and heading. - * - * When the current theme is not an FSE theme, we use the default fonts. - * When the current theme is an FSE theme, we use the fonts from the theme.json file if available except for the 'twentytwentyfour' theme. + * Gets the `archive-product` fallback template stored on the db for a given slug. * - * @return array + * @param string $template_slug Slug to check for fallbacks. + * @param array $db_templates Templates that have already been found on the db. + * @return boolean|object */ - public static function get_font_families() + public static function get_fallback_template_from_db($template_slug, $db_templates) { } - } - /** - * ExternalProductAddToCartWithOptionsTemplate class. - * - * @internal - */ - class ExternalProductAddToCartWithOptionsTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplatePart - { /** - * The slug of the template. + * Removes templates from the theme or WooCommerce which have the same slug + * as template saved in the database with the `woocommerce/woocommerce` theme. + * Before WC migrated to the Template Registration API from WordPress, templates + * were saved in the database with the `woocommerce/woocommerce` theme instead + * of the theme's slug. * - * @var string - */ - const SLUG = 'external-product-add-to-cart-with-options'; - /** - * The template part area where the template part belongs. + * @param \WP_Block_Template[]|\stdClass[] $templates List of templates to run the filter on. * - * @var string - */ - public $template_area = 'add-to-cart-with-options'; - /** - * Initialization method. + * @return array List of templates with duplicates removed. The customised alternative is preferred over the theme default. */ - public function init() + public static function remove_templates_with_custom_alternative($templates) { } /** - * Returns the title of the template. + * Removes customized templates that shouldn't be available. That means customized templates based on the + * WooCommerce default template when there is a customized template based on the theme template. * - * @return string + * @param \WP_Block_Template[]|\stdClass[] $templates List of templates to run the filter on. + * + * @return array Filtered list of templates with only relevant templates available. */ - public function get_template_title() + public static function remove_duplicate_customized_templates($templates) { } /** - * Returns the description of the template. + * Returns whether the blockified templates should be used or not. + * If the option is not stored on the db, we need to check if the current theme is a block one or not. * - * @return string + * @return boolean */ - public function get_template_description() + public static function should_use_blockified_product_grid_templates() { } - } - /** - * GroupedProductAddToCartWithOptionsTemplate class. - * - * @internal - */ - class GroupedProductAddToCartWithOptionsTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplatePart - { /** - * The slug of the template. + * Determines whether the provided $blocks contains any of the $block_names, + * or if they contain a pattern that contains any of the $block_names. * - * @var string + * @param string[] $block_names Full block types to look for. + * @param WP_Block[] $blocks Array of block objects. + * @return bool Whether the content contains the specified block. */ - const SLUG = 'grouped-product-add-to-cart-with-options'; + public static function has_block_including_patterns($block_names, $blocks) + { + } /** - * The template part area where the template part belongs. + * Returns whether the passed `$template` has the legacy template block. * - * @var string + * @param object $template The template object. + * @return boolean */ - public $template_area = 'add-to-cart-with-options'; + public static function template_has_legacy_template_block($template) + { + } /** - * Initialization method. + * Updates the title, description and area of a template to the correct values and to make them more user-friendly. + * For example, instead of: + * - Title: `Tag (product_tag)` + * - Description: `Displays taxonomy: Tag.` + * we display: + * - Title: `Products by Tag` + * - Description: `Displays products filtered by a tag.`. + * + * @param WP_Block_Template $template The template object. + * @param string $template_type wp_template or wp_template_part. + * + * @return WP_Block_Template */ - public function init() + public static function update_template_data($template, $template_type) { } /** - * Returns the title of the template. + * Gets the templates saved in the database. * - * @return string + * @param array $slugs An array of slugs to retrieve templates for. + * @param string $template_type wp_template or wp_template_part. + * + * @return \WP_Block_Template[] An array of found templates. */ - public function get_template_title() + public static function get_block_templates_from_db($slugs = array(), $template_type = 'wp_template') { } /** - * Returns the description of the template. + * Gets the template part by slug * - * @return string + * @param string $slug The template part slug. + * + * @return string The template part content. */ - public function get_template_description() + public static function get_template_part($slug) { } } /** - * MiniCartTemplate class. + * BlocksWpQuery query. * - * @internal + * Wrapper for WP Query with additional helper methods. + * Allows query args to be set and parsed without doing running it, so that a cache can be used. + * + * @deprecated 2.5.0 */ - class MiniCartTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplatePart + class BlocksWpQuery extends \WP_Query { /** - * The slug of the template. + * Constructor. * - * @var string - */ - const SLUG = 'mini-cart'; - /** - * The template part area where the template part belongs. + * Sets up the WordPress query, if parameter is not empty. * - * @var string - */ - public $template_area = 'mini-cart'; - /** - * Initialization method. - */ - public function init() - { - } - /** - * Returns the title of the template. + * Unlike the constructor in WP_Query, this does not RUN the query. * - * @return string + * @param string|array $query URL query string or array of vars. */ - public function get_template_title() + public function __construct($query = '') { } /** - * Returns the description of the template. + * Get cached posts, if a cache exists. * - * @return string - */ - public function get_template_description() - { - } - /** - * Add Mini-Cart to the default template part areas. + * A hash is generated using the array of query_vars. If doing custom queries via filters such as posts_where + * (where the SQL query is manipulated directly) you can still ensure there is a unique hash by injecting custom + * query vars via the parse_query filter. For example: * - * @param array $default_area_definitions An array of supported area objects. - * @return array The supported template part areas including the Mini-Cart one. + * add_filter( 'parse_query', function( $wp_query ) { + * $wp_query->query_vars['my_custom_query_var'] = true; + * } ); + * + * Doing so won't have any negative effect on the query itself, and it will cause the hash to change. + * + * @param string $transient_version Transient version to allow for invalidation. + * @return WP_Post[]|int[] Array of post objects or post IDs. */ - public function register_mini_cart_template_part_area($default_area_definitions) + public function get_cached_posts($transient_version = '') { } } /** - * OrderConfirmationTemplate class. - * - * @internal + * Class containing utility methods for dealing with the Cart and Checkout blocks. */ - class OrderConfirmationTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractPageTemplate + class CartCheckoutUtils { /** - * The slug of the template. + * Caches if we're on the cart page. * - * @var string + * @var bool */ - const SLUG = 'order-confirmation'; + private static $is_cart_page = null; /** - * Initialization method. + * Caches if we're on the checkout page. + * + * @var bool */ - public function init() - { - } + private static $is_checkout_page = null; /** - * Returns the title of the template. + * Returns true if the current page is a specific page type (cart or checkout). * - * @return string + * This is determined by looking at the global $post object and comparing it to the post ID defined in settings, + * or checking the page contents for a block or shortcode. + * + * This function cannot be used accurately before the `pre_get_posts` action has been run. + * + * @param string $page_type The page type to check for. + * @return bool|null */ - public function get_template_title() + private static function is_page_type(string $page_type): ?bool { } /** - * Returns the description of the template. + * Returns true on the cart page. * - * @return string + * @return bool */ - public function get_template_description() + public static function is_cart_page(): bool { } /** - * Remove edit page from admin bar. + * Returns true on the checkout page. + * + * @return bool */ - public function remove_edit_page_link() + public static function is_checkout_page(): bool { } /** - * Returns the page object assigned to this template/page. + * Returns true if shipping methods exist in the store. Excludes local pickup and only counts enabled shipping methods. * - * @return \WP_Post|null Post object or null. + * @return bool true if shipping methods exist. */ - protected function get_placeholder_page() + public static function shipping_methods_exist() { } /** - * True when viewing the Order Received endpoint. + * Check if the post content contains a block with a specific attribute value. * + * @param string $block_id The block ID to check for. + * @param string $attribute The attribute to check. + * @param string $value The value to check for. + * @param string $post_content The post content to check. * @return boolean */ - protected function is_active_template() + public static function has_block_variation($block_id, $attribute, $value, $post_content) { } - } - /** - * ProductAttributeTemplate class. - * - * @internal - */ - class ProductAttributeTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplateWithFallback - { /** - * The slug of the template. + * Checks if the default cart page is using the Cart block. * - * @var string + * @return bool true if the WC cart page is using the Cart block. */ - const SLUG = 'taxonomy-product_attribute'; + public static function is_cart_block_default() + { + } /** - * The template used as a fallback if that one is customized. + * Checks if the default checkout page is using the Checkout block. * - * @var string + * @return bool true if the WC checkout page is using the Checkout block. */ - public string $fallback_template = \Automattic\WooCommerce\Blocks\Templates\ProductCatalogTemplate::SLUG; + public static function is_checkout_block_default() + { + } /** - * Returns the title of the template. + * Migrate checkout block field visibility attributes to settings when using the checkout block. * - * @return string + * This migration routine is called if the options (woocommerce_checkout_phone_field, woocommerce_checkout_company_field, + * woocommerce_checkout_address_2_field) are not set. They are not set by default; they were orignally set by the + * customizer interface of the legacy shortcode based checkout. + * + * Once migration is initiated, the settings will be updated and will not trigger this routine again. + * + * Note: The block only stores non-default attributes. Not all attributes will be present. + * + * e.g. `{"showCompanyField":true,"requireCompanyField":true,"showApartmentField":false,"className":"wc-block-checkout"}` + * + * If the attributes are missing, we assume default values are needed. */ - public function get_template_title() + protected static function migrate_checkout_block_field_visibility_attributes() { } /** - * Returns the description of the template. + * Get the default visibility for the address_2 field. * * @return string */ - public function get_template_description() + public static function get_company_field_visibility() { } /** - * Renders the default block template from Woo Blocks if no theme templates exist. + * Get the default visibility for the address_2 field. + * + * @return string */ - public function render_block_template() + public static function get_address_2_field_visibility() { } /** - * Renders the Product by Attribute template for product attributes taxonomy pages. + * Get the default visibility for the address_2 field. * - * @param array $templates Templates that match the product attributes taxonomy. + * @return string */ - public function template_hierarchy($templates) + public static function get_phone_field_visibility() { } - } - /** - * ProductBrandTemplate class. - * - * @internal - */ - class ProductBrandTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplateWithFallback - { - /** - * The slug of the template. - * - * @var string - */ - const SLUG = 'taxonomy-product_brand'; - /** - * The template used as a fallback if that one is customized. - * - * @var string - */ - public string $fallback_template = \Automattic\WooCommerce\Blocks\Templates\ProductCatalogTemplate::SLUG; /** - * Whether this is a taxonomy template. + * Checks if the template overriding the page loads the page content or not. + * Templates by default load the page content, but if that block is deleted the content can get out of sync with the one presented in the page editor. * - * @var bool - */ - public bool $is_taxonomy_template = true; - /** - * Returns the title of the template. + * @param string $block The block to check. * - * @return string + * @return bool true if the template has out of sync content. */ - public function get_template_title() + public static function is_overriden_by_custom_template_content(string $block): bool { } /** - * Returns the description of the template. + * Gets country codes, names, states, and locale information. * - * @return string + * @return array */ - public function get_template_description() + public static function get_country_data() { } /** - * Renders the default block template from Woo Blocks if no theme templates exist. + * Removes accents from an array of values, sorts by the values, then returns the original array values sorted. + * + * @param array $sort_array Array of values to sort. + * @return array Sorted array. */ - public function render_block_template() + protected static function deep_sort_with_accents($sort_array) { } - } - /** - * ProductCatalogTemplate class. - * - * @internal - */ - class ProductCatalogTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplate - { /** - * The slug of the template. + * Retrieves formatted shipping zones from WooCommerce. * - * @var string - */ - const SLUG = 'archive-product'; - /** - * Initialization method. + * @return array An array of formatted shipping zones. */ - public function init() + public static function get_shipping_zones() { } /** - * Returns the title of the template. + * Recursively search the checkout block to find the express checkout block and + * get the button style attributes using the parse_blocks function. * - * @return string + * @param array $blocks Blocks to search. + * @param string $cart_or_checkout The block type to check. + * + * @return array Block attributes. */ - public function get_template_title() + public static function find_express_checkout_attributes_in_parsed_blocks($blocks, $cart_or_checkout) { } /** - * Returns the description of the template. + * Recursively search the checkout block to find the express checkout block and + * get the button style attributes * - * @return string + * @param string|array $post_content The post content. + * @param string $cart_or_checkout The block type to check. + * + * @return array|null Block attributes, if present and valid, otherwise `null`. */ - public function get_template_description() + public static function find_express_checkout_attributes($post_content, $cart_or_checkout) { } /** - * Renders the default block template from Woo Blocks if no theme templates exist. + * Given an array of blocks, find the express payment block and update its attributes. + * + * @param array $blocks Blocks to search. + * @param string $cart_or_checkout The block type to check. + * @param array $updated_attrs The new attributes to set. */ - public function render_block_template() + public static function update_blocks_with_new_attrs(&$blocks, $cart_or_checkout, $updated_attrs) { } /** - * Remove the template panel from the Sidebar of the Shop page because - * the Site Editor handles it. - * - * @see https://github.com/woocommerce/woocommerce-gutenberg-products-block/issues/6278 - * - * @param bool $is_support Whether the active theme supports block templates. + * Check if the cart page is defined. * - * @return bool + * @return bool True if the cart page is defined, false otherwise. */ - public function remove_block_template_support_for_shop_page($is_support) + public static function has_cart_page() { } } /** - * ProductCategoryTemplate class. - * - * @internal + * Utility methods used for the Mini Cart block. */ - class ProductCategoryTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplateWithFallback + class MiniCartUtils { /** - * The slug of the template. - * - * @var string - */ - const SLUG = 'taxonomy-product_cat'; - /** - * The template used as a fallback if that one is customized. - * - * @var string - */ - public string $fallback_template = \Automattic\WooCommerce\Blocks\Templates\ProductCatalogTemplate::SLUG; - /** - * Whether this is a taxonomy template. + * Migrate attributes to color panel component format. * - * @var bool + * @param array $attributes Any attributes that currently are available from the block. + * @return array Reformatted attributes that are compatible with the color panel component. */ - public bool $is_taxonomy_template = true; + public static function migrate_attributes_to_color_panel($attributes) + { + } /** - * Returns the title of the template. + * Get the SVG icon for the mini cart. * - * @return string + * @param string $icon_name The name of the icon. + * @param string $icon_color The color of the icon. + * @return string The SVG icon. */ - public function get_template_title() + public static function get_svg_icon($icon_name, $icon_color = 'currentColor') { } + } + /** + * Utility functions for product availability. + */ + class ProductAvailabilityUtils + { /** - * Returns the description of the template. + * Get product availability information. * - * @return string + * @param \WC_Product $product Product object. + * @return string[] The product availability class and text. */ - public function get_template_description() + public static function get_product_availability($product) { } + } + /** + * Utility class to get product data consumable by the blocks. + * + * @internal + */ + class ProductDataUtils + { /** - * Renders the default block template from Woo Blocks if no theme templates exist. + * Get the product data. + * + * @param \WC_Product $product Product object. + * @return array The product data. */ - public function render_block_template() + public static function get_product_data(\WC_Product $product) { } } /** - * ProductSearchResultsTemplate class. - * - * @internal + * Utility methods used for the Product Gallery block. + * {@internal This class and its methods are not intended for public use.} */ - class ProductSearchResultsTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplate + class ProductGalleryUtils { /** - * The slug of the template. + * Get all image IDs for the product. * - * @var string + * @param \WC_Product $product The product object. + * @return array An array of image IDs. */ - const SLUG = 'product-search-results'; + public static function get_all_image_ids($product) + { + } /** - * Initialization method. + * Get the product gallery image data. + * + * @param \WC_Product $product The product object to retrieve the gallery images for. + * @param string $size The size of the image to retrieve. + * @return array An array of image data for the product gallery. */ - public function init() + public static function get_product_gallery_image_data($product, $size) { } /** - * Returns the title of the template. + * Get the product gallery image count. * - * @return string + * @param \WC_Product $product The product object to retrieve the gallery images for. + * @return int The number of images in the product gallery. */ - public function get_template_title() + public static function get_product_gallery_image_count($product) { } /** - * Returns the description of the template. + * Get the image source data. * - * @return string + * @param array $image_ids The image IDs to retrieve the source data for. + * @param string $size The size of the image to retrieve. + * @param string $product_title The title of the product used for alt fallback. + * @return array An array of image source data. */ - public function get_template_description() + public static function get_image_src_data($image_ids, $size, $product_title = '') { } /** - * Renders the default block template from Woo Blocks if no theme templates exist. + * Get the product variation image data. + * + * @param \WC_Product $product The product object to retrieve the variation images for. + * @return array An array of image data for the product variation images. */ - public function render_block_template() + public static function get_product_variation_image_ids($product) { } /** - * When the search is for products and a block theme is active, render the Product Search Template. + * Get the product gallery image IDs. * - * @param array $templates Templates that match the search hierarchy. + * @param \WC_Product $product The product object to retrieve the gallery images for. + * @return array An array of unique image IDs for the product gallery. */ - public function update_search_template_hierarchy($templates) + public static function get_product_gallery_image_ids($product) { } } /** - * ProductTagTemplate class. - * - * @internal + * StyleAttributesUtils class used for getting class and style from attributes. */ - class ProductTagTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplateWithFallback + class StyleAttributesUtils { + // Empty style array. + const EMPTY_STYLE = ['class' => '', 'style' => '', 'value' => '']; /** - * The slug of the template. + * If color value is in preset format, convert it to a CSS var. Else return same value + * For example: + * "var:preset|color|pale-pink" -> "var(--wp--preset--color--pale-pink)" + * "#98b66e" -> "#98b66e" * - * @var string - */ - const SLUG = 'taxonomy-product_tag'; - /** - * The template used as a fallback if that one is customized. + * @param string $color_value value to be processed. * - * @var string + * @return (string) */ - public string $fallback_template = \Automattic\WooCommerce\Blocks\Templates\ProductCatalogTemplate::SLUG; + public static function get_color_value($color_value) + { + } /** - * Whether this is a taxonomy template. + * Get CSS value for color preset. * - * @var bool - */ - public bool $is_taxonomy_template = true; - /** - * Returns the title of the template. + * @param string $preset_name Preset name. * - * @return string + * @return string CSS value for color preset. */ - public function get_template_title() + public static function get_preset_value($preset_name) { } /** - * Returns the description of the template. + * Get CSS value for shadow preset. Returns the same value if it's not a preset. * - * @return string + * @param string $shadow_name Shadow name. + * + * @return string CSS value for shadow preset. */ - public function get_template_description() + public static function get_shadow_value($shadow_name) { } /** - * Renders the default block template from Woo Blocks if no theme templates exist. + * If spacing value is in preset format, convert it to a CSS var. Else return same value + * For example: + * "var:preset|spacing|50" -> "var(--wp--preset--spacing--50)" + * "50px" -> "50px" + * + * @param string $spacing_value value to be processed. + * + * @return (string) */ - public function render_block_template() + public static function get_spacing_value($spacing_value) { } - } - /** - * SimpleProductAddToCartWithOptionsTemplate class. - * - * @internal - */ - class SimpleProductAddToCartWithOptionsTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplatePart - { /** - * The slug of the template. + * Get class and style for align from attributes. * - * @var string + * @param array $attributes Block attributes. + * @return array */ - const SLUG = 'simple-product-add-to-cart-with-options'; + public static function get_align_class_and_style($attributes) + { + } /** - * The template part area where the template part belongs. + * Get class and style for background-color from attributes. * - * @var string - */ - public $template_area = 'add-to-cart-with-options'; - /** - * Initialization method. + * @param array $attributes Block attributes. + * @return array */ - public function init() + public static function get_background_color_class_and_style($attributes) { } /** - * Returns the title of the template. + * Join classes and styles while removing duplicates and null values. * - * @return string + * @param array $rules Array of classes or styles. + * @return array */ - public function get_template_title() + protected static function join_styles($rules) { } /** - * Returns the description of the template. + * Get class and style for border-color from attributes. * - * @return string + * Data passed to this function is not always consistent. It can be: + * Linked - preset color: $attributes['borderColor'] => 'luminous-vivid-orange'. + * Linked - custom color: $attributes['style']['border']['color'] => '#681228'. + * Unlinked - preset color: $attributes['style']['border']['top']['color'] => 'var:preset|color|luminous-vivid-orange' + * Unlinked - custom color: $attributes['style']['border']['top']['color'] => '#681228'. + * + * @param array $attributes Block attributes. + * @return array */ - public function get_template_description() + public static function get_border_color_class_and_style($attributes) { } - } - /** - * SingleProductTemplate class. - * - * @internal - */ - class SingleProductTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplate - { - use \Automattic\WooCommerce\Blocks\Utils\BlocksSharedState; /** - * The slug of the template. + * Get class and style for border-radius from attributes. * - * @var string - */ - const SLUG = 'single-product'; - /** - * Initialization method. + * @param array $attributes Block attributes. + * @return array */ - public function init() + public static function get_border_radius_class_and_style($attributes) { } /** - * Returns the title of the template. + * Get class and style for border width from attributes. * - * @return string + * @param array $attributes Block attributes. + * @return array */ - public function get_template_title() + public static function get_border_width_class_and_style($attributes) { } /** - * Returns the description of the template. + * Get class and style for border width from attributes. * - * @return string + * @param array $attributes Block attributes. + * @return array */ - public function get_template_description() + public static function get_border_style_class_and_style($attributes) { } /** - * Renders the default block template from Woo Blocks if no theme templates exist. + * Get space-separated classes from block attributes. + * + * @param array $attributes Block attributes. + * @param array $properties Properties to get classes from. + * + * @return string Space-separated classes. */ - public function render_block_template() + public static function get_classes_by_attributes($attributes, $properties = array()) { } /** - * Add the block template objects to be used. + * Get class and style for font-family from attributes. * - * @param array $query_result Array of template objects. + * @param array $attributes Block attributes. * @return array */ - public function update_single_product_content($query_result) + public static function get_font_family_class_and_style($attributes) { } /** - * Replace the first single product template block with the password form. Remove all other single product template blocks. + * Get class and style for font-size from attributes. * - * @param array $parsed_blocks Array of parsed block objects. - * @param boolean $is_already_replaced If the password form has already been added. - * @return array Parsed blocks + * @param array $attributes Block attributes. + * @return array */ - private static function replace_first_single_product_template_block_with_password_form($parsed_blocks, $is_already_replaced) + public static function get_font_size_class_and_style($attributes) { } /** - * Add password form to the Single Product Template. + * Get class and style for font-style from attributes. * - * @param string $content The content of the template. - * @return string + * @param array $attributes Block attributes. + * @return array */ - public static function add_password_form($content) + public static function get_font_style_class_and_style($attributes) { } - } - /** - * SingleProductTemplateCompatibility class. - * - * To bridge the gap on compatibility with PHP hooks and Single Product templates. - * - * @internal - */ - class SingleProductTemplateCompatibility extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplateCompatibility - { - const IS_FIRST_BLOCK = '__wooCommerceIsFirstBlock'; - const IS_LAST_BLOCK = '__wooCommerceIsLastBlock'; /** - * Inject hooks to rendered content of corresponding blocks. - * - * @param mixed $block_content The rendered block content. - * @param mixed $block The parsed block data. + * Get class and style for font-weight from attributes. * - * @return string + * @param array $attributes Block attributes. + * @return array */ - public function inject_hooks($block_content, $block) + public static function get_font_weight_class_and_style($attributes) { } /** - * Inject custom hooks to the first and last blocks. - * Since that there is a custom logic for the first and last block, we have to inject the hooks manually. - * The first block supports the following hooks: - * woocommerce_before_single_product - * woocommerce_before_single_product_summary - * - * The last block supports the following hooks: - * woocommerce_after_single_product - * - * @param mixed $block_content The rendered block content. - * @param mixed $block The parsed block data. - * @param array $block_hooks The hooks that should be injected to the block. + * Get class and style for letter-spacing from attributes. * - * @return string + * @param array $attributes Block attributes. + * @return array */ - private function inject_hook_to_first_and_last_blocks($block_content, $block, $block_hooks) + public static function get_letter_spacing_class_and_style($attributes) { } /** - * Update the render block data to inject our custom attribute needed to - * determine which is the first block of the Single Product Template. - * - * @param array $parsed_block The block being rendered. - * @param array $source_block An un-modified copy of $parsed_block, as it appeared in the source content. - * @param WP_Block|null $parent_block If this is a nested block, a reference to the parent block. + * Get class and style for line height from attributes. * + * @param array $attributes Block attributes. * @return array */ - public function update_render_block_data($parsed_block, $source_block, $parent_block) + public static function get_line_height_class_and_style($attributes) { } /** - * Set supported hooks. + * Get a value from an array based on a path e.g style.elements.link + * + * @param array $array Target array. + * @param string $path Path joined by delimiter. + * @param string $delimiter Chosen delimiter defaults to ".". + * @return mixed */ - protected function set_hook_data() + protected static function array_get_value_by_path(array &$array, $path, $delimiter = '.') { } /** - * Add compatibility layer to the first and last block of the Single Product Template. + * Get class and style for link-color from attributes. * - * @param string $template_content Template. - * @return string + * @param array $attributes Block attributes. + * @return array */ - public static function add_compatibility_layer($template_content) + public static function get_link_color_class_and_style($attributes) { } /** - * For compatibility reason, we need to wrap the Single Product template in a div with specific class. - * For more details, see https://github.com/woocommerce/woocommerce-blocks/issues/8314. + * Get class and style for link-hover-color from attributes. * - * @param string $template_content Template Content. - * @return array Wrapped template content inside a div. + * @param array $attributes Block attributes. + * @return array */ - private static function wrap_single_product_template($template_content) + public static function get_link_hover_color_class_and_style($attributes) { } /** - * Add custom attributes to the first group block and last group block that wrap Single Product Template blocks. + * Get class and style for margin from attributes. * - * @param array $wrapped_blocks Wrapped blocks. + * @param array $attributes Block attributes. * @return array */ - private static function inject_custom_attributes_to_first_and_last_block_single_product_template($wrapped_blocks) + public static function get_margin_class_and_style($attributes) { } /** - * Wrap all the blocks inside the template in a group block. + * Get class and style for padding from attributes. * - * @param array $blocks Array of parsed block objects. - * @return array Group block with the blocks inside. + * @param array $attributes Block attributes. + * + * @return array */ - private static function create_wrap_block_group($blocks) + public static function get_padding_class_and_style($attributes) { } /** - * Check if the Single Product template has a single product template block: - * woocommerce/product-gallery-image, woocommerce/product-details, woocommerce/add-to-cart-form, etc. + * Get class and style for shadow from attributes. * - * @param array $parsed_blocks Array of parsed block objects. - * @return bool True if the template has a single product template block, false otherwise. + * @param array $attributes Block attributes. + * @return array */ - private static function has_single_product_template_blocks($parsed_blocks) + public static function get_shadow_class_and_style($attributes) { } /** - * Group blocks in this way: - * B1 + TP1 + B2 + B3 + B4 + TP2 + B5 - * (B = Block, TP = Template Part) - * becomes: - * [[B1], [TP1], [B2, B3, B4], [TP2], [B5]] + * Get space-separated style rules from block attributes. * - * @param array $parsed_blocks Array of parsed block objects. - * @return array Array of blocks grouped by template part. + * @param array $attributes Block attributes. + * @param array $properties Properties to get styles from. + * + * @return string Space-separated style rules. */ - private static function group_blocks($parsed_blocks) + public static function get_styles_by_attributes($attributes, $properties = array()) { } /** - * Inject the hooks after the div wrapper. + * Get class and style for text align from attributes. * - * @param string $block_content Block Content. - * @param array $hooks Hooks to inject. + * @param array $attributes Block attributes. * @return array */ - private function inject_hooks_after_the_wrapper($block_content, $hooks) + public static function get_text_align_class_and_style($attributes) { } /** - * Plain custom HTML block is parsed as block with an empty blockName with a filled innerHTML. + * Get class and style for text-color from attributes. * - * @param array $block Parse block. - * @return bool + * @param array $attributes Block attributes. + * @return array */ - private static function is_custom_html($block) + public static function get_text_color_class_and_style($attributes) { } /** - * Serialize template. + * Get class and style for text-decoration from attributes. * - * @param array $parsed_blocks Parsed blocks. - * @return string + * @param array $attributes Block attributes. + * + * @return array */ - private static function serialize_blocks($parsed_blocks) + public static function get_text_decoration_class_and_style($attributes) { } - } - /** - * VariableProductAddToCartWithOptionsTemplate class. - * - * @internal - */ - class VariableProductAddToCartWithOptionsTemplate extends \Automattic\WooCommerce\Blocks\Templates\AbstractTemplatePart - { /** - * The slug of the template. + * Get class and style for text-transform from attributes. * - * @var string + * @param array $attributes Block attributes. + * @return array */ - const SLUG = 'variable-product-add-to-cart-with-options'; + public static function get_text_transform_class_and_style($attributes) + { + } /** - * The template part area where the template part belongs. + * Get extra CSS classes from attributes. * - * @var string - */ - public $template_area = 'add-to-cart-with-options'; - /** - * Initialization method. + * @param array $attributes Block attributes. + * @return array */ - public function init() + public static function get_classes_from_attributes($attributes) { } /** - * Returns the title of the template. + * Get classes and styles from attributes. * - * @return string + * Excludes link_color and link_hover_color since those should not apply to the container. + * + * @param array $attributes Block attributes. + * @param array $properties Properties to get classes/styles from. + * @param array $exclude Properties to exclude. + * @return array */ - public function get_template_title() + public static function get_classes_and_styles_by_attributes($attributes, $properties = array(), $exclude = array()) { } + } + /** + * Utils class + */ + class Utils + { /** - * Returns the description of the template. + * Compare the current WordPress version with a given version. It's a wrapper around `version-compare` + * that additionally takes into account the suffix (like `-RC1`). + * For example: version 6.3 is considered lower than 6.3-RC2, so you can do + * wp_version_compare( '6.3', '>=' ) and that will return true for 6.3-RC2. * - * @return string + * @param string $version The version to compare against. + * @param string|null $operator Optional. The comparison operator. Defaults to null. + * @return bool|int Returns true if the current WordPress version satisfies the comparison, false otherwise. */ - public function get_template_description() + public static function wp_version_compare($version, $operator = null) { } } } -namespace Automattic\WooCommerce\Blocks\Utils { +namespace Automattic\WooCommerce\Caching { /** - * Utility methods used for serving block templates from WooCommerce Blocks. - * {@internal This class and its methods should only be used within the BlockTemplateController.php and is not intended for public use.} + * Base class for caching objects (or associative arrays) that have a unique identifier. + * At the very least, derived classes need to implement the 'get_object_type' method, + * but usually it will be convenient to override some of the other protected members. + * + * The actual caching is delegated to an instance of CacheEngine. By default WpCacheEngine is used, + * but a different engine can be used by either overriding the get_cache_engine_instance method + * or capturing the wc_object_cache_get_engine filter. + * + * Objects are identified by ids that are either integers or strings. The actual cache keys passed + * to the cache engine will be prefixed with the object type and a random string. The 'flush' operation + * just forces the generation a new prefix and lets the old cached objects expire. */ - class BlockTemplateUtils + abstract class ObjectCache { /** - * Directory names for block templates - * - * Directory names conventions for block templates have changed with Gutenberg 12.1.0, - * however, for backwards-compatibility, we also keep the older conventions, prefixed - * with `DEPRECATED_`. - * - * @var array { - * @var string DEPRECATED_TEMPLATES Old directory name of the block templates directory. - * @var string DEPRECATED_TEMPLATE_PARTS Old directory name of the block template parts directory. - * @var string TEMPLATES_DIR_NAME Directory name of the block templates directory. - * @var string TEMPLATE_PARTS_DIR_NAME Directory name of the block template parts directory. - * } + * Expiration value to be passed to 'set' to use the value of $default_expiration. */ - const DIRECTORY_NAMES = array('DEPRECATED_TEMPLATES' => 'block-templates', 'DEPRECATED_TEMPLATE_PARTS' => 'block-template-parts', 'TEMPLATES' => 'templates', 'TEMPLATE_PARTS' => 'parts'); - const TEMPLATES_ROOT_DIR = 'templates'; + public const DEFAULT_EXPIRATION = -1; /** - * WooCommerce plugin slug - * - * This is used to save templates to the DB which are stored against this value in the wp_terms table. + * Maximum expiration time value, in seconds, that can be passed to 'set'. + */ + public const MAX_EXPIRATION = MONTH_IN_SECONDS; + /** + * This needs to be set in each derived class. * * @var string */ - const PLUGIN_SLUG = 'woocommerce/woocommerce'; + private $object_type; /** - * Deprecated WooCommerce plugin slug + * Default value for the duration of the objects in the cache, in seconds + * (may not be used depending on the cache engine used WordPress cache implementation). * - * For supporting users who have customized templates under the incorrect plugin slug during the first release. - * More context found here: https://github.com/woocommerce/woocommerce-gutenberg-products-block/issues/5423. + * @var int + */ + protected $default_expiration = HOUR_IN_SECONDS; + /** + * Temporarily used when retrieving data in 'get'. * - * @var string + * @var array */ - const DEPRECATED_PLUGIN_SLUG = 'woocommerce'; + private $last_cached_data; /** - * Returns the template matching the slug + * The cache engine to use. * - * @param string $template_slug Slug of the template to retrieve. + * @var ?CacheEngine + */ + private $cache_engine = null; + /** + * Gets an identifier for the types of objects cached by this class. + * This identifier will be used to compose the keys passed to the cache engine. + * It must be unique for each class inheriting from ObjectCache. * - * @return AbstractTemplate|AbstractTemplatePart|null + * @return string */ - public static function get_template($template_slug) + abstract public function get_object_type(): string; + /** + * Creates a new instance of the class. + * + * @throws CacheException If get_object_type returns null or an empty string. + */ + public function __construct() { } /** - * Returns an array containing the references of - * the passed blocks and their inner blocks. - * - * @param array $blocks array of blocks. + * Get the default expiration time for cached objects, in seconds. * - * @return array block references to the passed blocks and their inner blocks. + * @return int */ - public static function flatten_blocks(&$blocks) + public function get_default_expiration_value(): int { } /** - * Parses wp_template content and injects the current theme's - * stylesheet as a theme attribute into each wp_template_part - * - * @param string $template_content serialized wp_template content. + * Get the cache engine to use and cache it internally. * - * @return string Updated wp_template content. + * @return CacheEngine */ - public static function inject_theme_attribute_in_content($template_content) + private function get_cache_engine(): \Automattic\WooCommerce\Caching\CacheEngine { } /** - * Build a unified template object based a post Object. - * Important: This method is an almost identical duplicate from wp-includes/block-template-utils.php as it was not intended for public use. It has been modified to build templates from plugins rather than themes. - * - * @param \WP_Post $post Template post. + * Add an object to the cache, or update an already cached object. * - * @return \WP_Block_Template|\WP_Error Template. + * @param object|array $object The object to be cached. + * @param int|string|null $id Id of the object to be cached, if null, get_object_id will be used to get it. + * @param int $expiration Expiration of the cached data in seconds from the current time, or DEFAULT_EXPIRATION to use the default value. + * @return bool True on success, false on error. + * @throws CacheException Invalid parameter, or null id was passed and get_object_id returns null too. */ - public static function build_template_result_from_post($post) + public function set($object, $id = null, int $expiration = self::DEFAULT_EXPIRATION): bool { } /** - * Build a unified template object based on a theme file. - * - * @internal Important: This method is an almost identical duplicate from wp-includes/block-template-utils.php as it was not intended for public use. It has been modified to build templates from plugins rather than themes. - * - * @param array|object $template_file Theme file. - * @param string $template_type wp_template or wp_template_part. + * Update an object in the cache, but only if an object is already cached with the same id. * - * @return \WP_Block_Template Template. + * @param object|array $object The new object that will replace the already cached one. + * @param int|string|null $id Id of the object to be cached, if null, get_object_id will be used to get it. + * @param int $expiration Expiration of the cached data in seconds from the current time, or DEFAULT_EXPIRATION to use the default value. + * @return bool True on success, false on error or if no object with the supplied id was cached. + * @throws CacheException Invalid parameter, or null id was passed and get_object_id returns null too. */ - public static function build_template_result_from_file($template_file, $template_type) + public function update_if_cached($object, $id = null, int $expiration = self::DEFAULT_EXPIRATION): bool { } /** - * Build a new template object so that we can make Woo Blocks default templates available in the current theme should they not have any. + * Get the id from an object if the id itself is null. * - * @param string $template_file Block template file path. - * @param string $template_type wp_template or wp_template_part. - * @param string $template_slug Block template slug e.g. single-product. - * @param bool $template_is_from_theme If the block template file is being loaded from the current theme instead of Woo Blocks. + * @param object|array $object The object to get the id from. + * @param int|string|null $id An object id or null. * - * @return object Block template object. + * @return int|string|null Passed $id if it wasn't null, otherwise id obtained from $object using get_object_id. + * + * @throws CacheException Passed $id is null and get_object_id returned null too. */ - public static function create_new_block_template_object($template_file, $template_type, $template_slug, $template_is_from_theme = false) + private function get_id_from_object_if_null($object, $id) { } /** - * Finds all nested template part file paths in a theme's directory. + * Check if the given expiration time value is valid, throw an exception if not. * - * @param string $template_type wp_template or wp_template_part. - * @return array $path_list A list of paths to all template part files. + * @param int $expiration Expiration time to check. + * @return void + * @throws CacheException Expiration time is negative or higher than MAX_EXPIRATION. */ - public static function get_template_paths($template_type) + private function verify_expiration_value(int $expiration): void { } /** - * Gets the directory where templates of a specific template type can be found. + * Retrieve a cached object, and if no object is cached with the given id, + * try to get one via get_from_datastore method or by supplying a callback and then cache it. * - * @param string $template_type wp_template or wp_template_part. + * If you want to provide a callable but still use the default expiration value, + * pass "ObjectCache::DEFAULT_EXPIRATION" as the second parameter. * - * @return string + * @param int|string $id The id of the object to retrieve. + * @param int $expiration Expiration of the cached data in seconds from the current time, used if an object is retrieved from datastore and cached. + * @param callable|null $get_from_datastore_callback Optional callback to get the object if it's not cached, it must return an object/array or null. + * @return object|array|null Cached object, or null if it's not cached and can't be retrieved from datastore or via callback. + * @throws CacheException Invalid id parameter. */ - public static function get_templates_directory($template_type = 'wp_template') + public function get($id, int $expiration = self::DEFAULT_EXPIRATION, ?callable $get_from_datastore_callback = null) { } /** - * Returns template title. + * Remove an object from the cache. * - * @param string $template_slug The template slug (e.g. single-product). - * @return string Human friendly title. + * @param int|string $id The id of the object to remove. + * @return bool True if the object is removed from the cache successfully, false otherwise (because the object wasn't cached or for other reason). */ - public static function get_block_template_title($template_slug) + public function remove($id): bool { } /** - * Returns template description. + * Remove all the objects from the cache. * - * @param string $template_slug The template slug (e.g. single-product). - * @return string Template description. + * @return bool True on success, false on error. */ - public static function get_block_template_description($template_slug) + public function flush(): bool { } /** - * Returns area for template parts. + * Is a given object cached? * - * @param string $template_slug The template part slug (e.g. mini-cart). - * @param string $template_type Either `wp_template` or `wp_template_part`. - * @return string Template part area. + * @param int|string $id The id of the object to check. + * @return bool True if there's a cached object with the specified id. */ - public static function get_block_template_area($template_slug, $template_type) + public function is_cached($id): bool { } /** - * Converts template paths into a slug + * Get the id of an object. This is used by 'set' when a null id is passed. + * If the object id can't be determined the method must return null. * - * @param string $path The template's path. - * @return string slug + * @param array|object $object The object to get the id for. + * @return int|string|null */ - public static function generate_template_slug_from_path($path) - { - } + abstract protected function get_object_id($object); /** - * Gets the first matching template part within themes directories - * - * Since [Gutenberg 12.1.0](https://github.com/WordPress/gutenberg/releases/tag/v12.1.0), the conventions for - * block templates and parts directory has changed from `block-templates` and `block-templates-parts` - * to `templates` and `parts` respectively. - * - * This function traverses all possible combinations of directory paths where a template or part - * could be located and returns the first one which is readable, prioritizing the new convention - * over the deprecated one, but maintaining that one for backwards compatibility. - * - * @param string $template_slug The slug of the template (i.e. without the file extension). - * @param string $template_type Either `wp_template` or `wp_template_part`. + * Validate an object before it's cached. * - * @return string|null The matched path or `null` if no match was found. + * @param array|object $object Object to validate. + * @return array|null An array with validation error messages, null or an empty array if there are no errors. */ - public static function get_theme_template_path($template_slug, $template_type = 'wp_template') - { - } + abstract protected function validate($object): ?array; /** - * Check if the theme has a template. So we know if to load our own in or not. + * Get the instance of the cache engine to use. * - * @param string $template_name name of the template file without .html extension e.g. 'single-product'. - * @return boolean + * @return CacheEngine */ - public static function theme_has_template($template_name) + protected function get_cache_engine_instance(): \Automattic\WooCommerce\Caching\CacheEngine { } /** - * Check if the theme has a template. So we know if to load our own in or not. + * Get a random string to be used to compose the cache key prefix. + * It should return a different string each time. * - * @param string $template_name name of the template file without .html extension e.g. 'single-product'. - * @return boolean + * @return string */ - public static function theme_has_template_part($template_name) + protected function get_random_string(): string { } + } +} +namespace Automattic\WooCommerce\Caches { + /** + * A class to cache order objects. + */ + class OrderCache extends \Automattic\WooCommerce\Caching\ObjectCache + { /** - * Checks to see if they are using a compatible version of WP, or if not they have a compatible version of the Gutenberg plugin installed. + * Get the cache key and prefix to use for Orders. * - * @param string $template_type Optional. Template type: `wp_template` or `wp_template_part`. - * Default `wp_template`. - * @return boolean + * @return string */ - public static function supports_block_templates($template_type = 'wp_template') + public function get_object_type(): string { } /** - * Gets the `archive-product` fallback template stored on the db for a given slug. + * Get the id of an object to be cached. * - * @param string $template_slug Slug to check for fallbacks. - * @param array $db_templates Templates that have already been found on the db. - * @return boolean|object + * @param array|object $object The object to be cached. + * @return int|string|null The id of the object, or null if it can't be determined. */ - public static function get_fallback_template_from_db($template_slug, $db_templates) + protected function get_object_id($object) { } /** - * Removes templates from the theme or WooCommerce which have the same slug - * as template saved in the database with the `woocommerce/woocommerce` theme. - * Before WC migrated to the Template Registration API from WordPress, templates - * were saved in the database with the `woocommerce/woocommerce` theme instead - * of the theme's slug. - * - * @param \WP_Block_Template[]|\stdClass[] $templates List of templates to run the filter on. + * Validate an object before caching it. * - * @return array List of templates with duplicates removed. The customised alternative is preferred over the theme default. + * @param array|object $object The object to validate. + * @return string[]|null An array of error messages, or null if the object is valid. */ - public static function remove_templates_with_custom_alternative($templates) + protected function validate($object): ?array { } + } + /** + * A class to control the usage of the orders cache. + */ + class OrderCacheController + { /** - * Removes customized templates that shouldn't be available. That means customized templates based on the - * WooCommerce default template when there is a customized template based on the theme template. + * The orders cache to use. * - * @param \WP_Block_Template[]|\stdClass[] $templates List of templates to run the filter on. + * @var OrderCache + */ + private $order_cache; + /** + * The orders cache to use. * - * @return array Filtered list of templates with only relevant templates available. + * @var FeaturesController */ - public static function remove_duplicate_customized_templates($templates) - { - } + private $features_controller; /** - * Returns whether the blockified templates should be used or not. - * If the option is not stored on the db, we need to check if the current theme is a block one or not. + * The backup value of the cache usage enable status, stored while the cache is temporarily disabled. * - * @return boolean + * @var null|bool */ - public static function should_use_blockified_product_grid_templates() - { - } + private $orders_cache_usage_backup = null; /** - * Determines whether the provided $blocks contains any of the $block_names, - * or if they contain a pattern that contains any of the $block_names. + * Class initialization, invoked by the DI container. * - * @param string[] $block_names Full block types to look for. - * @param WP_Block[] $blocks Array of block objects. - * @return bool Whether the content contains the specified block. + * @internal + * @param OrderCache $order_cache The order cache engine to use. */ - public static function has_block_including_patterns($block_names, $blocks) + final public function init(\Automattic\WooCommerce\Caches\OrderCache $order_cache) { } /** - * Returns whether the passed `$template` has the legacy template block. + * Whether order cache usage is enabled. Currently, linked to custom orders' table usage. * - * @param object $template The template object. - * @return boolean + * @return bool True if the order cache is enabled. */ - public static function template_has_legacy_template_block($template) + public function orders_cache_usage_is_enabled(): bool { } /** - * Updates the title, description and area of a template to the correct values and to make them more user-friendly. - * For example, instead of: - * - Title: `Tag (product_tag)` - * - Description: `Displays taxonomy: Tag.` - * we display: - * - Title: `Products by Tag` - * - Description: `Displays products filtered by a tag.`. - * - * @param WP_Block_Template $template The template object. - * @param string $template_type wp_template or wp_template_part. + * Temporarily disable the order cache if it's enabled. * - * @return WP_Block_Template + * This is a purely in-memory operation: a variable is created with the value + * of the current enable status for the feature, and this variable + * is checked by orders_cache_usage_is_enabled. In the next request the + * feature will be again enabled or not depending on how the feature is set. */ - public static function update_template_data($template, $template_type) + public function temporarily_disable_orders_cache_usage(): void { } /** - * Gets the templates saved in the database. - * - * @param array $slugs An array of slugs to retrieve templates for. - * @param string $template_type wp_template or wp_template_part. + * Check if the order cache has been temporarily disabled. * - * @return \WP_Block_Template[] An array of found templates. + * @return bool True if the order cache is currently temporarily disabled. */ - public static function get_block_templates_from_db($slugs = array(), $template_type = 'wp_template') + public function orders_cache_usage_is_temporarly_disabled(): bool { } /** - * Gets the template part by slug - * - * @param string $slug The template part slug. - * - * @return string The template part content. + * Restore the order cache usage that had been temporarily disabled. */ - public static function get_template_part($slug) + public function maybe_restore_orders_cache_usage(): void { } } /** - * BlocksWpQuery query. - * - * Wrapper for WP Query with additional helper methods. - * Allows query args to be set and parsed without doing running it, so that a cache can be used. - * - * @deprecated 2.5.0 + * A class to cache counts for various order statuses. */ - class BlocksWpQuery extends \WP_Query + class OrderCountCache { /** - * Constructor. + * Cache prefix. * - * Sets up the WordPress query, if parameter is not empty. + * @var string + */ + private $cache_prefix = 'order-count'; + /** + * Default value for the duration of the objects in the cache, in seconds + * (may not be used depending on the cache engine used WordPress cache implementation). * - * Unlike the constructor in WP_Query, this does not RUN the query. + * @var int + */ + protected $expiration = DAY_IN_SECONDS; + /** + * Retrieves the list of known statuses by order type. A cached array of statuses is saved per order type for + * improved backward compatibility with some of the extensions that don't register all statuses they use with + * WooCommerce. * - * @param string|array $query URL query string or array of vars. + * @param string $order_type The type of order. + * + * @return string[] */ - public function __construct($query = '') + private function get_saved_statuses_for_type(string $order_type) { } /** - * Get cached posts, if a cache exists. - * - * A hash is generated using the array of query_vars. If doing custom queries via filters such as posts_where - * (where the SQL query is manipulated directly) you can still ensure there is a unique hash by injecting custom - * query vars via the parse_query filter. For example: - * - * add_filter( 'parse_query', function( $wp_query ) { - * $wp_query->query_vars['my_custom_query_var'] = true; - * } ); + * Adds the given statuses to the cached statuses array for the order type if they are not already stored. * - * Doing so won't have any negative effect on the query itself, and it will cause the hash to change. + * @param string $order_type The order type to save with. + * @param string[] $order_statuses One or more normalised statuses to add. * - * @param string $transient_version Transient version to allow for invalidation. - * @return WP_Post[]|int[] Array of post objects or post IDs. + * @return void */ - public function get_cached_posts($transient_version = '') + private function ensure_statuses_for_type(string $order_type, array $order_statuses) { } - } - /** - * Class containing utility methods for dealing with the Cart and Checkout blocks. - */ - class CartCheckoutUtils - { /** - * Caches if we're on the cart page. + * Get the default statuses. * - * @var bool + * @return string[] + * + * @deprecated 10.1.0 This method will be removed in the future. */ - private static $is_cart_page = null; + public function get_default_statuses() + { + } /** - * Caches if we're on the checkout page. + * Get the cache key for a given order type and status. * - * @var bool + * @param string $order_type The type of order. + * @param string $order_status The status of the order. + * @return string The cache key. */ - private static $is_checkout_page = null; + private function get_cache_key($order_type, $order_status) + { + } /** - * Returns true if the current page is a specific page type (cart or checkout). - * - * This is determined by looking at the global $post object and comparing it to the post ID defined in settings, - * or checking the page contents for a block or shortcode. + * Get the cache key saved statuses of the given order type. * - * This function cannot be used accurately before the `pre_get_posts` action has been run. + * @param string $order_type The type of order. * - * @param string $page_type The page type to check for. - * @return bool|null + * @return string The cache key. */ - private static function is_page_type(string $page_type): ?bool + private function get_saved_statuses_cache_key(string $order_type) { } /** - * Returns true on the cart page. + * Check if the cache has a value for a given order type and status. * - * @return bool + * @param string $order_type The type of order. + * @param string $order_status The status of the order. + * @return bool True if the cache has a value, false otherwise. */ - public static function is_cart_page(): bool + public function is_cached($order_type, $order_status) { } /** - * Returns true on the checkout page. + * Set the cache value for a given order type and status. * - * @return bool + * @param string $order_type The type of order. + * @param string $order_status The status slug of the order. + * @param int $value The value to set. + * @return bool True if the value was set, false otherwise. */ - public static function is_checkout_page(): bool + public function set($order_type, $order_status, int $value): bool { } /** - * Returns true if shipping methods exist in the store. Excludes local pickup and only counts enabled shipping methods. + * Set the cache count value for multiple statuses at once. * - * @return bool true if shipping methods exist. + * @param string $order_type The order type being set. + * @param array $counts Normalized counts keyed by status slug + * (e.g. [ 'wc-processing' => 10, 'wc-pending' => 5 ]). + * + * @return array|bool[] Success map from wp_cache_set_multiple(). */ - public static function shipping_methods_exist() + public function set_multiple(string $order_type, array $counts) { } /** - * Check if the post content contains a block with a specific attribute value. + * Get the cache value for a given order type and set of statuses. * - * @param string $block_id The block ID to check for. - * @param string $attribute The attribute to check. - * @param string $value The value to check for. - * @param string $post_content The post content to check. - * @return boolean + * @param string $order_type The type of order. + * @param string[] $order_statuses The statuses of the order. + * @return int[] The cache value. */ - public static function has_block_variation($block_id, $attribute, $value, $post_content) + public function get($order_type, $order_statuses = array()) { } /** - * Checks if the default cart page is using the Cart block. + * Increment the cache value for a given order status. * - * @return bool true if the WC cart page is using the Cart block. + * @param string $order_type The type of order. + * @param string $order_status The status of the order. + * @param int $offset The amount to increment by. + * @return int The new value of the cache. */ - public static function is_cart_block_default() + public function increment($order_type, $order_status, $offset = 1) { } /** - * Checks if the default checkout page is using the Checkout block. + * Decrement the cache value for a given order status. * - * @return bool true if the WC checkout page is using the Checkout block. + * @param string $order_type The type of order. + * @param string $order_status The status of the order. + * @param int $offset The amount to decrement by. + * @return int The new value of the cache. */ - public static function is_checkout_block_default() + public function decrement($order_type, $order_status, $offset = 1) { } /** - * Migrate checkout block field visibility attributes to settings when using the checkout block. - * - * This migration routine is called if the options (woocommerce_checkout_phone_field, woocommerce_checkout_company_field, - * woocommerce_checkout_address_2_field) are not set. They are not set by default; they were orignally set by the - * customizer interface of the legacy shortcode based checkout. - * - * Once migration is initiated, the settings will be updated and will not trigger this routine again. - * - * Note: The block only stores non-default attributes. Not all attributes will be present. - * - * e.g. `{"showCompanyField":true,"requireCompanyField":true,"showApartmentField":false,"className":"wc-block-checkout"}` + * Flush the cache for a given order type and statuses. * - * If the attributes are missing, we assume default values are needed. + * @param string $order_type The type of order. + * @param string[] $order_statuses The statuses of the order. + * @return void */ - protected static function migrate_checkout_block_field_visibility_attributes() + public function flush($order_type = 'shop_order', $order_statuses = array()) { } + } + /** + * A service class to help with updates to the aggregate orders cache. + * + * @internal + */ + class OrderCountCacheService + { + const BACKGROUND_EVENT_HOOK = 'woocommerce_refresh_order_count_cache'; /** - * Get the default visibility for the address_2 field. + * OrderCountCache instance. * - * @return string + * @var OrderCountCache */ - public static function get_company_field_visibility() - { - } + private $order_count_cache; /** - * Get the default visibility for the address_2 field. + * Array of order ids with their last transitioned status as key value pairs. * - * @return string + * @var array */ - public static function get_address_2_field_visibility() + private $order_statuses = array(); + /** + * Array of order ids with their initial status as key value pairs. + * + * @var array + */ + private $initial_order_statuses = array(); + /** + * Class initialization, invoked by the DI container. + * + * @internal + */ + final public function init() { } /** - * Get the default visibility for the address_2 field. + * Refresh the cache for a given order type. * - * @return string + * @param string $order_type The order type. + * @return void */ - public static function get_phone_field_visibility() + public function refresh_cache($order_type) { } /** - * Checks if the template overriding the page loads the page content or not. - * Templates by default load the page content, but if that block is deleted the content can get out of sync with the one presented in the page editor. - * - * @param string $block The block to check. + * Register background caching for each order type. * - * @return bool true if the template has out of sync content. + * @return void */ - public static function is_overriden_by_custom_template_content(string $block): bool + public function schedule_background_actions() { } /** - * Gets country codes, names, states, and locale information. + * Unschedules background actions. * - * @return array + * @since 10.0.0 + * @internal */ - public static function get_country_data() + public function unschedule_background_actions() { } /** - * Removes accents from an array of values, sorts by the values, then returns the original array values sorted. + * Update the cache when a new order is made. * - * @param array $sort_array Array of values to sort. - * @return array Sorted array. + * @param int $order_id Order id. + * @param WC_Order $order The order. */ - protected static function deep_sort_with_accents($sort_array) + public function update_on_new_order($order_id, $order) { } /** - * Retrieves formatted shipping zones from WooCommerce. + * Update the cache when an order is trashed. * - * @return array An array of formatted shipping zones. + * @param int $order_id Order id. + * @param WC_Order $order The order. */ - public static function get_shipping_zones() + public function update_on_order_trashed($order_id, $order) { } /** - * Recursively search the checkout block to find the express checkout block and - * get the button style attributes + * Update the cache when an order is deleted. * - * @param array $blocks Blocks to search. - * @param string $cart_or_checkout The block type to check. + * @param int $order_id Order id. + * @param WC_Order $order The order. */ - public static function find_express_checkout_attributes($blocks, $cart_or_checkout) + public function update_on_order_deleted($order_id, $order) { } /** - * Given an array of blocks, find the express payment block and update its attributes. + * Update the cache whenver an order status changes. * - * @param array $blocks Blocks to search. - * @param string $cart_or_checkout The block type to check. - * @param array $updated_attrs The new attributes to set. + * @param int $order_id Order id. + * @param string $previous_status the old WooCommerce order status. + * @param string $next_status the new WooCommerce order status. + * @param WC_Order $order The order. */ - public static function update_blocks_with_new_attrs(&$blocks, $cart_or_checkout, $updated_attrs) + public function update_on_order_status_changed($order_id, $previous_status, $next_status, $order) { } /** - * Check if the cart page is defined. + * Get the prefixed status. * - * @return bool True if the cart page is defined, false otherwise. + * @param string $status The status. + * @return string */ - public static function has_cart_page() + private function get_prefixed_status($status) { } } +} +namespace Automattic\WooCommerce\Caching { /** - * Utility methods used for the Mini Cart block. + * Interface for cache engines used by objects inheriting from ObjectCache. + * Here "object" means either an array or an actual PHP object. */ - class MiniCartUtils + interface CacheEngine { /** - * Migrate attributes to color panel component format. + * Retrieves an object cached under a given key. * - * @param array $attributes Any attributes that currently are available from the block. - * @return array Reformatted attributes that are compatible with the color panel component. + * @param string $key They key under which the object to retrieve is cached. + * @param string $group The group under which the object is cached. + * + * @return array|object|null The cached object, or null if there's no object cached under the passed key. */ - public static function migrate_attributes_to_color_panel($attributes) - { - } + public function get_cached_object(string $key, string $group = ''); /** - * Get the SVG icon for the mini cart. + * Caches an object under a given key, and with a given expiration. * - * @param string $icon_name The name of the icon. - * @param string $icon_color The color of the icon. - * @return string The SVG icon. + * @param string $key The key under which the object will be cached. + * @param array|object $object The object to cache. + * @param int $expiration Expiration for the cached object, in seconds. + * @param string $group The group under which the object will be cached. + * + * @return bool True if the object is cached successfully, false otherwise. */ - public static function get_svg_icon($icon_name, $icon_color = 'currentColor') - { - } + public function cache_object(string $key, $object, int $expiration, string $group = ''): bool; + /** + * Removes a cached object from the cache. + * + * @param string $key They key under which the object is cached. + * @param string $group The group under which the object is cached. + * + * @return bool True if the object is removed from the cache successfully, false otherwise (because the object wasn't cached or for other reason). + */ + public function delete_cached_object(string $key, string $group = ''): bool; + /** + * Checks if an object is cached under a given key. + * + * @param string $key The key to verify. + * @param string $group The group under which the object is cached. + * + * @return bool True if there's an object cached under the given key, false otherwise. + */ + public function is_cached(string $key, string $group = ''): bool; + /** + * Deletes all cached objects under a given group. + * + * @param string $group The group to delete. + * + * @return bool True if the group is deleted successfully, false otherwise. + */ + public function delete_cache_group(string $group = ''): bool; } /** - * Utility functions for product availability. + * Exception thrown by classes derived from ObjectCache. */ - class ProductAvailabilityUtils + class CacheException extends \Exception { /** - * Get product availability information. + * Error messages. * - * @param \WC_Product $product Product object. - * @return string[] The product availability class and text. + * @var array */ - public static function get_product_availability($product) + private $errors; + /** + * The object that threw the exception. + * + * @var ObjectCache + */ + private $thrower; + /** + * The id of the cached object, if available. + * + * @var int|string|null + */ + private $cached_id; + /** + * Creates a new instance of the class. + * + * @param string $message The exception message. + * @param ObjectCache $thrower The object that is throwing the exception. + * @param int|string|null $cached_id The involved cached object id, if available. + * @param array|null $errors An array of error messages, if available. + * @param mixed $code An error code, if available. + * @param \Throwable|null $previous The previous exception, if available. + */ + public function __construct(string $message, \Automattic\WooCommerce\Caching\ObjectCache $thrower, $cached_id = null, ?array $errors = null, $code = 0, ?\Throwable $previous = null) { } - } - /** - * Utility class to get product data consumable by the blocks. - * - * @internal - */ - class ProductDataUtils - { /** - * Get the product data. + * Get a string representation of the exception object. * - * @param \WC_Product $product Product object. - * @return array The product data. + * @return string String representation of the exception object. */ - public static function get_product_data(\WC_Product $product) + public function __toString(): string { } - } - /** - * Utility methods used for the Product Gallery block. - * {@internal This class and its methods are not intended for public use.} - */ - class ProductGalleryUtils - { /** - * Get all image IDs for the product. + * Gets the array of error messages passed to the exception constructor. * - * @param \WC_Product $product The product object. - * @return array An array of image IDs. + * @return array Error messages passed to the exception constructor. */ - public static function get_all_image_ids($product) + public function get_errors(): array { } /** - * Get the product gallery image data. + * Gets the object that threw the exception as passed to the exception constructor. * - * @param \WC_Product $product The product object to retrieve the gallery images for. - * @param string $size The size of the image to retrieve. - * @return array An array of image data for the product gallery. + * @return object The object that threw the exception. */ - public static function get_product_gallery_image_data($product, $size) + public function get_thrower(): object { } /** - * Get the product gallery image count. + * Gets the id of the cached object as passed to the exception constructor. * - * @param \WC_Product $product The product object to retrieve the gallery images for. - * @return int The number of images in the product gallery. + * @return int|string|null The id of the cached object. */ - public static function get_product_gallery_image_count($product) + public function get_cached_id() { } + } + /** + * Implementation of CacheEngine that uses the built-in WordPress cache. + */ + class WPCacheEngine implements \Automattic\WooCommerce\Caching\CacheEngine + { + use \Automattic\WooCommerce\Caching\CacheNameSpaceTrait; /** - * Get the image source data. + * Retrieves an object cached under a given key. * - * @param array $image_ids The image IDs to retrieve the source data for. - * @param string $size The size of the image to retrieve. - * @param string $product_title The title of the product used for alt fallback. - * @return array An array of image source data. + * @param string $key The key under which the object to retrieve is cached. + * @param string $group The group under which the object is cached. + * + * @return array|object|null The cached object, or null if there's no object cached under the passed key. */ - public static function get_image_src_data($image_ids, $size, $product_title = '') + public function get_cached_object(string $key, string $group = '') { } /** - * Get the product variation image data. + * Retrieves a set of objects cached under the given keys. * - * @param \WC_Product $product The product object to retrieve the variation images for. - * @return array An array of image data for the product variation images. + * @param string[] $keys The keys under which the object to retrieve is cached. + * @param string $group The group under which the object is cached. + * + * @return array The cached array of objects keyed by the given keys, values will be null for any non-cached keys. */ - public static function get_product_variation_image_ids($product) + public function get_cached_objects(array $keys, string $group = '') { } /** - * Get the product gallery image IDs. + * Caches an object under a given key, and with a given expiration. * - * @param \WC_Product $product The product object to retrieve the gallery images for. - * @return array An array of unique image IDs for the product gallery. + * @param string $key The key under which the object will be cached. + * @param array|object $object The object to cache. + * @param int $expiration Expiration for the cached object, in seconds. + * @param string $group The group under which the object will be cached. + * + * @return bool True if the object is cached successfully, false otherwise. */ - public static function get_product_gallery_image_ids($product) + public function cache_object(string $key, $object, int $expiration, string $group = ''): bool { } - } - /** - * StyleAttributesUtils class used for getting class and style from attributes. - */ - class StyleAttributesUtils - { - // Empty style array. - const EMPTY_STYLE = ['class' => '', 'style' => '', 'value' => '']; /** - * If color value is in preset format, convert it to a CSS var. Else return same value - * For example: - * "var:preset|color|pale-pink" -> "var(--wp--preset--color--pale-pink)" - * "#98b66e" -> "#98b66e" + * Caches an object under a given key, and with a given expiration. * - * @param string $color_value value to be processed. + * @param array $objects The objects to cache keyed by the key to cache under. + * @param int $expiration Expiration for the cached object, in seconds. + * @param string $group The group under which the object will be cached. * - * @return (string) + * @return array Array of return values, grouped by key. Each value is either + * true on success, or false on failure */ - public static function get_color_value($color_value) + public function cache_objects(array $objects, int $expiration, string $group = ''): array { } /** - * Get CSS value for color preset. + * Removes a cached object from the cache. * - * @param string $preset_name Preset name. + * @param string $key They key under which the object is cached. + * @param string $group The group under which the object is cached. * - * @return string CSS value for color preset. + * @return bool True if the object is removed from the cache successfully, false otherwise (because the object wasn't cached or for other reason). */ - public static function get_preset_value($preset_name) + public function delete_cached_object(string $key, string $group = ''): bool { } /** - * Get CSS value for shadow preset. Returns the same value if it's not a preset. + * Checks if an object is cached under a given key. * - * @param string $shadow_name Shadow name. + * @param string $key The key to verify. + * @param string $group The group under which the object is cached. * - * @return string CSS value for shadow preset. + * @return bool True if there's an object cached under the given key, false otherwise. */ - public static function get_shadow_value($shadow_name) + public function is_cached(string $key, string $group = ''): bool { } /** - * If spacing value is in preset format, convert it to a CSS var. Else return same value - * For example: - * "var:preset|spacing|50" -> "var(--wp--preset--spacing--50)" - * "50px" -> "50px" + * Deletes all cached objects under a given group. * - * @param string $spacing_value value to be processed. + * @param string $group The group to delete. * - * @return (string) + * @return bool True if the group is deleted successfully, false otherwise. */ - public static function get_spacing_value($spacing_value) + public function delete_cache_group(string $group = ''): bool { } + } +} +namespace Automattic\WooCommerce\Checkout\Helpers { + /** + * Stock Reservation class. + */ + final class ReserveStock + { /** - * Get class and style for align from attributes. + * Is stock reservation enabled? * - * @param array $attributes Block attributes. - * @return array + * @var boolean */ - public static function get_align_class_and_style($attributes) + private $enabled = true; + /** + * Constructor + */ + public function __construct() { } /** - * Get class and style for background-color from attributes. + * Is stock reservation enabled? * - * @param array $attributes Block attributes. - * @return array + * @return boolean */ - public static function get_background_color_class_and_style($attributes) + protected function is_enabled() { } /** - * Join classes and styles while removing duplicates and null values. + * Query for any existing holds on stock for this item. * - * @param array $rules Array of classes or styles. - * @return array + * @param \WC_Product $product Product to get reserved stock for. + * @param int $exclude_order_id Optional order to exclude from the results. + * + * @return int|float Amount of stock already reserved. */ - protected static function join_styles($rules) + public function get_reserved_stock($product, $exclude_order_id = 0) { } /** - * Get class and style for border-color from attributes. + * Put a temporary hold on stock for an order if enough is available. * - * Data passed to this function is not always consistent. It can be: - * Linked - preset color: $attributes['borderColor'] => 'luminous-vivid-orange'. - * Linked - custom color: $attributes['style']['border']['color'] => '#681228'. - * Unlinked - preset color: $attributes['style']['border']['top']['color'] => 'var:preset|color|luminous-vivid-orange' - * Unlinked - custom color: $attributes['style']['border']['top']['color'] => '#681228'. + * @throws ReserveStockException If stock cannot be reserved. * - * @param array $attributes Block attributes. - * @return array + * @param \WC_Order $order Order object. + * @param int $minutes How long to reserve stock in minutes. Defaults to woocommerce_hold_stock_minutes. */ - public static function get_border_color_class_and_style($attributes) + public function reserve_stock_for_order($order, $minutes = 0) { } /** - * Get class and style for border-radius from attributes. + * Release a temporary hold on stock for an order. * - * @param array $attributes Block attributes. - * @return array + * @param \WC_Order $order Order object. */ - public static function get_border_radius_class_and_style($attributes) + public function release_stock_for_order($order) { } /** - * Get class and style for border width from attributes. + * Reserve stock for a product by inserting rows into the DB. * - * @param array $attributes Block attributes. - * @return array + * @throws ReserveStockException If a row cannot be inserted. + * + * @param int $product_id Product ID which is having stock reserved. + * @param int $stock_quantity Stock amount to reserve. + * @param \WC_Order $order Order object which contains the product. + * @param int $minutes How long to reserve stock in minutes. */ - public static function get_border_width_class_and_style($attributes) + private function reserve_stock_for_product($product_id, $stock_quantity, $order, $minutes) { } /** - * Get class and style for border width from attributes. + * Returns query statement for getting reserved stock of a product. * - * @param array $attributes Block attributes. - * @return array + * @param int $product_id Product ID. + * @param int $exclude_order_id Optional order to exclude from the results. + * @return string|void Query statement. */ - public static function get_border_style_class_and_style($attributes) + private function get_query_for_reserved_stock($product_id, $exclude_order_id = 0) { } + } + /** + * ReserveStockException class. + */ + class ReserveStockException extends \Exception + { /** - * Get space-separated classes from block attributes. + * Sanitized error code. * - * @param array $attributes Block attributes. - * @param array $properties Properties to get classes from. + * @var string + */ + protected $error_code; + /** + * Error extra data. * - * @return string Space-separated classes. + * @var array + */ + protected $error_data; + /** + * Setup exception. + * + * @param string $code Machine-readable error code, e.g `woocommerce_invalid_product_id`. + * @param string $message User-friendly translated error message, e.g. 'Product ID is invalid'. + * @param int $http_status_code Proper HTTP status code to respond with, e.g. 400. + * @param array $data Extra error data. */ - public static function get_classes_by_attributes($attributes, $properties = array()) + public function __construct($code, $message, $http_status_code = 400, $data = array()) { } /** - * Get class and style for font-family from attributes. + * Returns the error code. * - * @param array $attributes Block attributes. - * @return array + * @return string */ - public static function get_font_family_class_and_style($attributes) + public function getErrorCode() { } /** - * Get class and style for font-size from attributes. + * Returns error data. * - * @param array $attributes Block attributes. * @return array */ - public static function get_font_size_class_and_style($attributes) + public function getErrorData() { } + } +} +namespace Automattic\WooCommerce { + /** + * PSR11 compliant dependency injection container for WooCommerce. + * + * Classes in the `src` directory should specify dependencies from that directory via an 'init' method having arguments + * with type hints. If an instance of the container itself is needed, the type hint to use is \Psr\Container\ContainerInterface. + * + * Classes in the `src` directory should interact with anything outside (especially code in the `includes` directory + * and WordPress functions) by using the classes in the `Proxies` directory. The exception is idempotent + * functions (e.g. `wp_parse_url`), those can be used directly. + * + * Classes in the `includes` directory should use the `wc_get_container` function to get the instance of the container when + * they need to get an instance of a class from the `src` directory. + * + * Internally, an instance of RuntimeContainer will be used for the actual class resolution. This class uses reflection + * to instantiate classes and figure out dependencies, so there's no need for explicit class registration. + * When running the unit tests suite this will be replaced with an instance of TestingContainer, + * which provides additional functionality. + */ + final class Container + { /** - * Get class and style for font-style from attributes. + * The underlying container. * - * @param array $attributes Block attributes. - * @return array + * @var RuntimeContainer */ - public static function get_font_style_class_and_style($attributes) + private $container; + /** + * Class constructor. + */ + public function __construct() { } /** - * Get class and style for font-weight from attributes. + * Returns an instance of the specified class. + * See the comment about ContainerException in RuntimeContainer::get. * - * @param array $attributes Block attributes. - * @return array + * @template T + * @param string|class-string $id Class name. + * + * @return T|object Object instance. + * + * @throws ContainerException Error when resolving the class to an object instance, or class not found. + * @throws \Exception Exception thrown in the constructor or in the 'init' method of one of the resolved classes. */ - public static function get_font_weight_class_and_style($attributes) + public function get(string $id) { } /** - * Get class and style for letter-spacing from attributes. + * Returns true if the container can return an instance of the given class or false otherwise. + * See the comment in RuntimeContainer::has. * - * @param array $attributes Block attributes. - * @return array + * @param class-string $id Class name. + * + * @return bool */ - public static function get_letter_spacing_class_and_style($attributes) + public function has(string $id): bool { } + } +} +namespace Automattic\WooCommerce\Database\Migrations\CustomOrderTable { + /** + * CLI tool for migrating order data to/from custom table. + * + * Credits https://github.com/liquidweb/woocommerce-custom-orders-table/blob/develop/includes/class-woocommerce-custom-orders-table-cli.php. + * + * Class CLIRunner + */ + class CLIRunner + { /** - * Get class and style for line height from attributes. + * CustomOrdersTableController instance. * - * @param array $attributes Block attributes. - * @return array + * @var CustomOrdersTableController */ - public static function get_line_height_class_and_style($attributes) - { - } + private $controller; /** - * Get a value from an array based on a path e.g style.elements.link + * DataSynchronizer instance. * - * @param array $array Target array. - * @param string $path Path joined by delimiter. - * @param string $delimiter Chosen delimiter defaults to ".". - * @return mixed + * @var DataSynchronizer; */ - protected static function array_get_value_by_path(array &$array, $path, $delimiter = '.') - { - } + private $synchronizer; /** - * Get class and style for link-color from attributes. + * PostsToOrdersMigrationController instance. * - * @param array $attributes Block attributes. - * @return array + * @var PostsToOrdersMigrationController */ - public static function get_link_color_class_and_style($attributes) - { - } + private $post_to_cot_migrator; /** - * Get class and style for link-hover-color from attributes. + * Init method, invoked by DI container. * - * @param array $attributes Block attributes. - * @return array + * @param CustomOrdersTableController $controller Instance. + * @param DataSynchronizer $synchronizer Instance. + * @param PostsToOrdersMigrationController $posts_to_orders_migration_controller Instance. + * + * @internal */ - public static function get_link_hover_color_class_and_style($attributes) + final public function init(\Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController $controller, \Automattic\WooCommerce\Internal\DataStores\Orders\DataSynchronizer $synchronizer, \Automattic\WooCommerce\Database\Migrations\CustomOrderTable\PostsToOrdersMigrationController $posts_to_orders_migration_controller) { } /** - * Get class and style for margin from attributes. - * - * @param array $attributes Block attributes. - * @return array + * Registers commands for CLI. */ - public static function get_margin_class_and_style($attributes) + public function register_commands() { } /** - * Get class and style for padding from attributes. + * Check if the COT feature is enabled. * - * @param array $attributes Block attributes. + * @param bool $log Optionally log a error message. * - * @return array + * @return bool Whether the COT feature is enabled. */ - public static function get_padding_class_and_style($attributes) + private function is_enabled($log = true): bool { } /** - * Get class and style for shadow from attributes. - * - * @param array $attributes Block attributes. - * @return array + * Free some in-memory usage. */ - public static function get_shadow_class_and_style($attributes) + private function free_in_memory_usage() { } /** - * Get space-separated style rules from block attributes. + * Count how many orders have yet to be migrated into the custom orders table. * - * @param array $attributes Block attributes. - * @param array $properties Properties to get styles from. + * ## EXAMPLES * - * @return string Space-separated style rules. + * wp wc hpos count_unmigrated + * + * @param array $args Positional arguments passed to the command. + * + * @param array $assoc_args Associative arguments (options) passed to the command. + * + * @return int The number of orders to be migrated.* */ - public static function get_styles_by_attributes($attributes, $properties = array()) + public function count_unmigrated($args = array(), $assoc_args = array()): int { } /** - * Get class and style for text align from attributes. + * Sync order data between the custom order tables and the core WordPress post tables. * - * @param array $attributes Block attributes. - * @return array + * ## OPTIONS + * + * [--batch-size=] + * : The number of orders to process in each batch. + * --- + * default: 500 + * --- + * + * ## EXAMPLES + * + * wp wc hpos sync --batch-size=500 + * + * @param array $args Positional arguments passed to the command. + * @param array $assoc_args Associative arguments (options) passed to the command. */ - public static function get_text_align_class_and_style($attributes) + public function sync($args = array(), $assoc_args = array()) { } /** - * Get class and style for text-color from attributes. + * [Deprecated] Use `wp wc hpos sync` instead. + * Copy order data into the postmeta table. * - * @param array $attributes Block attributes. - * @return array + * Note that this could dramatically increase the size of your postmeta table, but is recommended + * if you wish to stop using the custom orders table plugin. + * + * ## OPTIONS + * + * [--batch-size=] + * : The number of orders to process in each batch. Passing a value of 0 will disable batching. + * --- + * default: 500 + * --- + * + * ## EXAMPLES + * + * # Copy all order data into the post meta table, 500 posts at a time. + * wp wc cot migrate --batch-size=500 + * + * @param array $args Positional arguments passed to the command. + * @param array $assoc_args Associative arguments (options) passed to the command. */ - public static function get_text_color_class_and_style($attributes) + public function migrate(array $args = array(), array $assoc_args = array()) { } /** - * Get class and style for text-decoration from attributes. + * Verify migrated order data with original posts data. * - * @param array $attributes Block attributes. + * ## OPTIONS * - * @return array + * [--batch-size=] + * : The number of orders to verify in each batch. + * --- + * default: 500 + * --- + * + * [--start-from=] + * : Order ID to start from. + * --- + * default: 0 + * --- + * + * [--end-at=] + * : Order ID to end at. + * --- + * default: -1 + * --- + * + * [--verbose] + * : Whether to output errors as they happen in batch, or output them all together at the end. + * --- + * default: false + * --- + * + * [--order-types] + * : Comma-separated list of order types that needs to be verified. For example, --order-types=shop_order,shop_order_refund + * --- + * default: Output of function `wc_get_order_types( 'cot-migration' )` + * + * [--re-migrate] + * : Attempt to re-migrate orders that failed verification. You should only use this option when you have never run the site with HPOS as authoritative source of order data yet, or you have manually checked the reported errors, otherwise, you risk stale data overwriting the more recent data. + * default: false + * + * ## EXAMPLES + * + * # Verify migrated order data, 500 orders at a time. + * wp wc hpos verify_cot_data --batch-size=500 --start-from=0 --end-at=10000 + * + * @param array $args Positional arguments passed to the command. + * @param array $assoc_args Associative arguments (options) passed to the command. */ - public static function get_text_decoration_class_and_style($attributes) + public function verify_cot_data($args = array(), $assoc_args = array()) { } /** - * Get class and style for text-transform from attributes. + * Helper method to get count for orders needing verification. * - * @param array $attributes Block attributes. - * @return array + * @param int $order_id_start Order ID to start from. + * @param int $order_id_end Order ID to end at. + * @param array $order_types List of order types to verify. + * @param bool $log Whether to also log an error message. + * + * @return int Order count. */ - public static function get_text_transform_class_and_style($attributes) + private function get_verify_order_count(int $order_id_start, int $order_id_end, array $order_types, bool $log = true): int { } /** - * Get extra CSS classes from attributes. + * Verify meta data as part of verifying the order object. * - * @param array $attributes Block attributes. - * @return array + * @param array $order_ids Order IDs. + * @param array $failed_ids Array for storing failed IDs. + * + * @return array Failed IDs with meta details. */ - public static function get_classes_from_attributes($attributes) + private function verify_meta_data(array $order_ids, array $failed_ids): array { } /** - * Get classes and styles from attributes. + * Helper method to normalize response from meta queries into order_id > meta_key > meta_values. * - * Excludes link_color and link_hover_color since those should not apply to the container. + * @param array $data Data fetched from meta queries. * - * @param array $attributes Block attributes. - * @param array $properties Properties to get classes/styles from. - * @param array $exclude Properties to exclude. - * @return array + * @return array Normalized data. */ - public static function get_classes_and_styles_by_attributes($attributes, $properties = array(), $exclude = array()) + private function normalize_raw_meta_data(array $data): array { } - } - /** - * Utils class - */ - class Utils - { /** - * Compare the current WordPress version with a given version. It's a wrapper around `version-compare` - * that additionally takes into account the suffix (like `-RC1`). - * For example: version 6.3 is considered lower than 6.3-RC2, so you can do - * wp_version_compare( '6.3', '>=' ) and that will return true for 6.3-RC2. + * Set custom order tables (HPOS) to authoritative if: 1). HPOS and posts tables are in sync, or, 2). This is a new shop (in this case also create tables). Additionally, all installed WC plugins should be compatible. * - * @param string $version The version to compare against. - * @param string|null $operator Optional. The comparison operator. Defaults to null. - * @return bool|int Returns true if the current WordPress version satisfies the comparison, false otherwise. + * ## OPTIONS + * + * [--for-new-shop] + * : Enable only if this is a new shop, irrespective of whether tables are in sync. + * --- + * default: false + * --- + * + * [--with-sync] + * : Also enables sync (if it's currently not enabled). + * --- + * default: false + * --- + * + * [--ignore-plugin-compatibility] + * : Enable even if there are active plugins that are incompatible with HPOS. + * + * ### EXAMPLES + * + * # Enable HPOS on new shops. + * wp wc hpos enable --for-new-shop + * + * @param array $args Positional arguments passed to the command. + * @param array $assoc_args Associative arguments (options) passed to the command. + * + * @return void */ - public static function wp_version_compare($version, $operator = null) + public function enable(array $args = array(), array $assoc_args = array()) { } - } -} -namespace Automattic\WooCommerce\Caching { - /** - * Base class for caching objects (or associative arrays) that have a unique identifier. - * At the very least, derived classes need to implement the 'get_object_type' method, - * but usually it will be convenient to override some of the other protected members. - * - * The actual caching is delegated to an instance of CacheEngine. By default WpCacheEngine is used, - * but a different engine can be used by either overriding the get_cache_engine_instance method - * or capturing the wc_object_cache_get_engine filter. - * - * Objects are identified by ids that are either integers or strings. The actual cache keys passed - * to the cache engine will be prefixed with the object type and a random string. The 'flush' operation - * just forces the generation a new prefix and lets the old cached objects expire. - */ - abstract class ObjectCache - { - /** - * Expiration value to be passed to 'set' to use the value of $default_expiration. - */ - public const DEFAULT_EXPIRATION = -1; - /** - * Maximum expiration time value, in seconds, that can be passed to 'set'. - */ - public const MAX_EXPIRATION = MONTH_IN_SECONDS; - /** - * This needs to be set in each derived class. - * - * @var string - */ - private $object_type; /** - * Default value for the duration of the objects in the cache, in seconds - * (may not be used depending on the cache engine used WordPress cache implementation). + * Disables custom order tables (HPOS) and posts to authoritative if HPOS and post tables are in sync. * - * @var int - */ - protected $default_expiration = HOUR_IN_SECONDS; - /** - * Temporarily used when retrieving data in 'get'. + * ## OPTIONS * - * @var array - */ - private $last_cached_data; - /** - * The cache engine to use. + * [--with-sync] + * : Also disables sync (if it's currently enabled). + * --- + * default: false + * --- * - * @var ?CacheEngine - */ - private $cache_engine = null; - /** - * Gets an identifier for the types of objects cached by this class. - * This identifier will be used to compose the keys passed to the cache engine. - * It must be unique for each class inheriting from ObjectCache. + * ### EXAMPLES * - * @return string - */ - abstract public function get_object_type(): string; - /** - * Creates a new instance of the class. + * # Disable HPOS. + * wp wc hpos disable * - * @throws CacheException If get_object_type returns null or an empty string. + * @param array $args Positional arguments passed to the command. + * @param array $assoc_args Associative arguments (options) passed to the command. */ - public function __construct() + public function disable($args, $assoc_args) { } /** - * Get the default expiration time for cached objects, in seconds. + * When HPOS is enabled, this command lets you remove redundant data from the postmeta table for migrated orders. * - * @return int + * ## OPTIONS + * + * ... + * : ID or range of orders to clean up. + * + * [--batch-size=] + * : Number of orders to process per batch. Applies only to cleaning up of 'all' orders. + * --- + * default: 500 + * --- + * + * [--force] + * : When true, post meta will be cleaned up even if the post appears to have been updated more recently than the order. + * --- + * default: false + * --- + * + * ## EXAMPLES + * + * # Cleanup post data for order 314. + * $ wp wc hpos cleanup 314 + * + * # Cleanup postmeta for orders with IDs between 10 and 100 and order 314. + * $ wp wc hpos cleanup 10-100 314 + * + * # Cleanup postmeta for all orders. + * wp wc hpos cleanup all + * + * # Cleanup postmeta for all orders with a batch size of 200 (instead of the default 500). + * wp wc hpos cleanup all --batch-size=200 + * + * @param array $args Positional arguments passed to the command. + * @param array $assoc_args Associative arguments (options) passed to the command. + * @return void */ - public function get_default_expiration_value(): int + public function cleanup_post_data(array $args = array(), array $assoc_args = array()) { } /** - * Get the cache engine to use and cache it internally. + * Displays a summary of HPOS situation on this site. * - * @return CacheEngine + * @since 8.6.0 + * + * @param array $args Positional arguments passed to the command. + * @param array $assoc_args Associative arguments (options) passed to the command. */ - private function get_cache_engine(): \Automattic\WooCommerce\Caching\CacheEngine + public function status(array $args = array(), array $assoc_args = array()) { } /** - * Add an object to the cache, or update an already cached object. + * Displays differences for an order between the HPOS and post datastore. * - * @param object|array $object The object to be cached. - * @param int|string|null $id Id of the object to be cached, if null, get_object_id will be used to get it. - * @param int $expiration Expiration of the cached data in seconds from the current time, or DEFAULT_EXPIRATION to use the default value. - * @return bool True on success, false on error. - * @throws CacheException Invalid parameter, or null id was passed and get_object_id returns null too. + * ## OPTIONS + * + * + * :The ID of the order. + * + * [--format=] + * : Render output in a particular format. + * --- + * default: table + * options: + * - table + * - csv + * - json + * - yaml + * --- + * + * ## EXAMPLES + * + * # Find differences between datastores for order 123. + * $ wp wc hpos diff 123 + * + * # Find differences for order 123 and display as CSV. + * $ wp wc hpos diff 123 --format=csv + * + * @since 8.6.0 + * + * @param array $args Positional arguments passed to the command. + * @param array $assoc_args Associative arguments (options) passed to the command. */ - public function set($object, $id = null, int $expiration = self::DEFAULT_EXPIRATION): bool + public function diff(array $args = array(), array $assoc_args = array()) { } /** - * Update an object in the cache, but only if an object is already cached with the same id. + * Backfills an order from either the HPOS or the posts datastore. + * + * ## OPTIONS + * + * + * : The ID of the order. + * + * --from= + * : Source datastore. Either 'hpos' or 'posts'. + * --- + * options: + * - hpos + * - posts + * --- + * + * --to= + * : Destination datastore. Either 'hpos' or 'posts'. + * --- + * options: + * - hpos + * - posts + * --- + * + * [--meta_keys=] + * : Comma-separated list of meta keys to backfill. + * + * [--props=] + * : Comma-separated list of order properties to backfill. * - * @param object|array $object The new object that will replace the already cached one. - * @param int|string|null $id Id of the object to be cached, if null, get_object_id will be used to get it. - * @param int $expiration Expiration of the cached data in seconds from the current time, or DEFAULT_EXPIRATION to use the default value. - * @return bool True on success, false on error or if no object with the supplied id was cached. - * @throws CacheException Invalid parameter, or null id was passed and get_object_id returns null too. + * @since 8.6.0 + * + * @param array $args Positional arguments passed to the command. + * @param array $assoc_args Associative arguments (options) passed to the command. */ - public function update_if_cached($object, $id = null, int $expiration = self::DEFAULT_EXPIRATION): bool + public function backfill(array $args = array(), array $assoc_args = array()) { } /** - * Get the id from an object if the id itself is null. + * Show the list of WooCommerce-aware plugins known to be compatible, incompatible or without compatibility declaration for HPOS. Note that inactive plugins will always be listed in the "uncertain" list. * - * @param object|array $object The object to get the id from. - * @param int|string|null $id An object id or null. + * [--include-inactive] + * : Include inactive plugins in the list. * - * @return int|string|null Passed $id if it wasn't null, otherwise id obtained from $object using get_object_id. + * [--display-filenames] + * : Print plugin file names instead of plugin names. * - * @throws CacheException Passed $id is null and get_object_id returned null too. - */ - private function get_id_from_object_if_null($object, $id) - { - } - /** - * Check if the given expiration time value is valid, throw an exception if not. + * @since 9.1.0 * - * @param int $expiration Expiration time to check. - * @return void - * @throws CacheException Expiration time is negative or higher than MAX_EXPIRATION. + * @param array $args Positional arguments passed to the command. + * @param array $assoc_args Associative arguments (options) passed to the command. */ - private function verify_expiration_value(int $expiration): void + public function compatibility_info(array $args = array(), array $assoc_args = array()): void { } /** - * Retrieve a cached object, and if no object is cached with the given id, - * try to get one via get_from_datastore method or by supplying a callback and then cache it. - * - * If you want to provide a callable but still use the default expiration value, - * pass "ObjectCache::DEFAULT_EXPIRATION" as the second parameter. + * Get the printable names for a set of plugins given their file names. * - * @param int|string $id The id of the object to retrieve. - * @param int $expiration Expiration of the cached data in seconds from the current time, used if an object is retrieved from datastore and cached. - * @param callable|null $get_from_datastore_callback Optional callback to get the object if it's not cached, it must return an object/array or null. - * @return object|array|null Cached object, or null if it's not cached and can't be retrieved from datastore or via callback. - * @throws CacheException Invalid id parameter. + * @param array $plugins The plugin file names. + * @param bool $display_filenames True to simply return the sorted list of plugin file names. + * @return array A sorted array of plugin names or file names. */ - public function get($id, int $expiration = self::DEFAULT_EXPIRATION, ?callable $get_from_datastore_callback = null) + private function get_printable_plugin_names(array $plugins, bool $display_filenames): array { } /** - * Remove an object from the cache. + * Print a list of plugin names. * - * @param int|string $id The id of the object to remove. - * @return bool True if the object is removed from the cache successfully, false otherwise (because the object wasn't cached or for other reason). + * @param array $plugins The names to print. */ - public function remove($id): bool + private function print_plugin_names(array $plugins): void { } /** - * Remove all the objects from the cache. + * Show a log message using the WP_CLI text colorization feature. * - * @return bool True on success, false on error. + * @param string $text Text to show. */ - public function flush(): bool + private function log(string $text) { } /** - * Is a given object cached? + * Enables compatibility mode, which keeps the HPOS and posts datastore in sync. * - * @param int|string $id The id of the object to check. - * @return bool True if there's a cached object with the specified id. + * @since 9.1.0 */ - public function is_cached($id): bool + public function enable_compat_mode(): void { } /** - * Get the id of an object. This is used by 'set' when a null id is passed. - * If the object id can't be determined the method must return null. - * - * @param array|object $object The object to get the id for. - * @return int|string|null - */ - abstract protected function get_object_id($object); - /** - * Validate an object before it's cached. - * - * @param array|object $object Object to validate. - * @return array|null An array with validation error messages, null or an empty array if there are no errors. - */ - abstract protected function validate($object): ?array; - /** - * Get the instance of the cache engine to use. + * Disables compatibility mode, which keeps the HPOS and posts datastore in sync. * - * @return CacheEngine + * @since 9.1.0 */ - protected function get_cache_engine_instance(): \Automattic\WooCommerce\Caching\CacheEngine + public function disable_compat_mode(): void { } /** - * Get a random string to be used to compose the cache key prefix. - * It should return a different string each time. + * Toggles compatibility mode on or off. * - * @return string + * @since 9.1.0 + * + * @param bool $enabled TRUE to enable compatibility mode, FALSE to disable. */ - protected function get_random_string(): string + private function toggle_compat_mode(bool $enabled): void { } } } -namespace Automattic\WooCommerce\Caches { +namespace Automattic\WooCommerce\Database\Migrations { /** - * A class to cache order objects. + * Base class for implementing WP posts to order tables migrations handlers. + * It mainly contains methods to deal with error handling. + * + * @package Automattic\WooCommerce\Database\Migrations */ - class OrderCache extends \Automattic\WooCommerce\Caching\ObjectCache + abstract class TableMigrator { /** - * Get the cache key and prefix to use for Orders. + * An array of cumulated error messages. * - * @return string + * @var array */ - public function get_object_type(): string - { - } + private $errors; /** - * Get the id of an object to be cached. + * Clear the error messages list. * - * @param array|object $object The object to be cached. - * @return int|string|null The id of the object, or null if it can't be determined. + * @return void */ - protected function get_object_id($object) + protected function clear_errors(): void { } /** - * Validate an object before caching it. + * Add an error message to the errors list unless it's there already. * - * @param array|object $object The object to validate. - * @return string[]|null An array of error messages, or null if the object is valid. + * @param string $error The error message to add. + * @return void */ - protected function validate($object): ?array + protected function add_error(string $error): void { } - } - /** - * A class to control the usage of the orders cache. - */ - class OrderCacheController - { /** - * The orders cache to use. + * Get the list of error messages added. * - * @var OrderCache + * @return array */ - private $order_cache; + protected function get_errors(): array + { + } /** - * The orders cache to use. + * Run $wpdb->query and add the error, if any, to the errors list. * - * @var FeaturesController + * @param string $query The SQL query to run. + * @return mixed Whatever $wpdb->query returns. */ - private $features_controller; + protected function db_query(string $query) + { + } /** - * The backup value of the cache usage enable status, stored while the cache is temporarily disabled. + * Run $wpdb->get_results and add the error, if any, to the errors list. * - * @var null|bool + * @param string|null $query The SQL query to run. + * @param string $output Any of ARRAY_A | ARRAY_N | OBJECT | OBJECT_K constants. + * @return mixed Whatever $wpdb->get_results returns. */ - private $orders_cache_usage_backup = null; + protected function db_get_results(?string $query = null, string $output = OBJECT) + { + } /** - * Class initialization, invoked by the DI container. + * Migrate a batch of orders, logging any database error that could arise and the exception thrown if any. * - * @internal - * @param OrderCache $order_cache The order cache engine to use. + * @param array $entity_ids Order ids to migrate. + * @return array An array containing the keys 'errors' (array of strings) and 'exception' (exception object or null). + * + * @deprecated 8.0.0 Use `fetch_sanitized_migration_data` and `process_migration_data` instead. */ - final public function init(\Automattic\WooCommerce\Caches\OrderCache $order_cache) + public function process_migration_batch_for_ids(array $entity_ids): array { } + // phpcs:disable Squiz.Commenting.FunctionComment.InvalidNoReturn, Squiz.Commenting.FunctionCommentThrowTag.Missing -- Methods are not marked abstract for back compat. /** - * Whether order cache usage is enabled. Currently, linked to custom orders' table usage. + * Return data to be migrated for a batch of entities. * - * @return bool True if the order cache is enabled. + * @param array $entity_ids Ids of entities to migrate. + * + * @return array[] Data to be migrated. Would be of the form: array( 'data' => array( ... ), 'errors' => array( ... ) ). */ - public function orders_cache_usage_is_enabled(): bool + public function fetch_sanitized_migration_data(array $entity_ids) { } /** - * Temporarily disable the order cache if it's enabled. + * Process migration data for a batch of entities. * - * This is a purely in-memory operation: a variable is created with the value - * of the current enable status for the feature, and this variable - * is checked by orders_cache_usage_is_enabled. In the next request the - * feature will be again enabled or not depending on how the feature is set. + * @param array $data Data to be migrated. Should be of the form: array( 'data' => array( ... ) ) as returned by the `fetch_sanitized_migration_data` method. + * + * @return array Array of errors and exception if any. */ - public function temporarily_disable_orders_cache_usage(): void + public function process_migration_data(array $data) { } + // phpcs:enable /** - * Check if the order cache has been temporarily disabled. + * The core method that actually performs the migration for the supplied batch of order ids. + * It doesn't need to deal with database errors nor with exceptions. * - * @return bool True if the order cache is currently temporarily disabled. + * @param array $entity_ids Order ids to migrate. + * @return void + * + * @deprecated 8.0.0 Use `fetch_sanitized_migration_data` and `process_migration_data` instead. */ - public function orders_cache_usage_is_temporarly_disabled(): bool - { - } + abstract protected function process_migration_batch_for_ids_core(array $entity_ids): void; /** - * Restore the order cache usage that had been temporarily disabled. + * Check if the amount of processed database rows matches the amount of orders to process, and log an error if not. + * + * @param string $operation Operation performed, 'insert' or 'update'. + * @param array|bool $received_rows_count Value returned by @wpdb after executing the query. + * @return void */ - public function maybe_restore_orders_cache_usage(): void + protected function maybe_add_insert_or_update_error(string $operation, $received_rows_count) { } } /** - * A class to cache counts for various order statuses. + * Base class for implementing migrations from the standard WordPress meta table + * to custom meta (key-value pairs) tables. + * + * @package Automattic\WooCommerce\Database\Migrations */ - class OrderCountCache + abstract class MetaToMetaTableMigrator extends \Automattic\WooCommerce\Database\Migrations\TableMigrator { /** - * Cache prefix. + * Schema config, see __construct for more details. * - * @var string + * @var array */ - private $cache_prefix = 'order-count'; + private $schema_config; /** - * Default value for the duration of the objects in the cache, in seconds - * (may not be used depending on the cache engine used WordPress cache implementation). + * Returns config for the migration. * - * @var int + * @return array Meta config, must be in following format: + * array( + * 'source' => array( + * 'meta' => array( + * 'table_name' => source_meta_table_name, + * 'entity_id_column' => entity_id column name in source meta table, + * 'meta_key_column' => meta_key column', + * 'meta_value_column' => meta_value column', + * ), + * 'entity' => array( + * 'table_name' => entity table name for the meta table, + * 'source_id_column' => column name in entity table which maps to meta table, + * 'id_column' => id column in entity table, + * ), + * 'excluded_keys' => array of keys to exclude, + * ), + * 'destination' => array( + * 'meta' => array( + * 'table_name' => destination meta table name, + * 'entity_id_column' => entity_id column in meta table, + * 'meta_key_column' => meta key column, + * 'meta_value_column' => meta_value column, + * 'entity_id_type' => data type of entity id, + * 'meta_id_column' => id column in meta table, + * ), + * ), + * ) */ - protected $expiration = DAY_IN_SECONDS; + abstract protected function get_meta_config(): array; /** - * Retrieves the list of known statuses by order type. A cached array of statuses is saved per order type for - * improved backward compatibility with some of the extensions that don't register all statuses they use with - * WooCommerce. - * - * @param string $order_type The type of order. - * - * @return string[] + * MetaToMetaTableMigrator constructor. */ - private function get_saved_statuses_for_type(string $order_type) + public function __construct() { } /** - * Adds the given statuses to the cached statuses array for the order type if they are not already stored. + * Return data to be migrated for a batch of entities. * - * @param string $order_type The order type to save with. - * @param string[] $order_statuses One or more normalised statuses to add. + * @param array $entity_ids Ids of entities to migrate. * - * @return void + * @return array[] Data to be migrated. Would be of the form: array( 'data' => array( ... ), 'errors' => array( ... ) ). */ - private function ensure_statuses_for_type(string $order_type, array $order_statuses) + public function fetch_sanitized_migration_data($entity_ids) { } /** - * Get the default statuses. - * - * @return string[] + * Migrate a batch of entities from the posts table to the corresponding table. * - * @deprecated 10.1.0 This method will be removed in the future. + * @param array $entity_ids Ids of entities ro migrate. */ - public function get_default_statuses() + protected function process_migration_batch_for_ids_core(array $entity_ids): void { } /** - * Get the cache key for a given order type and status. + * Process migration data for a batch of entities. * - * @param string $order_type The type of order. - * @param string $order_status The status of the order. - * @return string The cache key. + * @param array $data Data to be migrated. Should be of the form: array( 'data' => array( ... ) ) as returned by the `fetch_sanitized_migration_data` method. + * + * @return array Array of errors and exception if any. */ - private function get_cache_key($order_type, $order_status) + public function process_migration_data(array $data) { } /** - * Get the cache key saved statuses of the given order type. + * Generate update SQL for given batch. * - * @param string $order_type The type of order. + * @param array $batch List of data to generate update SQL for. Should be in same format as output of $this->fetch_data_for_migration_for_ids. * - * @return string The cache key. + * @return string Query to update batch records. */ - private function get_saved_statuses_cache_key(string $order_type) + private function generate_update_sql_for_batch(array $batch): string { } /** - * Check if the cache has a value for a given order type and status. + * Generate insert sql queries for batches. * - * @param string $order_type The type of order. - * @param string $order_status The status of the order. - * @return bool True if the cache has a value, false otherwise. + * @param array $batch Data to generate queries for. + * + * @return string Insert SQL query. */ - public function is_cached($order_type, $order_status) + private function generate_insert_sql_for_batch(array $batch): string { } /** - * Set the cache value for a given order type and status. + * Fetch data for migration. * - * @param string $order_type The type of order. - * @param string $order_status The status slug of the order. - * @param int $value The value to set. - * @return bool True if the value was set, false otherwise. + * @param array $entity_ids Array of IDs to fetch data for. + * + * @return array[] Data, will of the form: + * array( + * 'id_1' => array( 'column1' => array( value1_1, value1_2...), 'column2' => array(value2_1, value2_2...), ...), + * ..., + * ) */ - public function set($order_type, $order_status, int $value): bool + public function fetch_data_for_migration_for_ids(array $entity_ids): array { } /** - * Set the cache count value for multiple statuses at once. + * Helper method to get already migrated records. Will be used to find prevent migration of already migrated records. * - * @param string $order_type The order type being set. - * @param array $counts Normalized counts keyed by status slug - * (e.g. [ 'wc-processing' => 10, 'wc-pending' => 5 ]). + * @param array $entity_ids List of entity ids to check for. * - * @return array|bool[] Success map from wp_cache_set_multiple(). + * @return array Already migrated records. */ - public function set_multiple(string $order_type, array $counts) + private function get_already_migrated_records(array $entity_ids): array { } /** - * Get the cache value for a given order type and set of statuses. + * Classify each record on whether to migrate or update. * - * @param string $order_type The type of order. - * @param string[] $order_statuses The statuses of the order. - * @return int[] The cache value. + * @param array $to_migrate Records to migrate. + * @param array $already_migrated Records already migrated. + * + * @return array[] Returns two arrays, first for records to migrate, and second for records to upgrade. */ - public function get($order_type, $order_statuses = array()) + private function classify_update_insert_records(array $to_migrate, array $already_migrated): array { } /** - * Increment the cache value for a given order status. + * Helper method to build query used to fetch data from source meta table. * - * @param string $order_type The type of order. - * @param string $order_status The status of the order. - * @param int $offset The amount to increment by. - * @return int The new value of the cache. + * @param array $entity_ids List of entity IDs to build meta query for. + * + * @return string Query that can be used to fetch data. */ - public function increment($order_type, $order_status, $offset = 1) + private function build_meta_table_query(array $entity_ids): string { } + } +} +namespace Automattic\WooCommerce\Database\Migrations\CustomOrderTable { + /** + * Helper class to migrate records from the WordPress post meta table + * to the custom orders meta table. + * + * @package Automattic\WooCommerce\Database\Migrations\CustomOrderTable + */ + class PostMetaToOrderMetaMigrator extends \Automattic\WooCommerce\Database\Migrations\MetaToMetaTableMigrator + { /** - * Decrement the cache value for a given order status. + * List of meta keys to exclude from migration. * - * @param string $order_type The type of order. - * @param string $order_status The status of the order. - * @param int $offset The amount to decrement by. - * @return int The new value of the cache. + * @var array */ - public function decrement($order_type, $order_status, $offset = 1) + private $excluded_columns; + /** + * PostMetaToOrderMetaMigrator constructor. + * + * @param array $excluded_columns List of meta keys to exclude from migration. + */ + public function __construct($excluded_columns) { } /** - * Flush the cache for a given order type and statuses. + * Generate config for meta data migration. * - * @param string $order_type The type of order. - * @param string[] $order_statuses The statuses of the order. - * @return void + * @return array Meta data migration config. */ - public function flush($order_type = 'shop_order', $order_statuses = array()) + protected function get_meta_config(): array { } } +} +namespace Automattic\WooCommerce\Database\Migrations { /** - * A service class to help with updates to the aggregate orders cache. + * Base class for implementing migrations from the standard WordPress meta table + * to custom structured tables. * - * @internal + * @package Automattic\WooCommerce\Database\Migrations */ - class OrderCountCacheService + abstract class MetaToCustomTableMigrator extends \Automattic\WooCommerce\Database\Migrations\TableMigrator { - const BACKGROUND_EVENT_HOOK = 'woocommerce_refresh_order_count_cache'; /** - * OrderCountCache instance. + * Config for tables being migrated and migrated from. See __construct() for detailed config. * - * @var OrderCountCache + * @var array */ - private $order_count_cache; + protected $schema_config; /** - * Array of order ids with their last transitioned status as key value pairs. + * Meta config, see __construct for detailed config. * * @var array */ - private $order_statuses = array(); + protected $meta_column_mapping; /** - * Array of order ids with their initial status as key value pairs. + * Column mapping from source table to destination custom table. See __construct for detailed config. * * @var array */ - private $initial_order_statuses = array(); + protected $core_column_mapping; /** - * Class initialization, invoked by the DI container. + * MetaToCustomTableMigrator constructor. + */ + public function __construct() + { + } + /** + * Specify schema config the source and destination table. + * + * @return array Schema, must of the form: + * array( + 'source' => array( + 'entity' => array( + 'table_name' => $source_table_name, + 'meta_rel_column' => $column_meta, Name of column in source table which is referenced by meta table. + 'destination_rel_column' => $column_dest, Name of column in source table which is refenced by destination table, + 'primary_key' => $primary_key, Primary key of the source table + ), + 'meta' => array( + 'table' => $meta_table_name, + 'meta_key_column' => $meta_key_column_name, + 'meta_value_column' => $meta_value_column_name, + 'entity_id_column' => $entity_id_column, Name of the column having entity IDs. + ), + ), + 'destination' => array( + 'table_name' => $table_name, Name of destination table, + 'source_rel_column' => $column_source_id, Name of the column in destination table which is referenced by source table. + 'primary_key' => $table_primary_key, + 'primary_key_type' => $type bool|int|string|decimal + ) + */ + abstract protected function get_schema_config(): array; + /** + * Specify column config from the source table. * - * @internal + * @return array Config, must be of the form: + * array( + * '$source_column_name_1' => array( // $source_column_name_1 is column name in source table, or a select statement. + * 'type' => 'type of value, could be string/int/date/float.', + * 'destination' => 'name of the column in column name where this data should be inserted in.', + * ), + * '$source_column_name_2' => array( + * ...... + * ), + * .... + * ). */ - final public function init() + abstract protected function get_core_column_mapping(): array; + /** + * Specify meta keys config from source meta table. + * + * @return array Config, must be of the form. + * array( + * '$meta_key_1' => array( // $meta_key_1 is the name of meta_key in source meta table. + * 'type' => 'type of value, could be string/int/date/float', + * 'destination' => 'name of the column in column name where this data should be inserted in.', + * ), + * '$meta_key_2' => array( + * ...... + * ), + * .... + * ). + */ + abstract protected function get_meta_column_config(): array; + /** + * Generate SQL for data insertion. + * + * @param array $batch Data to generate queries for. Will be 'data' array returned by `$this->fetch_data_for_migration_for_ids()` method. + * + * @return string Generated queries for insertion for this batch, would be of the form: + * INSERT IGNORE INTO $table_name ($columns) values + * ($value for row 1) + * ($value for row 2) + * ... + */ + private function generate_insert_sql_for_batch(array $batch): string { } /** - * Refresh the cache for a given order type. + * Generate SQL for data updating. * - * @param string $order_type The order type. - * @return void + * @param array $batch Data to generate queries for. Will be `data` array returned by fetch_data_for_migration_for_ids() method. + * + * @param array $entity_row_mapping Maps rows to update data with their original IDs. Will be returned by `generate_update_sql_for_batch`. + * + * @return string Generated queries for batch update. Would be of the form: + * INSERT INTO $table ( $columns ) VALUES + * ($value for row 1) + * ($value for row 2) + * ... + * ON DUPLICATE KEY UPDATE + * $column1 = VALUES($column1) + * $column2 = VALUES($column2) + * ... */ - public function refresh_cache($order_type) + private function generate_update_sql_for_batch(array $batch, array $entity_row_mapping): string { } /** - * Register background caching for each order type. + * Generate schema for primary ID column of destination table. * - * @return void + * @return array[] Schema for primary ID column. */ - public function schedule_background_actions() + private function get_destination_table_primary_id_schema(): array { } /** - * Unschedules background actions. + * Generate values and columns clauses to be used in INSERT and INSERT..ON DUPLICATE KEY UPDATE statements. * - * @since 10.0.0 - * @internal + * @param array $columns_schema Columns config for destination table. + * @param array $batch Actual data to migrate as returned by `data` in `fetch_data_for_migration_for_ids` method. + * + * @return array SQL clause for values, columns placeholders, and columns. */ - public function unschedule_background_actions() + private function generate_column_clauses(array $columns_schema, array $batch): array { } /** - * Update the cache when a new order is made. + * Return data to be migrated for a batch of entities. * - * @param int $order_id Order id. - * @param WC_Order $order The order. + * @param array $entity_ids Ids of entities to migrate. + * + * @return array[] Data to be migrated. Would be of the form: array( 'data' => array( ... ), 'errors' => array( ... ) ). */ - public function update_on_new_order($order_id, $order) + public function fetch_sanitized_migration_data($entity_ids) { } /** - * Update the cache when an order is trashed. + * Migrate a batch of entities from the posts table to the corresponding table. * - * @param int $order_id Order id. - * @param WC_Order $order The order. + * @param array $entity_ids Ids of entities to migrate. + * + * @return void */ - public function update_on_order_trashed($order_id, $order) + protected function process_migration_batch_for_ids_core(array $entity_ids): void { } /** - * Update the cache when an order is deleted. + * Process migration data for a batch of entities. * - * @param int $order_id Order id. - * @param WC_Order $order The order. + * @param array $data Data to be migrated. Should be of the form: array( 'data' => array( ... ) ) as returned by the `fetch_sanitized_migration_data` method. + * + * @return array Array of errors and exception if any. */ - public function update_on_order_deleted($order_id, $order) + public function process_migration_data(array $data) { } /** - * Update the cache whenver an order status changes. + * Process batch for insertion into destination table. * - * @param int $order_id Order id. - * @param string $previous_status the old WooCommerce order status. - * @param string $next_status the new WooCommerce order status. - * @param WC_Order $order The order. + * @param array $batch Data to insert, will be of the form as returned by `data` in `fetch_data_for_migration_for_ids`. */ - public function update_on_order_status_changed($order_id, $previous_status, $next_status, $order) + private function process_insert_batch(array $batch): void { } /** - * Get the prefixed status. + * Process batch for update into destination table. * - * @param string $status The status. - * @return string + * @param array $batch Data to insert, will be of the form as returned by `data` in `fetch_data_for_migration_for_ids`. + * @param array $ids_mapping Maps rows to update data with their original IDs. */ - private function get_prefixed_status($status) + private function process_update_batch(array $batch, array $ids_mapping): void { } - } -} -namespace Automattic\WooCommerce\Caching { - /** - * Interface for cache engines used by objects inheriting from ObjectCache. - * Here "object" means either an array or an actual PHP object. - */ - interface CacheEngine - { /** - * Retrieves an object cached under a given key. + * Fetch data for migration. * - * @param string $key They key under which the object to retrieve is cached. - * @param string $group The group under which the object is cached. + * @param array $entity_ids Entity IDs to fetch data for. * - * @return array|object|null The cached object, or null if there's no object cached under the passed key. + * @return array[] Data along with errors (if any), will of the form: + * array( + * 'data' => array( + * 'id_1' => array( 'column1' => value1, 'column2' => value2, ...), + * ..., + * ), + * 'errors' => array( + * 'id_1' => array( 'column1' => error1, 'column2' => value2, ...), + * ..., + * ) */ - public function get_cached_object(string $key, string $group = ''); + private function fetch_data_for_migration_for_ids(array $entity_ids): array + { + } /** - * Caches an object under a given key, and with a given expiration. + * Fetch id mappings for records that are already inserted in the destination table. * - * @param string $key The key under which the object will be cached. - * @param array|object $object The object to cache. - * @param int $expiration Expiration for the cached object, in seconds. - * @param string $group The group under which the object will be cached. + * @param array $entity_ids List of entity IDs to verify. * - * @return bool True if the object is cached successfully, false otherwise. + * @return array Already migrated entities, would be of the form + * array( + * '$source_id1' => array( + * 'source_id' => $source_id1, + * 'destination_id' => $destination_id1 + * 'modified' => 0 if it can be determined that the row doesn't need update, 1 otherwise + * ), + * ... + * ) */ - public function cache_object(string $key, $object, int $expiration, string $group = ''): bool; + protected function get_already_existing_records(array $entity_ids): array + { + } /** - * Removes a cached object from the cache. - * - * @param string $key They key under which the object is cached. - * @param string $group The group under which the object is cached. + * Get additional string to be appended to the WHERE clause of the SQL query used by get_data_to_insert_or_update. * - * @return bool True if the object is removed from the cache successfully, false otherwise (because the object wasn't cached or for other reason). + * @param array $entity_ids The ids of the entities being inserted or updated. + * @return string Additional string for the WHERE clause, must either be empty or start with "AND" or "OR". */ - public function delete_cached_object(string $key, string $group = ''): bool; + protected function get_additional_where_clause_for_get_data_to_insert_or_update(array $entity_ids): string + { + } /** - * Checks if an object is cached under a given key. + * Helper method to build query used to fetch data from core source table. * - * @param string $key The key to verify. - * @param string $group The group under which the object is cached. + * @param array $entity_ids List of entity IDs to fetch. * - * @return bool True if there's an object cached under the given key, false otherwise. + * @return string Query that can be used to fetch data. */ - public function is_cached(string $key, string $group = ''): bool; + private function build_entity_table_query(array $entity_ids): string + { + } /** - * Deletes all cached objects under a given group. - * - * @param string $group The group to delete. + * Helper method to build query that will be used to fetch data from source meta table. * - * @return bool True if the group is deleted successfully, false otherwise. - */ - public function delete_cache_group(string $group = ''): bool; - } - /** - * Exception thrown by classes derived from ObjectCache. - */ - class CacheException extends \Exception - { - /** - * Error messages. + * @param array $entity_ids List of IDs to fetch metadata for. * - * @var array + * @return string Query for fetching meta data. */ - private $errors; + private function build_meta_data_query(array $entity_ids): string + { + } /** - * The object that threw the exception. + * Helper function to validate and combine data before we try to insert. * - * @var ObjectCache - */ - private $thrower; - /** - * The id of the cached object, if available. + * @param array $entity_data Data from source table. + * @param array $meta_data Data from meta table. * - * @var int|string|null + * @return array[] Validated and combined data with errors. */ - private $cached_id; + private function process_and_sanitize_data(array $entity_data, array $meta_data): array + { + } /** - * Creates a new instance of the class. + * Helper method to sanitize core source table. * - * @param string $message The exception message. - * @param ObjectCache $thrower The object that is throwing the exception. - * @param int|string|null $cached_id The involved cached object id, if available. - * @param array|null $errors An array of error messages, if available. - * @param mixed $code An error code, if available. - * @param \Throwable|null $previous The previous exception, if available. + * @param array $sanitized_entity_data Array containing sanitized data for insertion. + * @param array $error_records Error records. + * @param array $entity_data Original source data. */ - public function __construct(string $message, \Automattic\WooCommerce\Caching\ObjectCache $thrower, $cached_id = null, ?array $errors = null, $code = 0, ?\Throwable $previous = null) + private function process_and_sanitize_entity_data(array &$sanitized_entity_data, array &$error_records, array $entity_data): void { } /** - * Get a string representation of the exception object. + * Helper method to sanitize soure meta data. * - * @return string String representation of the exception object. + * @param array $sanitized_entity_data Array containing sanitized data for insertion. + * @param array $error_records Error records. + * @param array $meta_data Original source data. */ - public function __toString(): string + private function processs_and_sanitize_meta_data(array &$sanitized_entity_data, array &$error_records, array $meta_data): void { } /** - * Gets the array of error messages passed to the exception constructor. + * Validate and transform data so that we catch as many errors as possible before inserting. * - * @return array Error messages passed to the exception constructor. + * @param mixed $value Actual data value. + * @param string $type Type of data, could be decimal, int, date, string. + * + * @return float|int|mixed|string|\WP_Error */ - public function get_errors(): array + private function validate_data($value, string $type) { } /** - * Gets the object that threw the exception as passed to the exception constructor. + * Verify whether data was migrated properly for given IDs. * - * @return object The object that threw the exception. + * @param array $source_ids List of source IDs. + * + * @return array List of IDs along with columns that failed to migrate. */ - public function get_thrower(): object + public function verify_migrated_data(array $source_ids): array { } /** - * Gets the id of the cached object as passed to the exception constructor. + * Generate query to fetch data from both source and destination tables. Use the results in `verify_data` to verify if data was migrated properly. * - * @return int|string|null The id of the cached object. + * @param array $source_ids Array of IDs in source table. + * + * @return string SELECT statement. */ - public function get_cached_id() + protected function build_verification_query($source_ids) { } - } - /** - * Implementation of CacheEngine that uses the built-in WordPress cache. - */ - class WPCacheEngine implements \Automattic\WooCommerce\Caching\CacheEngine - { - use \Automattic\WooCommerce\Caching\CacheNameSpaceTrait; /** - * Retrieves an object cached under a given key. + * Fill source metadata for given IDs for verification. This will return filled data in following format: + * [ + * { + * $source_table_$source_column: $value, + * ..., + * $destination_table_$destination_column: $value, + * ... + * meta_source_{$destination_column_name1}: $meta_value, + * ... + * }, + * ... + * ] * - * @param string $key The key under which the object to retrieve is cached. - * @param string $group The group under which the object is cached. + * @param array $results Entity data from both source and destination table. + * @param array $source_ids List of source IDs. * - * @return array|object|null The cached object, or null if there's no object cached under the passed key. + * @return array Filled $results param with source metadata. */ - public function get_cached_object(string $key, string $group = '') + private function fill_source_metadata($results, $source_ids) { } /** - * Retrieves a set of objects cached under the given keys. + * Helper function to generate where clause for fetching data for verification. * - * @param string[] $keys The keys under which the object to retrieve is cached. - * @param string $group The group under which the object is cached. + * @param array $source_ids Array of IDs from source table. * - * @return array The cached array of objects keyed by the given keys, values will be null for any non-cached keys. + * @return string WHERE clause. */ - public function get_cached_objects(array $keys, string $group = '') + protected function get_where_clause_for_verification($source_ids) { } /** - * Caches an object under a given key, and with a given expiration. + * Verify data from both source and destination tables and check if they were migrated properly. * - * @param string $key The key under which the object will be cached. - * @param array|object $object The object to cache. - * @param int $expiration Expiration for the cached object, in seconds. - * @param string $group The group under which the object will be cached. + * @param array $collected_data Collected data in array format, should be in same structure as returned from query in `$this->build_verification_query`. * - * @return bool True if the object is cached successfully, false otherwise. + * @return array Array of failed IDs if any, along with columns/meta_key names. */ - public function cache_object(string $key, $object, int $expiration, string $group = ''): bool + protected function verify_data($collected_data) { } /** - * Caches an object under a given key, and with a given expiration. + * Helper method to verify and compare core columns. * - * @param array $objects The objects to cache keyed by the key to cache under. - * @param int $expiration Expiration for the cached object, in seconds. - * @param string $group The group under which the object will be cached. + * @param array $row Both migrated and source data for a single row. + * @param array $failed_ids Array of failed IDs. * - * @return array Array of return values, grouped by key. Each value is either - * true on success, or false on failure + * @return array Array of failed IDs if any, along with columns/meta_key names. */ - public function cache_objects(array $objects, int $expiration, string $group = ''): array + private function verify_entity_columns($row, $failed_ids) { } /** - * Removes a cached object from the cache. + * Helper method to verify meta columns. * - * @param string $key They key under which the object is cached. - * @param string $group The group under which the object is cached. + * @param array $row Both migrated and source data for a single row. + * @param array $failed_ids Array of failed IDs. * - * @return bool True if the object is removed from the cache successfully, false otherwise (because the object wasn't cached or for other reason). + * @return array Array of failed IDs if any, along with columns/meta_key names. */ - public function delete_cached_object(string $key, string $group = ''): bool + private function verify_meta_columns($row, $failed_ids) { } /** - * Checks if an object is cached under a given key. + * Helper method to pre-process rows to make sure we parse the correct type. * - * @param string $key The key to verify. - * @param string $group The group under which the object is cached. + * @param array $row Both migrated and source data for a single row. + * @param array $schema Column schema. + * @param string $alias Name of source column. + * @param string $destination_alias Name of destination column. * - * @return bool True if there's an object cached under the given key, false otherwise. + * @return array Processed row. */ - public function is_cached(string $key, string $group = ''): bool + private function pre_process_row($row, $schema, $alias, $destination_alias) { } /** - * Deletes all cached objects under a given group. + * Helper method to get default value of a type. * - * @param string $group The group to delete. + * @param string $type Type. * - * @return bool True if the group is deleted successfully, false otherwise. + * @return mixed Default value. */ - public function delete_cache_group(string $group = ''): bool + private function get_type_defaults($type) { } } } -namespace Automattic\WooCommerce\Checkout\Helpers { +namespace Automattic\WooCommerce\Database\Migrations\CustomOrderTable { /** - * Stock Reservation class. + * Helper class to migrate records from the WordPress post table + * to the custom order addresses table. + * + * @package Automattic\WooCommerce\Database\Migrations\CustomOrderTable */ - final class ReserveStock + class PostToOrderAddressTableMigrator extends \Automattic\WooCommerce\Database\Migrations\MetaToCustomTableMigrator { /** - * Is stock reservation enabled? + * Type of addresses being migrated; 'billing' or 'shipping'. * - * @var boolean + * @var $type */ - private $enabled = true; + protected $type; /** - * Constructor + * PostToOrderAddressTableMigrator constructor. + * + * @param string $type Type of address being migrated; 'billing' or 'shipping'. */ - public function __construct() + public function __construct($type) { } /** - * Is stock reservation enabled? + * Get schema config for wp_posts and wc_order_address table. * - * @return boolean + * @return array Config. */ - protected function is_enabled() + protected function get_schema_config(): array { } /** - * Query for any existing holds on stock for this item. - * - * @param \WC_Product $product Product to get reserved stock for. - * @param int $exclude_order_id Optional order to exclude from the results. + * Get columns config. * - * @return int|float Amount of stock already reserved. + * @return \string[][] Config. */ - public function get_reserved_stock($product, $exclude_order_id = 0) + protected function get_core_column_mapping(): array { } /** - * Put a temporary hold on stock for an order if enough is available. - * - * @throws ReserveStockException If stock cannot be reserved. + * Get meta data config. * - * @param \WC_Order $order Order object. - * @param int $minutes How long to reserve stock in minutes. Defaults to woocommerce_hold_stock_minutes. + * @return \string[][] Config. */ - public function reserve_stock_for_order($order, $minutes = 0) + public function get_meta_column_config(): array { } /** - * Release a temporary hold on stock for an order. + * Additional WHERE clause to only fetch the addresses of the current type. * - * @param \WC_Order $order Order object. + * @param array $entity_ids The ids of the entities being inserted or updated. + * @return string The additional string for the WHERE clause. */ - public function release_stock_for_order($order) + protected function get_additional_where_clause_for_get_data_to_insert_or_update(array $entity_ids): string { } /** - * Reserve stock for a product by inserting rows into the DB. + * Helper function to generate where clause for fetching data for verification. * - * @throws ReserveStockException If a row cannot be inserted. + * @param array $source_ids Array of IDs from source table. * - * @param int $product_id Product ID which is having stock reserved. - * @param int $stock_quantity Stock amount to reserve. - * @param \WC_Order $order Order object which contains the product. - * @param int $minutes How long to reserve stock in minutes. + * @return string WHERE clause. */ - private function reserve_stock_for_product($product_id, $stock_quantity, $order, $minutes) + protected function get_where_clause_for_verification($source_ids) { } + } + /** + * Helper class to migrate records from the WordPress post table + * to the custom order operations table. + * + * @package Automattic\WooCommerce\Database\Migrations\CustomOrderTable + */ + class PostToOrderOpTableMigrator extends \Automattic\WooCommerce\Database\Migrations\MetaToCustomTableMigrator + { /** - * Returns query statement for getting reserved stock of a product. + * Get schema config for wp_posts and wc_order_operational_detail table. * - * @param int $product_id Product ID. - * @param int $exclude_order_id Optional order to exclude from the results. - * @return string|void Query statement. + * @return array Config. */ - private function get_query_for_reserved_stock($product_id, $exclude_order_id = 0) + protected function get_schema_config(): array { } - } - /** - * ReserveStockException class. - */ - class ReserveStockException extends \Exception - { /** - * Sanitized error code. + * Get columns config. * - * @var string + * @return \string[][] Config. */ - protected $error_code; + protected function get_core_column_mapping(): array + { + } /** - * Error extra data. + * Get meta data config. * - * @var array + * @return \string[][] Config. */ - protected $error_data; + public function get_meta_column_config(): array + { + } + } + /** + * Helper class to migrate records from the WordPress post table + * to the custom order table (and only that table - PostsToOrdersMigrationController + * is used for fully migrating orders). + */ + class PostToOrderTableMigrator extends \Automattic\WooCommerce\Database\Migrations\MetaToCustomTableMigrator + { /** - * Setup exception. + * Get schema config for wp_posts and wc_order table. * - * @param string $code Machine-readable error code, e.g `woocommerce_invalid_product_id`. - * @param string $message User-friendly translated error message, e.g. 'Product ID is invalid'. - * @param int $http_status_code Proper HTTP status code to respond with, e.g. 400. - * @param array $data Extra error data. + * @return array Config. */ - public function __construct($code, $message, $http_status_code = 400, $data = array()) + protected function get_schema_config(): array { } /** - * Returns the error code. + * Get columns config. * - * @return string + * @return \string[][] Config. */ - public function getErrorCode() + protected function get_core_column_mapping(): array { } /** - * Returns error data. + * Get meta data config. * - * @return array + * @return \string[][] Config. */ - public function getErrorData() + public function get_meta_column_config(): array { } } -} -namespace Automattic\WooCommerce { /** - * PSR11 compliant dependency injection container for WooCommerce. - * - * Classes in the `src` directory should specify dependencies from that directory via an 'init' method having arguments - * with type hints. If an instance of the container itself is needed, the type hint to use is \Psr\Container\ContainerInterface. - * - * Classes in the `src` directory should interact with anything outside (especially code in the `includes` directory - * and WordPress functions) by using the classes in the `Proxies` directory. The exception is idempotent - * functions (e.g. `wp_parse_url`), those can be used directly. - * - * Classes in the `includes` directory should use the `wc_get_container` function to get the instance of the container when - * they need to get an instance of a class from the `src` directory. + * This is the main class used to perform the complete migration of orders + * from the posts table to the custom orders table. * - * Internally, an instance of RuntimeContainer will be used for the actual class resolution. This class uses reflection - * to instantiate classes and figure out dependencies, so there's no need for explicit class registration. - * When running the unit tests suite this will be replaced with an instance of TestingContainer, - * which provides additional functionality. + * @package Automattic\WooCommerce\Database\Migrations\CustomOrderTable */ - final class Container + class PostsToOrdersMigrationController { /** - * The underlying container. + * Error logger for migration errors. * - * @var RuntimeContainer + * @var \WC_Logger */ - private $container; + private $error_logger; /** - * Class constructor. + * Array of objects used to perform the migration. + * + * @var \Automattic\WooCommerce\Database\Migrations\TableMigrator[] + */ + private $all_migrators; + /** + * The source name to use for logs. + */ + public const LOGS_SOURCE_NAME = 'posts-to-orders-migration'; + /** + * PostsToOrdersMigrationController constructor. + */ + public function __construct() + { + } + /** + * Helper method to get migrated keys for all the tables in this controller. + * + * @return string[] Array of meta keys. + */ + public function get_migrated_meta_keys() + { + } + /** + * Migrates a set of orders from the posts table to the custom orders tables. + * + * @param array $order_post_ids List of post IDs of the orders to migrate. + */ + public function migrate_orders(array $order_post_ids): void + { + } + /** + * Log migration errors if any. + * + * @param array $order_post_ids List of post IDs of the orders to migrate. + * @param array $errors List of errors to log. + * @param \Exception|null $exception Exception to log. + * @param bool|null $using_transactions Whether transactions were used. + * @param string $name Name of the migrator. */ - public function __construct() + private function handle_migration_error(array $order_post_ids, array $errors, ?\Exception $exception, ?bool $using_transactions, string $name) { } /** - * Returns an instance of the specified class. - * See the comment about ContainerException in RuntimeContainer::get. - * - * @param string $id Class name. + * Clear the cache of order data for modified orders during migration if cache is enabled. * - * @return object Object instance. + * @param array $order_post_ids List of order IDs of the orders to clear from cache. * - * @throws ContainerException Error when resolving the class to an object instance, or class not found. - * @throws \Exception Exception thrown in the constructor or in the 'init' method of one of the resolved classes. + * @return void */ - public function get(string $id) + private function maybe_clear_order_datastore_cache_for_ids(array $order_post_ids) { } /** - * Returns true if the container can return an instance of the given class or false otherwise. - * See the comment in RuntimeContainer::has. + * Start a database transaction if the configuration mandates so. * - * @param class-string $id Class name. + * @return bool|null True if transaction started, false if transactions won't be used, null if transaction failed to start. * - * @return bool + * @throws \Exception If the transaction isolation level is invalid. */ - public function has(string $id): bool + private function maybe_start_transaction(): ?bool { } - } -} -namespace Automattic\WooCommerce\Database\Migrations\CustomOrderTable { - /** - * CLI tool for migrating order data to/from custom table. - * - * Credits https://github.com/liquidweb/woocommerce-custom-orders-table/blob/develop/includes/class-woocommerce-custom-orders-table-cli.php. - * - * Class CLIRunner - */ - class CLIRunner - { - /** - * CustomOrdersTableController instance. - * - * @var CustomOrdersTableController - */ - private $controller; /** - * DataSynchronizer instance. - * - * @var DataSynchronizer; - */ - private $synchronizer; - /** - * PostsToOrdersMigrationController instance. + * Commit the current database transaction. * - * @var PostsToOrdersMigrationController + * @return bool True on success, false on error. */ - private $post_to_cot_migrator; + private function commit_transaction(): bool + { + } /** - * Init method, invoked by DI container. - * - * @param CustomOrdersTableController $controller Instance. - * @param DataSynchronizer $synchronizer Instance. - * @param PostsToOrdersMigrationController $posts_to_orders_migration_controller Instance. + * Rollback the current database transaction. * - * @internal + * @return bool True on success, false on error. */ - final public function init(\Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController $controller, \Automattic\WooCommerce\Internal\DataStores\Orders\DataSynchronizer $synchronizer, \Automattic\WooCommerce\Database\Migrations\CustomOrderTable\PostsToOrdersMigrationController $posts_to_orders_migration_controller) + private function rollback_transaction(): bool { } /** - * Registers commands for CLI. + * Execute a database query and log any errors. + * + * @param string $query The SQL query to execute. + * @param bool $supress_errors Whether to suppress errors. + * + * @return bool True if the query succeeded, false if there were errors. */ - public function register_commands() + private function db_query(string $query, bool $supress_errors = false): bool { } /** - * Check if the COT feature is enabled. + * Verify whether the given order IDs were migrated properly or not. * - * @param bool $log Optionally log a error message. + * @param array $order_post_ids Order IDs. * - * @return bool Whether the COT feature is enabled. + * @return array Array of failed IDs along with columns. */ - private function is_enabled($log = true): bool + public function verify_migrated_orders(array $order_post_ids): array { } /** - * Free some in-memory usage. + * Migrates an order from the posts table to the custom orders tables. + * + * @param int $order_post_id Post ID of the order to migrate. */ - private function free_in_memory_usage() + public function migrate_order(int $order_post_id): void { } + } +} +namespace Automattic\WooCommerce\Database\Migrations { + /** + * Helper class to assist with migration related operations. + */ + class MigrationHelper + { /** - * Count how many orders have yet to be migrated into the custom orders table. - * - * ## EXAMPLES - * - * wp wc hpos count_unmigrated + * Placeholders that we will use in building $wpdb queries. * - * @param array $args Positional arguments passed to the command. + * @var string[] + */ + private static $wpdb_placeholder_for_type = array('int' => '%d', 'decimal' => '%f', 'string' => '%s', 'date' => '%s', 'date_epoch' => '%s', 'bool' => '%d'); + /** + * Helper method to escape backtick in various schema fields. * - * @param array $assoc_args Associative arguments (options) passed to the command. + * @param array $schema_config Schema config. * - * @return int The number of orders to be migrated.* + * @return array Schema config escaped for backtick. */ - public function count_unmigrated($args = array(), $assoc_args = array()): int + public static function escape_schema_for_backtick(array $schema_config): array { } /** - * Sync order data between the custom order tables and the core WordPress post tables. - * - * ## OPTIONS - * - * [--batch-size=] - * : The number of orders to process in each batch. - * --- - * default: 500 - * --- - * - * ## EXAMPLES + * Helper method to escape backtick in column and table names. + * WP does not provide a method to escape table/columns names yet, but hopefully soon in @link https://core.trac.wordpress.org/ticket/52506 * - * wp wc hpos sync --batch-size=500 + * @param string|array $identifier Column or table name. * - * @param array $args Positional arguments passed to the command. - * @param array $assoc_args Associative arguments (options) passed to the command. + * @return array|string|string[] Escaped identifier. */ - public function sync($args = array(), $assoc_args = array()) + public static function escape_and_add_backtick($identifier) { } /** - * [Deprecated] Use `wp wc hpos sync` instead. - * Copy order data into the postmeta table. - * - * Note that this could dramatically increase the size of your postmeta table, but is recommended - * if you wish to stop using the custom orders table plugin. - * - * ## OPTIONS - * - * [--batch-size=] - * : The number of orders to process in each batch. Passing a value of 0 will disable batching. - * --- - * default: 500 - * --- - * - * ## EXAMPLES + * Return $wpdb->prepare placeholder for data type. * - * # Copy all order data into the post meta table, 500 posts at a time. - * wp wc cot migrate --batch-size=500 + * @param string $type Data type. * - * @param array $args Positional arguments passed to the command. - * @param array $assoc_args Associative arguments (options) passed to the command. + * @return string $wpdb placeholder. */ - public function migrate(array $args = array(), array $assoc_args = array()) + public static function get_wpdb_placeholder_for_type(string $type): string { } /** - * Verify migrated order data with original posts data. - * - * ## OPTIONS - * - * [--batch-size=] - * : The number of orders to verify in each batch. - * --- - * default: 500 - * --- - * - * [--start-from=] - * : Order ID to start from. - * --- - * default: 0 - * --- - * - * [--end-at=] - * : Order ID to end at. - * --- - * default: -1 - * --- - * - * [--verbose] - * : Whether to output errors as they happen in batch, or output them all together at the end. - * --- - * default: false - * --- - * - * [--order-types] - * : Comma-separated list of order types that needs to be verified. For example, --order-types=shop_order,shop_order_refund - * --- - * default: Output of function `wc_get_order_types( 'cot-migration' )` - * - * [--re-migrate] - * : Attempt to re-migrate orders that failed verification. You should only use this option when you have never run the site with HPOS as authoritative source of order data yet, or you have manually checked the reported errors, otherwise, you risk stale data overwriting the more recent data. - * default: false - * - * ## EXAMPLES + * Generates ON DUPLICATE KEY UPDATE clause to be used in migration. * - * # Verify migrated order data, 500 orders at a time. - * wp wc hpos verify_cot_data --batch-size=500 --start-from=0 --end-at=10000 + * @param array $columns List of column names. * - * @param array $args Positional arguments passed to the command. - * @param array $assoc_args Associative arguments (options) passed to the command. + * @return string SQL clause for INSERT...ON DUPLICATE KEY UPDATE */ - public function verify_cot_data($args = array(), $assoc_args = array()) + public static function generate_on_duplicate_statement_clause(array $columns): string { } /** - * Helper method to get count for orders needing verification. - * - * @param int $order_id_start Order ID to start from. - * @param int $order_id_end Order ID to end at. - * @param array $order_types List of order types to verify. - * @param bool $log Whether to also log an error message. + * Migrate state codes in all the required places in the database, needed after they change for a given country. * - * @return int Order count. + * @param string $country_code The country that has the states for which the migration is needed. + * @param array $old_to_new_states_mapping An associative array where keys are the old state codes and values are the new state codes. + * @return bool True if there are more records that need to be migrated, false otherwise. */ - private function get_verify_order_count(int $order_id_start, int $order_id_end, array $order_types, bool $log = true): int + public static function migrate_country_states(string $country_code, array $old_to_new_states_mapping): bool { } /** - * Verify meta data as part of verifying the order object. - * - * @param array $order_ids Order IDs. - * @param array $failed_ids Array for storing failed IDs. + * Migrate state codes in all the required places in the database (except orders). * - * @return array Failed IDs with meta details. + * @param string $country_code The country that has the states for which the migration is needed. + * @param array $old_to_new_states_mapping An associative array where keys are the old state codes and values are the new state codes. + * @return void */ - private function verify_meta_data(array $order_ids, array $failed_ids): array + private static function migrate_country_states_for_misc_data(string $country_code, array $old_to_new_states_mapping): void { } /** - * Helper method to normalize response from meta queries into order_id > meta_key > meta_values. - * - * @param array $data Data fetched from meta queries. + * Migrate state codes in the shipping locations table. * - * @return array Normalized data. + * @param string $country_code The country that has the states for which the migration is needed. + * @param array $old_to_new_states_mapping An associative array where keys are the old state codes and values are the new state codes. + * @return void */ - private function normalize_raw_meta_data(array $data): array + private static function migrate_country_states_for_shipping_locations(string $country_code, array $old_to_new_states_mapping): void { } /** - * Set custom order tables (HPOS) to authoritative if: 1). HPOS and posts tables are in sync, or, 2). This is a new shop (in this case also create tables). Additionally, all installed WC plugins should be compatible. - * - * ## OPTIONS - * - * [--for-new-shop] - * : Enable only if this is a new shop, irrespective of whether tables are in sync. - * --- - * default: false - * --- - * - * [--with-sync] - * : Also enables sync (if it's currently not enabled). - * --- - * default: false - * --- - * - * [--ignore-plugin-compatibility] - * : Enable even if there are active plugins that are incompatible with HPOS. - * - * ### EXAMPLES - * - * # Enable HPOS on new shops. - * wp wc hpos enable --for-new-shop - * - * @param array $args Positional arguments passed to the command. - * @param array $assoc_args Associative arguments (options) passed to the command. + * Migrate the state code for the store location. * + * @param string $country_code The country that has the states for which the migration is needed. + * @param array $old_to_new_states_mapping An associative array where keys are the old state codes and values are the new state codes. * @return void */ - public function enable(array $args = array(), array $assoc_args = array()) + private static function migrate_country_states_for_store_location(string $country_code, array $old_to_new_states_mapping): void { } /** - * Disables custom order tables (HPOS) and posts to authoritative if HPOS and post tables are in sync. - * - * ## OPTIONS - * - * [--with-sync] - * : Also disables sync (if it's currently enabled). - * --- - * default: false - * --- - * - * ### EXAMPLES - * - * # Disable HPOS. - * wp wc hpos disable + * Migrate state codes for orders in the orders table and in the posts table. + * It will migrate only N*2*(number of states) records, being N equal to 100 by default + * but this number can be modified via the woocommerce_migrate_country_states_for_orders_batch_size filter. * - * @param array $args Positional arguments passed to the command. - * @param array $assoc_args Associative arguments (options) passed to the command. + * @param string $country_code The country that has the states for which the migration is needed. + * @param array $old_to_new_states_mapping An associative array where keys are the old state codes and values are the new state codes. + * @return bool True if there are more records that need to be migrated, false otherwise. */ - public function disable($args, $assoc_args) + private static function migrate_country_states_for_orders(string $country_code, array $old_to_new_states_mapping): bool { } /** - * When HPOS is enabled, this command lets you remove redundant data from the postmeta table for migrated orders. - * - * ## OPTIONS + * Migrate state codes in the tax rates table. * - * ... - * : ID or range of orders to clean up. + * @param string $country_code The country that has the states for which the migration is needed. + * @param array $old_to_new_states_mapping An associative array where keys are the old state codes and values are the new state codes. + * @return void + */ + private static function migrate_country_states_for_tax_rates(string $country_code, array $old_to_new_states_mapping): void + { + } + } +} +namespace Automattic\WooCommerce\Enums { + /** + * Enum class for all the catalog visibility values. + */ + final class CatalogVisibility + { + /** + * Product is visible on both shop and search results. * - * [--batch-size=] - * : Number of orders to process per batch. Applies only to cleaning up of 'all' orders. - * --- - * default: 500 - * --- + * @var string + */ + public const VISIBLE = 'visible'; + /** + * Product is visible on the shop page only. + */ + public const CATALOG = 'catalog'; + /** + * Product visible in the search results only. + */ + public const SEARCH = 'search'; + /** + * Product is invisible on both shop and search results, but can still be accessed directly. + */ + public const HIDDEN = 'hidden'; + } + /** + * Enum class for feature plugin compatibility. + */ + final class FeaturePluginCompatibility + { + /** + * Plugins are compatible by default with the feature. * - * [--force] - * : When true, post meta will be cleaned up even if the post appears to have been updated more recently than the order. - * --- - * default: false - * --- + * @var string + */ + public const COMPATIBLE = 'compatible'; + /** + * Plugins are incompatible by default with the feature. * - * ## EXAMPLES + * @var string + */ + public const INCOMPATIBLE = 'incompatible'; + /** + * Plugin compatibility with the feautre is yet to be determined. Internal use only. * - * # Cleanup post data for order 314. - * $ wp wc hpos cleanup 314 + * @internal + * @var string + */ + public const UNCERTAIN = 'uncertain'; + /** + * Valid values for registration of feature compatibility. * - * # Cleanup postmeta for orders with IDs between 10 and 100 and order 314. - * $ wp wc hpos cleanup 10-100 314 + * @var string[] + */ + public const VALID_REGISTRATION_VALUES = array(self::COMPATIBLE, self::INCOMPATIBLE); + } + /** + * Enum class for all the order statuses. + * + * For a full documentation on the public order statuses, please refer to the following link: + * https://woocommerce.com/document/managing-orders/order-statuses/ + */ + final class OrderStatus + { + /** + * The order has been received, but no payment has been made. * - * # Cleanup postmeta for all orders. - * wp wc hpos cleanup all + * @var string + */ + public const PENDING = 'pending'; + /** + * The customer’s payment failed or was declined, and no payment has been successfully made. * - * # Cleanup postmeta for all orders with a batch size of 200 (instead of the default 500). - * wp wc hpos cleanup all --batch-size=200 + * @var string + */ + public const FAILED = 'failed'; + /** + * The order is awaiting payment confirmation. * - * @param array $args Positional arguments passed to the command. - * @param array $assoc_args Associative arguments (options) passed to the command. - * @return void + * @var string */ - public function cleanup_post_data(array $args = array(), array $assoc_args = array()) - { - } + public const ON_HOLD = 'on-hold'; /** - * Displays a summary of HPOS situation on this site. + * Order fulfilled and complete. * - * @since 8.6.0 + * @var string + */ + public const COMPLETED = 'completed'; + /** + * Payment has been received (paid), and the stock has been reduced. * - * @param array $args Positional arguments passed to the command. - * @param array $assoc_args Associative arguments (options) passed to the command. + * @var string */ - public function status(array $args = array(), array $assoc_args = array()) - { - } + public const PROCESSING = 'processing'; /** - * Displays differences for an order between the HPOS and post datastore. + * Orders are automatically put in the Refunded status when an admin or shop manager has fully refunded the order’s value after payment. * - * ## OPTIONS + * @var string + */ + public const REFUNDED = 'refunded'; + /** + * The order was canceled by an admin or the customer. * - * - * :The ID of the order. + * @var string + */ + public const CANCELLED = 'cancelled'; + /** + * The order is in the trash. * - * [--format=] - * : Render output in a particular format. - * --- - * default: table - * options: - * - table - * - csv - * - json - * - yaml - * --- + * @var string + */ + public const TRASH = 'trash'; + /** + * The order is a draft (legacy status). * - * ## EXAMPLES + * @var string + */ + public const NEW = 'new'; + /** + * The order is an automatically generated draft. * - * # Find differences between datastores for order 123. - * $ wp wc hpos diff 123 + * @var string + */ + public const AUTO_DRAFT = 'auto-draft'; + /** + * Draft orders are created when customers start the checkout process while the block version of the checkout is in place. * - * # Find differences for order 123 and display as CSV. - * $ wp wc hpos diff 123 --format=csv + * @var string + */ + public const DRAFT = 'draft'; + /** + * Checkout Draft orders are created when customers start the checkout process while the block version of the checkout is in place. * - * @since 8.6.0 + * @var string + */ + public const CHECKOUT_DRAFT = 'checkout-draft'; + /** + * Array of all the valid order statuses for a complete payment. * - * @param array $args Positional arguments passed to the command. - * @param array $assoc_args Associative arguments (options) passed to the command. + * @var string[] */ - public function diff(array $args = array(), array $assoc_args = array()) - { - } + public const PAYMENT_COMPLETE_STATUSES = array(self::ON_HOLD, self::PENDING, self::FAILED, self::CANCELLED); + } + /** + * Enum class for all the payment gateway feature's values. + */ + final class PaymentGatewayFeature + { /** - * Backfills an order from either the HPOS or the posts datastore. + * Payment gateway supports add payment methods. * - * ## OPTIONS + * @var string + */ + public const ADD_PAYMENT_METHOD = 'add_payment_method'; + /** + * Payment gateway supports credit card form on saved method. * - * - * : The ID of the order. + * @var string + */ + public const CREDIT_CARD_FORM_CVC_ON_SAVED_METHOD = 'credit_card_form_cvc_on_saved_method'; + /** + * Payment gateway supports default credit card form. * - * --from= - * : Source datastore. Either 'hpos' or 'posts'. - * --- - * options: - * - hpos - * - posts - * --- + * @var string + */ + public const DEFAULT_CREDIT_CARD_FORM = 'default_credit_card_form'; + /** + * Payment gateway supports deposits. * - * --to= - * : Destination datastore. Either 'hpos' or 'posts'. - * --- - * options: - * - hpos - * - posts - * --- + * @var string + */ + public const DEPOSITS = 'deposits'; + /** + * Payment gateway supports multiple subscriptions. * - * [--meta_keys=] - * : Comma-separated list of meta keys to backfill. + * @var string + */ + public const MULTIPLE_SUBSCRIPTIONS = 'multiple_subscriptions'; + /** + * Payment gateway supports pay button. * - * [--props=] - * : Comma-separated list of order properties to backfill. + * @var string + */ + public const PAY_BUTTON = 'pay_button'; + /** + * Payment gateway supports pre-orders. * - * @since 8.6.0 + * @var string + */ + public const PRE_ORDERS = 'pre-orders'; + /** + * Payment gateway supports products. * - * @param array $args Positional arguments passed to the command. - * @param array $assoc_args Associative arguments (options) passed to the command. + * @var string */ - public function backfill(array $args = array(), array $assoc_args = array()) - { - } + public const PRODUCTS = 'products'; /** - * Show the list of WooCommerce-aware plugins known to be compatible, incompatible or without compatibility declaration for HPOS. Note that inactive plugins will always be listed in the "uncertain" list. + * Payment gateway supports refunds. * - * [--include-inactive] - * : Include inactive plugins in the list. + * @var string + */ + public const REFUNDS = 'refunds'; + /** + * Payment gateway supports subscription amount changes. * - * [--display-filenames] - * : Print plugin file names instead of plugin names. + * @var string + */ + public const SUBSCRIPTION_AMOUNT_CHANGES = 'subscription_amount_changes'; + /** + * Payment gateway supports subscription cancellation. * - * @since 9.1.0 + * @var string + */ + public const SUBSCRIPTION_CANCELLATION = 'subscription_cancellation'; + /** + * Payment gateway supports subscription date changes. * - * @param array $args Positional arguments passed to the command. - * @param array $assoc_args Associative arguments (options) passed to the command. + * @var string */ - public function compatibility_info(array $args = array(), array $assoc_args = array()): void - { - } + public const SUBSCRIPTION_DATE_CHANGES = 'subscription_date_changes'; /** - * Get the printable names for a set of plugins given their file names. + * Payment gateway supports subscription payment method changes. * - * @param array $plugins The plugin file names. - * @param bool $display_filenames True to simply return the sorted list of plugin file names. - * @return array A sorted array of plugin names or file names. + * @var string */ - private function get_printable_plugin_names(array $plugins, bool $display_filenames): array - { - } + public const SUBSCRIPTION_PAYMENT_METHOD_CHANGE = 'subscription_payment_method_change'; /** - * Print a list of plugin names. + * Payment gateway supports subscription payment method changes by admin. * - * @param array $plugins The names to print. + * @var string */ - private function print_plugin_names(array $plugins): void - { - } + public const SUBSCRIPTION_PAYMENT_METHOD_CHANGE_ADMIN = 'subscription_payment_method_change_admin'; /** - * Show a log message using the WP_CLI text colorization feature. + * Payment gateway supports subscription payment method changes by customer or admin. * - * @param string $text Text to show. + * @var string */ - private function log(string $text) - { - } + public const SUBSCRIPTION_PAYMENT_METHOD_CHANGE_CUSTOMER = 'subscription_payment_method_change_customer'; /** - * Enables compatibility mode, which keeps the HPOS and posts datastore in sync. + * Payment gateway supports subscription reactivation. * - * @since 9.1.0 + * @var string */ - public function enable_compat_mode(): void - { - } + public const SUBSCRIPTION_REACTIVATION = 'subscription_reactivation'; /** - * Disables compatibility mode, which keeps the HPOS and posts datastore in sync. + * Payment gateway supports subscription suspension. * - * @since 9.1.0 + * @var string */ - public function disable_compat_mode(): void - { - } + public const SUBSCRIPTION_SUSPENSION = 'subscription_suspension'; /** - * Toggles compatibility mode on or off. + * Payment gateway supports subscriptions. * - * @since 9.1.0 + * @var string + */ + public const SUBSCRIPTIONS = 'subscriptions'; + /** + * Payment gateway supports tokenization. * - * @param bool $enabled TRUE to enable compatibility mode, FALSE to disable. + * @var string */ - private function toggle_compat_mode(bool $enabled): void - { - } + public const TOKENIZATION = 'tokenization'; } -} -namespace Automattic\WooCommerce\Database\Migrations { /** - * Base class for implementing WP posts to order tables migrations handlers. - * It mainly contains methods to deal with error handling. - * - * @package Automattic\WooCommerce\Database\Migrations + * Enum class for all the product statuses. */ - abstract class TableMigrator + final class ProductStatus { /** - * An array of cumulated error messages. + * The product is in auto-draft status. * - * @var array + * @var string */ - private $errors; + public const AUTO_DRAFT = 'auto-draft'; /** - * Clear the error messages list. + * The product is in draft status. * - * @return void + * @var string */ - protected function clear_errors(): void - { - } + public const DRAFT = 'draft'; /** - * Add an error message to the errors list unless it's there already. + * The product is in pending status. * - * @param string $error The error message to add. - * @return void + * @var string */ - protected function add_error(string $error): void - { - } + public const PENDING = 'pending'; /** - * Get the list of error messages added. + * The product is in private status. * - * @return array + * @var string */ - protected function get_errors(): array - { - } + public const PRIVATE = 'private'; /** - * Run $wpdb->query and add the error, if any, to the errors list. + * The product is in publish status. * - * @param string $query The SQL query to run. - * @return mixed Whatever $wpdb->query returns. + * @var string */ - protected function db_query(string $query) - { - } + public const PUBLISH = 'publish'; /** - * Run $wpdb->get_results and add the error, if any, to the errors list. + * The product is in trash status. * - * @param string|null $query The SQL query to run. - * @param string $output Any of ARRAY_A | ARRAY_N | OBJECT | OBJECT_K constants. - * @return mixed Whatever $wpdb->get_results returns. + * @var string */ - protected function db_get_results(?string $query = null, string $output = OBJECT) - { - } + public const TRASH = 'trash'; /** - * Migrate a batch of orders, logging any database error that could arise and the exception thrown if any. - * - * @param array $entity_ids Order ids to migrate. - * @return array An array containing the keys 'errors' (array of strings) and 'exception' (exception object or null). + * The product is in future status. * - * @deprecated 8.0.0 Use `fetch_sanitized_migration_data` and `process_migration_data` instead. + * @var string */ - public function process_migration_batch_for_ids(array $entity_ids): array - { - } - // phpcs:disable Squiz.Commenting.FunctionComment.InvalidNoReturn, Squiz.Commenting.FunctionCommentThrowTag.Missing -- Methods are not marked abstract for back compat. + public const FUTURE = 'future'; + } + /** + * Enum class for all the product stock statuses. + */ + final class ProductStockStatus + { /** - * Return data to be migrated for a batch of entities. - * - * @param array $entity_ids Ids of entities to migrate. + * The product is in stock. * - * @return array[] Data to be migrated. Would be of the form: array( 'data' => array( ... ), 'errors' => array( ... ) ). + * @var string */ - public function fetch_sanitized_migration_data(array $entity_ids) - { - } + public const IN_STOCK = 'instock'; /** - * Process migration data for a batch of entities. - * - * @param array $data Data to be migrated. Should be of the form: array( 'data' => array( ... ) ) as returned by the `fetch_sanitized_migration_data` method. + * The product is out of stock. * - * @return array Array of errors and exception if any. + * @var string */ - public function process_migration_data(array $data) - { - } - // phpcs:enable + public const OUT_OF_STOCK = 'outofstock'; /** - * The core method that actually performs the migration for the supplied batch of order ids. - * It doesn't need to deal with database errors nor with exceptions. - * - * @param array $entity_ids Order ids to migrate. - * @return void + * The product is on backorder. * - * @deprecated 8.0.0 Use `fetch_sanitized_migration_data` and `process_migration_data` instead. + * @var string */ - abstract protected function process_migration_batch_for_ids_core(array $entity_ids): void; + public const ON_BACKORDER = 'onbackorder'; /** - * Check if the amount of processed database rows matches the amount of orders to process, and log an error if not. + * The product is low in stock. * - * @param string $operation Operation performed, 'insert' or 'update'. - * @param array|bool $received_rows_count Value returned by @wpdb after executing the query. - * @return void + * @var string */ - protected function maybe_add_insert_or_update_error(string $operation, $received_rows_count) - { - } + public const LOW_STOCK = 'lowstock'; } /** - * Base class for implementing migrations from the standard WordPress meta table - * to custom meta (key-value pairs) tables. - * - * @package Automattic\WooCommerce\Database\Migrations + * Enum class for all the product tax statuses. */ - abstract class MetaToMetaTableMigrator extends \Automattic\WooCommerce\Database\Migrations\TableMigrator + class ProductTaxStatus { /** - * Schema config, see __construct for more details. + * Tax status for products that are taxable. * - * @var array + * @var string */ - private $schema_config; + public const TAXABLE = 'taxable'; /** - * Returns config for the migration. + * Indicates that only the shipping cost should be taxed, not the product itself. * - * @return array Meta config, must be in following format: - * array( - * 'source' => array( - * 'meta' => array( - * 'table_name' => source_meta_table_name, - * 'entity_id_column' => entity_id column name in source meta table, - * 'meta_key_column' => meta_key column', - * 'meta_value_column' => meta_value column', - * ), - * 'entity' => array( - * 'table_name' => entity table name for the meta table, - * 'source_id_column' => column name in entity table which maps to meta table, - * 'id_column' => id column in entity table, - * ), - * 'excluded_keys' => array of keys to exclude, - * ), - * 'destination' => array( - * 'meta' => array( - * 'table_name' => destination meta table name, - * 'entity_id_column' => entity_id column in meta table, - * 'meta_key_column' => meta key column, - * 'meta_value_column' => meta_value column, - * 'entity_id_type' => data type of entity id, - * 'meta_id_column' => id column in meta table, - * ), - * ), - * ) + * @var string */ - abstract protected function get_meta_config(): array; + public const SHIPPING = 'shipping'; /** - * MetaToMetaTableMigrator constructor. + * Tax status for products that are not taxable. + * + * @var string */ - public function __construct() - { - } + public const NONE = 'none'; + } + /** + * Enum class for all the product types. + */ + final class ProductType + { /** - * Return data to be migrated for a batch of entities. - * - * @param array $entity_ids Ids of entities to migrate. + * Simple product type. * - * @return array[] Data to be migrated. Would be of the form: array( 'data' => array( ... ), 'errors' => array( ... ) ). + * @var string */ - public function fetch_sanitized_migration_data($entity_ids) - { - } + public const SIMPLE = 'simple'; /** - * Migrate a batch of entities from the posts table to the corresponding table. + * Variable product type. * - * @param array $entity_ids Ids of entities ro migrate. + * @var string */ - protected function process_migration_batch_for_ids_core(array $entity_ids): void - { - } + public const VARIABLE = 'variable'; /** - * Process migration data for a batch of entities. - * - * @param array $data Data to be migrated. Should be of the form: array( 'data' => array( ... ) ) as returned by the `fetch_sanitized_migration_data` method. + * Grouped product type. * - * @return array Array of errors and exception if any. + * @var string */ - public function process_migration_data(array $data) - { - } + public const GROUPED = 'grouped'; /** - * Generate update SQL for given batch. - * - * @param array $batch List of data to generate update SQL for. Should be in same format as output of $this->fetch_data_for_migration_for_ids. + * External/Affiliate product type. * - * @return string Query to update batch records. + * @var string */ - private function generate_update_sql_for_batch(array $batch): string - { - } + public const EXTERNAL = 'external'; /** - * Generate insert sql queries for batches. - * - * @param array $batch Data to generate queries for. + * Variation product type. * - * @return string Insert SQL query. + * @var string */ - private function generate_insert_sql_for_batch(array $batch): string - { - } + public const VARIATION = 'variation'; + } +} +namespace Automattic\WooCommerce\Internal\Admin\BlockTemplates { + /** + * Trait for block formatted template. + */ + trait BlockFormattedTemplateTrait + { /** - * Fetch data for migration. - * - * @param array $entity_ids Array of IDs to fetch data for. + * Get the block configuration as a formatted template. * - * @return array[] Data, will of the form: - * array( - * 'id_1' => array( 'column1' => array( value1_1, value1_2...), 'column2' => array(value2_1, value2_2...), ...), - * ..., - * ) + * @return array The block configuration as a formatted template. */ - public function fetch_data_for_migration_for_ids(array $entity_ids): array + public function get_formatted_template(): array { } /** - * Helper method to get already migrated records. Will be used to find prevent migration of already migrated records. - * - * @param array $entity_ids List of entity ids to check for. - * - * @return array Already migrated records. + * Get the block hide conditions formatted for inclusion in a formatted template. */ - private function get_already_migrated_records(array $entity_ids): array + private function get_formatted_hide_conditions(): array { } /** - * Classify each record on whether to migrate or update. - * - * @param array $to_migrate Records to migrate. - * @param array $already_migrated Records already migrated. - * - * @return array[] Returns two arrays, first for records to migrate, and second for records to upgrade. + * Get the block disable conditions formatted for inclusion in a formatted template. */ - private function classify_update_insert_records(array $to_migrate, array $already_migrated): array + private function get_formatted_disable_conditions(): array { } /** - * Helper method to build query used to fetch data from source meta table. - * - * @param array $entity_ids List of entity IDs to build meta query for. + * Formats conditions in the expected format to include in the template. * - * @return string Query that can be used to fetch data. + * @param array $conditions The conditions to format. */ - private function build_meta_table_query(array $entity_ids): string + private function format_conditions($conditions): array { } } -} -namespace Automattic\WooCommerce\Database\Migrations\CustomOrderTable { /** - * Helper class to migrate records from the WordPress post meta table - * to the custom orders meta table. - * - * @package Automattic\WooCommerce\Database\Migrations\CustomOrderTable + * Block configuration used to specify blocks in BlockTemplate. */ - class PostMetaToOrderMetaMigrator extends \Automattic\WooCommerce\Database\Migrations\MetaToMetaTableMigrator + class AbstractBlock implements \Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface { + use \Automattic\WooCommerce\Internal\Admin\BlockTemplates\BlockFormattedTemplateTrait; /** - * List of meta keys to exclude from migration. + * The block name. * - * @var array + * @var string */ - private $excluded_columns; + private $name; /** - * PostMetaToOrderMetaMigrator constructor. + * The block ID. * - * @param array $excluded_columns List of meta keys to exclude from migration. + * @var string */ - public function __construct($excluded_columns) - { - } + private $id; /** - * Generate config for meta data migration. + * The block order. * - * @return array Meta data migration config. + * @var int */ - protected function get_meta_config(): array - { - } - } -} -namespace Automattic\WooCommerce\Database\Migrations { - /** - * Base class for implementing migrations from the standard WordPress meta table - * to custom structured tables. - * - * @package Automattic\WooCommerce\Database\Migrations - */ - abstract class MetaToCustomTableMigrator extends \Automattic\WooCommerce\Database\Migrations\TableMigrator - { + private $order = 10000; /** - * Config for tables being migrated and migrated from. See __construct() for detailed config. + * The block attributes. * * @var array */ - protected $schema_config; + private $attributes = array(); /** - * Meta config, see __construct for detailed config. + * The block hide conditions. * * @var array */ - protected $meta_column_mapping; + private $hide_conditions = array(); /** - * Column mapping from source table to destination custom table. See __construct for detailed config. + * The block hide conditions counter. * - * @var array + * @var int */ - protected $core_column_mapping; + private $hide_conditions_counter = 0; /** - * MetaToCustomTableMigrator constructor. + * The block disable conditions. + * + * @var array */ - public function __construct() - { - } + private $disable_conditions = array(); /** - * Specify schema config the source and destination table. - * - * @return array Schema, must of the form: - * array( - 'source' => array( - 'entity' => array( - 'table_name' => $source_table_name, - 'meta_rel_column' => $column_meta, Name of column in source table which is referenced by meta table. - 'destination_rel_column' => $column_dest, Name of column in source table which is refenced by destination table, - 'primary_key' => $primary_key, Primary key of the source table - ), - 'meta' => array( - 'table' => $meta_table_name, - 'meta_key_column' => $meta_key_column_name, - 'meta_value_column' => $meta_value_column_name, - 'entity_id_column' => $entity_id_column, Name of the column having entity IDs. - ), - ), - 'destination' => array( - 'table_name' => $table_name, Name of destination table, - 'source_rel_column' => $column_source_id, Name of the column in destination table which is referenced by source table. - 'primary_key' => $table_primary_key, - 'primary_key_type' => $type bool|int|string|decimal - ) - */ - abstract protected function get_schema_config(): array; + * The block disable conditions counter. + * + * @var int + */ + private $disable_conditions_counter = 0; /** - * Specify column config from the source table. + * The block template that this block belongs to. * - * @return array Config, must be of the form: - * array( - * '$source_column_name_1' => array( // $source_column_name_1 is column name in source table, or a select statement. - * 'type' => 'type of value, could be string/int/date/float.', - * 'destination' => 'name of the column in column name where this data should be inserted in.', - * ), - * '$source_column_name_2' => array( - * ...... - * ), - * .... - * ). + * @var BlockTemplate */ - abstract protected function get_core_column_mapping(): array; + private $root_template; /** - * Specify meta keys config from source meta table. + * The parent container. * - * @return array Config, must be of the form. - * array( - * '$meta_key_1' => array( // $meta_key_1 is the name of meta_key in source meta table. - * 'type' => 'type of value, could be string/int/date/float', - * 'destination' => 'name of the column in column name where this data should be inserted in.', - * ), - * '$meta_key_2' => array( - * ...... - * ), - * .... - * ). + * @var ContainerInterface */ - abstract protected function get_meta_column_config(): array; + private $parent; /** - * Generate SQL for data insertion. + * Block constructor. * - * @param array $batch Data to generate queries for. Will be 'data' array returned by `$this->fetch_data_for_migration_for_ids()` method. + * @param array $config The block configuration. + * @param BlockTemplateInterface $root_template The block template that this block belongs to. + * @param BlockContainerInterface|null $parent The parent block container. * - * @return string Generated queries for insertion for this batch, would be of the form: - * INSERT IGNORE INTO $table_name ($columns) values - * ($value for row 1) - * ($value for row 2) - * ... + * @throws \ValueError If the block configuration is invalid. + * @throws \ValueError If the parent block container does not belong to the same template as the block. */ - private function generate_insert_sql_for_batch(array $batch): string + public function __construct(array $config, \Automattic\WooCommerce\Admin\BlockTemplates\BlockTemplateInterface &$root_template, ?\Automattic\WooCommerce\Admin\BlockTemplates\ContainerInterface &$parent = null) { } /** - * Generate SQL for data updating. - * - * @param array $batch Data to generate queries for. Will be `data` array returned by fetch_data_for_migration_for_ids() method. + * Validate block configuration. * - * @param array $entity_row_mapping Maps rows to update data with their original IDs. Will be returned by `generate_update_sql_for_batch`. + * @param array $config The block configuration. + * @param BlockTemplateInterface $root_template The block template that this block belongs to. + * @param ContainerInterface|null $parent The parent block container. * - * @return string Generated queries for batch update. Would be of the form: - * INSERT INTO $table ( $columns ) VALUES - * ($value for row 1) - * ($value for row 2) - * ... - * ON DUPLICATE KEY UPDATE - * $column1 = VALUES($column1) - * $column2 = VALUES($column2) - * ... + * @throws \ValueError If the block configuration is invalid. + * @throws \ValueError If the parent block container does not belong to the same template as the block. */ - private function generate_update_sql_for_batch(array $batch, array $entity_row_mapping): string + protected function validate(array $config, \Automattic\WooCommerce\Admin\BlockTemplates\BlockTemplateInterface &$root_template, ?\Automattic\WooCommerce\Admin\BlockTemplates\ContainerInterface &$parent = null) { } /** - * Generate schema for primary ID column of destination table. - * - * @return array[] Schema for primary ID column. + * Get the block name. */ - private function get_destination_table_primary_id_schema(): array + public function get_name(): string { } /** - * Generate values and columns clauses to be used in INSERT and INSERT..ON DUPLICATE KEY UPDATE statements. - * - * @param array $columns_schema Columns config for destination table. - * @param array $batch Actual data to migrate as returned by `data` in `fetch_data_for_migration_for_ids` method. - * - * @return array SQL clause for values, columns placeholders, and columns. + * Get the block ID. */ - private function generate_column_clauses(array $columns_schema, array $batch): array + public function get_id(): string { } /** - * Return data to be migrated for a batch of entities. - * - * @param array $entity_ids Ids of entities to migrate. - * - * @return array[] Data to be migrated. Would be of the form: array( 'data' => array( ... ), 'errors' => array( ... ) ). + * Get the block order. */ - public function fetch_sanitized_migration_data($entity_ids) + public function get_order(): int { } /** - * Migrate a batch of entities from the posts table to the corresponding table. - * - * @param array $entity_ids Ids of entities to migrate. + * Set the block order. * - * @return void + * @param int $order The block order. */ - protected function process_migration_batch_for_ids_core(array $entity_ids): void + public function set_order(int $order) { } /** - * Process migration data for a batch of entities. - * - * @param array $data Data to be migrated. Should be of the form: array( 'data' => array( ... ) ) as returned by the `fetch_sanitized_migration_data` method. - * - * @return array Array of errors and exception if any. + * Get the block attributes. */ - public function process_migration_data(array $data) + public function get_attributes(): array { } /** - * Process batch for insertion into destination table. + * Set the block attributes. * - * @param array $batch Data to insert, will be of the form as returned by `data` in `fetch_data_for_migration_for_ids`. + * @param array $attributes The block attributes. */ - private function process_insert_batch(array $batch): void + public function set_attributes(array $attributes) { } /** - * Process batch for update into destination table. + * Set a block attribute value without replacing the entire attributes object. * - * @param array $batch Data to insert, will be of the form as returned by `data` in `fetch_data_for_migration_for_ids`. - * @param array $ids_mapping Maps rows to update data with their original IDs. + * @param string $key The attribute key. + * @param mixed $value The attribute value. */ - private function process_update_batch(array $batch, array $ids_mapping): void + public function set_attribute(string $key, $value) { } /** - * Fetch data for migration. - * - * @param array $entity_ids Entity IDs to fetch data for. - * - * @return array[] Data along with errors (if any), will of the form: - * array( - * 'data' => array( - * 'id_1' => array( 'column1' => value1, 'column2' => value2, ...), - * ..., - * ), - * 'errors' => array( - * 'id_1' => array( 'column1' => error1, 'column2' => value2, ...), - * ..., - * ) + * Get the template that this block belongs to. */ - private function fetch_data_for_migration_for_ids(array $entity_ids): array + public function &get_root_template(): \Automattic\WooCommerce\Admin\BlockTemplates\BlockTemplateInterface { } /** - * Fetch id mappings for records that are already inserted in the destination table. - * - * @param array $entity_ids List of entity IDs to verify. - * - * @return array Already migrated entities, would be of the form - * array( - * '$source_id1' => array( - * 'source_id' => $source_id1, - * 'destination_id' => $destination_id1 - * 'modified' => 0 if it can be determined that the row doesn't need update, 1 otherwise - * ), - * ... - * ) + * Get the parent block container. */ - protected function get_already_existing_records(array $entity_ids): array + public function &get_parent(): \Automattic\WooCommerce\Admin\BlockTemplates\ContainerInterface { } /** - * Get additional string to be appended to the WHERE clause of the SQL query used by get_data_to_insert_or_update. + * Remove the block from its parent. + */ + public function remove() + { + } + /** + * Check if the block is detached from its parent block container or the template it belongs to. * - * @param array $entity_ids The ids of the entities being inserted or updated. - * @return string Additional string for the WHERE clause, must either be empty or start with "AND" or "OR". + * @return bool True if the block is detached from its parent block container or the template it belongs to. */ - protected function get_additional_where_clause_for_get_data_to_insert_or_update(array $entity_ids): string + public function is_detached(): bool { } /** - * Helper method to build query used to fetch data from core source table. + * Add a hide condition to the block. * - * @param array $entity_ids List of entity IDs to fetch. + * The hide condition is a JavaScript-like expression that will be evaluated on the client to determine if the block should be hidden. + * See [@woocommerce/expression-evaluation](https://github.com/woocommerce/woocommerce/blob/trunk/packages/js/expression-evaluation/README.md) for more details. * - * @return string Query that can be used to fetch data. + * @param string $expression An expression, which if true, will hide the block. */ - private function build_entity_table_query(array $entity_ids): string + public function add_hide_condition(string $expression): string { } /** - * Helper method to build query that will be used to fetch data from source meta table. - * - * @param array $entity_ids List of IDs to fetch metadata for. + * Remove a hide condition from the block. * - * @return string Query for fetching meta data. + * @param string $key The key of the hide condition to remove. */ - private function build_meta_data_query(array $entity_ids): string + public function remove_hide_condition(string $key) { } /** - * Helper function to validate and combine data before we try to insert. + * Get the hide conditions of the block. + */ + public function get_hide_conditions(): array + { + } + /** + * Add a disable condition to the block. * - * @param array $entity_data Data from source table. - * @param array $meta_data Data from meta table. + * The disable condition is a JavaScript-like expression that will be evaluated on the client to determine if the block should be hidden. + * See [@woocommerce/expression-evaluation](https://github.com/woocommerce/woocommerce/blob/trunk/packages/js/expression-evaluation/README.md) for more details. * - * @return array[] Validated and combined data with errors. + * @param string $expression An expression, which if true, will disable the block. */ - private function process_and_sanitize_data(array $entity_data, array $meta_data): array + public function add_disable_condition(string $expression): string { } /** - * Helper method to sanitize core source table. + * Remove a disable condition from the block. * - * @param array $sanitized_entity_data Array containing sanitized data for insertion. - * @param array $error_records Error records. - * @param array $entity_data Original source data. + * @param string $key The key of the disable condition to remove. */ - private function process_and_sanitize_entity_data(array &$sanitized_entity_data, array &$error_records, array $entity_data): void + public function remove_disable_condition(string $key) { } /** - * Helper method to sanitize soure meta data. - * - * @param array $sanitized_entity_data Array containing sanitized data for insertion. - * @param array $error_records Error records. - * @param array $meta_data Original source data. + * Get the disable conditions of the block. */ - private function processs_and_sanitize_meta_data(array &$sanitized_entity_data, array &$error_records, array $meta_data): void + public function get_disable_conditions(): array { } + } + /** + * Trait for block containers. + */ + trait BlockContainerTrait + { + use \Automattic\WooCommerce\Internal\Admin\BlockTemplates\BlockFormattedTemplateTrait { + get_formatted_template as get_block_formatted_template; + } /** - * Validate and transform data so that we catch as many errors as possible before inserting. + * The inner blocks. * - * @param mixed $value Actual data value. - * @param string $type Type of data, could be decimal, int, date, string. + * @var BlockInterface[] + */ + private $inner_blocks = array(); + // phpcs doesn't take into account exceptions thrown by called methods. + // phpcs:disable Squiz.Commenting.FunctionCommentThrowTag.WrongNumber + /** + * Add a block to the block container. * - * @return float|int|mixed|string|\WP_Error + * @param BlockInterface $block The block. + * + * @throws \ValueError If the block configuration is invalid. + * @throws \ValueError If a block with the specified ID already exists in the template. + * @throws \UnexpectedValueException If the block container is not the parent of the block. + * @throws \UnexpectedValueException If the block container's root template is not the same as the block's root template. */ - private function validate_data($value, string $type) + protected function &add_inner_block(\Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface $block): \Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface { } + // phpcs:enable Squiz.Commenting.FunctionCommentThrowTag.WrongNumber /** - * Verify whether data was migrated properly for given IDs. - * - * @param array $source_ids List of source IDs. + * Checks if a block is a descendant of the block container. * - * @return array List of IDs along with columns that failed to migrate. + * @param BlockInterface $block The block. */ - public function verify_migrated_data(array $source_ids): array + private function is_block_descendant(\Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface $block): bool { } /** - * Generate query to fetch data from both source and destination tables. Use the results in `verify_data` to verify if data was migrated properly. - * - * @param array $source_ids Array of IDs in source table. + * Get a block by ID. * - * @return string SELECT statement. + * @param string $block_id The block ID. */ - protected function build_verification_query($source_ids) + public function get_block(string $block_id): ?\Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface { } /** - * Fill source metadata for given IDs for verification. This will return filled data in following format: - * [ - * { - * $source_table_$source_column: $value, - * ..., - * $destination_table_$destination_column: $value, - * ... - * meta_source_{$destination_column_name1}: $meta_value, - * ... - * }, - * ... - * ] + * Remove a block from the block container. * - * @param array $results Entity data from both source and destination table. - * @param array $source_ids List of source IDs. + * @param string $block_id The block ID. * - * @return array Filled $results param with source metadata. + * @throws \UnexpectedValueException If the block container is not an ancestor of the block. */ - private function fill_source_metadata($results, $source_ids) + public function remove_block(string $block_id) { } /** - * Helper function to generate where clause for fetching data for verification. - * - * @param array $source_ids Array of IDs from source table. - * - * @return string WHERE clause. + * Remove all blocks from the block container. */ - protected function get_where_clause_for_verification($source_ids) + public function remove_blocks() { } /** - * Verify data from both source and destination tables and check if they were migrated properly. - * - * @param array $collected_data Collected data in array format, should be in same structure as returned from query in `$this->build_verification_query`. + * Remove a block from the block container's inner blocks. This is an internal method and should not be called directly + * except for from the BlockContainerTrait's remove_block() method. * - * @return array Array of failed IDs if any, along with columns/meta_key names. + * @param BlockInterface $block The block. */ - protected function verify_data($collected_data) + public function remove_inner_block(\Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface $block) { } /** - * Helper method to verify and compare core columns. - * - * @param array $row Both migrated and source data for a single row. - * @param array $failed_ids Array of failed IDs. - * - * @return array Array of failed IDs if any, along with columns/meta_key names. + * Get the inner blocks sorted by order. */ - private function verify_entity_columns($row, $failed_ids) + private function get_inner_blocks_sorted_by_order(): array { } /** - * Helper method to verify meta columns. + * Get the inner blocks as a formatted template. + */ + public function get_formatted_template(): array + { + } + /** + * Do the `woocommerce_block_template_after_add_block` action. + * Handle exceptions thrown by the action. * - * @param array $row Both migrated and source data for a single row. - * @param array $failed_ids Array of failed IDs. + * @param BlockInterface $block The block. + */ + private function do_after_add_block_action(\Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface $block) + { + } + /** + * Do the `woocommerce_block_template_area_{template_area}_after_add_block_{block_id}` action. + * Handle exceptions thrown by the action. * - * @return array Array of failed IDs if any, along with columns/meta_key names. + * @param BlockInterface $block The block. */ - private function verify_meta_columns($row, $failed_ids) + private function do_after_add_specific_block_action(\Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface $block) { } /** - * Helper method to pre-process rows to make sure we parse the correct type. + * Do the `woocommerce_block_after_add_block_error` action. * - * @param array $row Both migrated and source data for a single row. - * @param array $schema Column schema. - * @param string $alias Name of source column. - * @param string $destination_alias Name of destination column. + * @param BlockInterface $block The block. + * @param string $action The action that threw the exception. + * @param \Exception $e The exception. + */ + private function do_after_add_block_error_action(\Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface $block, string $action, \Exception $e) + { + } + /** + * Do the `woocommerce_block_template_after_remove_block` action. + * Handle exceptions thrown by the action. * - * @return array Processed row. + * @param BlockInterface $block The block. */ - private function pre_process_row($row, $schema, $alias, $destination_alias) + private function do_after_remove_block_action(\Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface $block) { } /** - * Helper method to get default value of a type. + * Do the `woocommerce_block_template_area_{template_area}_after_remove_block_{block_id}` action. + * Handle exceptions thrown by the action. * - * @param string $type Type. + * @param BlockInterface $block The block. + */ + private function do_after_remove_specific_block_action(\Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface $block) + { + } + /** + * Do the `woocommerce_block_after_remove_block_error` action. * - * @return mixed Default value. + * @param BlockInterface $block The block. + * @param string $action The action that threw the exception. + * @param \Exception $e The exception. */ - private function get_type_defaults($type) + private function do_after_remove_block_error_action(\Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface $block, string $action, \Exception $e) { } } -} -namespace Automattic\WooCommerce\Database\Migrations\CustomOrderTable { /** - * Helper class to migrate records from the WordPress post table - * to the custom order addresses table. - * - * @package Automattic\WooCommerce\Database\Migrations\CustomOrderTable + * Block template class. */ - class PostToOrderAddressTableMigrator extends \Automattic\WooCommerce\Database\Migrations\MetaToCustomTableMigrator + abstract class AbstractBlockTemplate implements \Automattic\WooCommerce\Admin\BlockTemplates\BlockTemplateInterface { + use \Automattic\WooCommerce\Internal\Admin\BlockTemplates\BlockContainerTrait; /** - * Type of addresses being migrated; 'billing' or 'shipping'. + * Get the template ID. + */ + abstract public function get_id(): string; + /** + * Get the template title. + */ + public function get_title(): string + { + } + /** + * Get the template description. + */ + public function get_description(): string + { + } + /** + * Get the template area. + */ + public function get_area(): string + { + } + /** + * The block cache. * - * @var $type + * @var BlockInterface[] */ - protected $type; + private $block_cache = []; /** - * PostToOrderAddressTableMigrator constructor. + * Get a block by ID. * - * @param string $type Type of address being migrated; 'billing' or 'shipping'. + * @param string $block_id The block ID. */ - public function __construct($type) + public function get_block(string $block_id): ?\Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface { } /** - * Get schema config for wp_posts and wc_order_address table. + * Caches a block in the template. This is an internal method and should not be called directly + * except for from the BlockContainerTrait's add_inner_block() method. * - * @return array Config. + * @param BlockInterface $block The block to cache. + * + * @throws \ValueError If a block with the specified ID already exists in the template. + * @throws \ValueError If the block template that the block belongs to is not this template. + * + * @ignore */ - protected function get_schema_config(): array + public function cache_block(\Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface &$block) { } /** - * Get columns config. + * Uncaches a block in the template. This is an internal method and should not be called directly + * except for from the BlockContainerTrait's remove_block() method. * - * @return \string[][] Config. + * @param string $block_id The block ID. + * + * @ignore */ - protected function get_core_column_mapping(): array + public function uncache_block(string $block_id) { } /** - * Get meta data config. + * Generate a block ID based on a base. * - * @return \string[][] Config. + * @param string $id_base The base to use when generating an ID. + * @return string */ - public function get_meta_column_config(): array + public function generate_block_id(string $id_base): string { } /** - * Additional WHERE clause to only fetch the addresses of the current type. + * Get the root template. + */ + public function &get_root_template(): \Automattic\WooCommerce\Admin\BlockTemplates\BlockTemplateInterface + { + } + /** + * Get the inner blocks as a formatted template. + */ + public function get_formatted_template(): array + { + } + /** + * Get the template as JSON like array. * - * @param array $entity_ids The ids of the entities being inserted or updated. - * @return string The additional string for the WHERE clause. + * @return array The JSON. */ - protected function get_additional_where_clause_for_get_data_to_insert_or_update(array $entity_ids): string + public function to_json(): array { } + } + /** + * Generic block with container properties to be used in BlockTemplate. + */ + class Block extends \Automattic\WooCommerce\Internal\Admin\BlockTemplates\AbstractBlock implements \Automattic\WooCommerce\Admin\BlockTemplates\BlockContainerInterface + { + use \Automattic\WooCommerce\Internal\Admin\BlockTemplates\BlockContainerTrait; /** - * Helper function to generate where clause for fetching data for verification. + * Add an inner block to this block. * - * @param array $source_ids Array of IDs from source table. + * @param array $block_config The block data. + */ + public function &add_block(array $block_config): \Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface + { + } + } + /** + * Block template class. + */ + class BlockTemplate extends \Automattic\WooCommerce\Internal\Admin\BlockTemplates\AbstractBlockTemplate + { + /** + * Get the template ID. + */ + public function get_id(): string + { + } + /** + * Add an inner block to this template. * - * @return string WHERE clause. + * @param array $block_config The block data. */ - protected function get_where_clause_for_verification($source_ids) + public function add_block(array $block_config): \Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface { } } /** - * Helper class to migrate records from the WordPress post table - * to the custom order operations table. - * - * @package Automattic\WooCommerce\Database\Migrations\CustomOrderTable + * Logger for block template modifications. */ - class PostToOrderOpTableMigrator extends \Automattic\WooCommerce\Database\Migrations\MetaToCustomTableMigrator + class BlockTemplateLogger { + const BLOCK_ADDED = 'block_added'; + const BLOCK_REMOVED = 'block_removed'; + const BLOCK_MODIFIED = 'block_modified'; + const BLOCK_ADDED_TO_DETACHED_CONTAINER = 'block_added_to_detached_container'; + const HIDE_CONDITION_ADDED = 'hide_condition_added'; + const HIDE_CONDITION_REMOVED = 'hide_condition_removed'; + const HIDE_CONDITION_ADDED_TO_DETACHED_BLOCK = 'hide_condition_added_to_detached_block'; + const ERROR_AFTER_BLOCK_ADDED = 'error_after_block_added'; + const ERROR_AFTER_BLOCK_REMOVED = 'error_after_block_removed'; + const LOG_HASH_TRANSIENT_BASE_NAME = 'wc_block_template_events_log_hash_'; /** - * Get schema config for wp_posts and wc_order_operational_detail table. + * Event types. + * + * @var array + */ + public static $event_types = array(self::BLOCK_ADDED => array('level' => \WC_Log_Levels::DEBUG, 'message' => 'Block added to template.'), self::BLOCK_REMOVED => array('level' => \WC_Log_Levels::NOTICE, 'message' => 'Block removed from template.'), self::BLOCK_MODIFIED => array('level' => \WC_Log_Levels::NOTICE, 'message' => 'Block modified in template.'), self::BLOCK_ADDED_TO_DETACHED_CONTAINER => array('level' => \WC_Log_Levels::WARNING, 'message' => 'Block added to detached container. Block will not be included in the template, since the container will not be included in the template.'), self::HIDE_CONDITION_ADDED => array('level' => \WC_Log_Levels::NOTICE, 'message' => 'Hide condition added to block.'), self::HIDE_CONDITION_REMOVED => array('level' => \WC_Log_Levels::NOTICE, 'message' => 'Hide condition removed from block.'), self::HIDE_CONDITION_ADDED_TO_DETACHED_BLOCK => array('level' => \WC_Log_Levels::WARNING, 'message' => 'Hide condition added to detached block. Block will not be included in the template, so the hide condition is not needed.'), self::ERROR_AFTER_BLOCK_ADDED => array('level' => \WC_Log_Levels::WARNING, 'message' => 'Error after block added to template.'), self::ERROR_AFTER_BLOCK_REMOVED => array('level' => \WC_Log_Levels::WARNING, 'message' => 'Error after block removed from template.')); + /** + * Singleton instance. + * + * @var BlockTemplateLogger + */ + protected static $instance = null; + /** + * Logger instance. + * + * @var \WC_Logger + */ + protected $logger = null; + /** + * All template events. + * + * @var array + */ + private $all_template_events = array(); + /** + * Templates. + * + * @var array + */ + private $templates = array(); + /** + * Threshold severity. * - * @return array Config. + * @var int */ - protected function get_schema_config(): array + private $threshold_severity = null; + /** + * Get the singleton instance. + */ + public static function get_instance(): \Automattic\WooCommerce\Internal\Admin\BlockTemplates\BlockTemplateLogger { } /** - * Get columns config. - * - * @return \string[][] Config. + * Constructor. */ - protected function get_core_column_mapping(): array + protected function __construct() { } /** - * Get meta data config. + * Get all template events for a given template as a JSON like array. * - * @return \string[][] Config. + * @param string $template_id Template ID. */ - public function get_meta_column_config(): array + public function template_events_to_json(string $template_id): array { } - } - /** - * Helper class to migrate records from the WordPress post table - * to the custom order table (and only that table - PostsToOrdersMigrationController - * is used for fully migrating orders). - */ - class PostToOrderTableMigrator extends \Automattic\WooCommerce\Database\Migrations\MetaToCustomTableMigrator - { /** - * Get schema config for wp_posts and wc_order table. + * Get all template events as a JSON like array. * - * @return array Config. + * @param array $template_events Template events. + * + * @return array The JSON. */ - protected function get_schema_config(): array + private function to_json(array $template_events): array { } /** - * Get columns config. + * Log all template events for a given template to the log file. * - * @return \string[][] Config. + * @param string $template_id Template ID. */ - protected function get_core_column_mapping(): array + public function log_template_events_to_file(string $template_id) { } /** - * Get meta data config. + * Has the template events changed since the last time they were logged? * - * @return \string[][] Config. + * @param string $template_id Template ID. + * @param string $events_hash Events hash. */ - public function get_meta_column_config(): array + private function has_template_events_changed(string $template_id, string $events_hash) { } - } - /** - * This is the main class used to perform the complete migration of orders - * from the posts table to the custom orders table. - * - * @package Automattic\WooCommerce\Database\Migrations\CustomOrderTable - */ - class PostsToOrdersMigrationController - { /** - * Error logger for migration errors. + * Generate a hash for a given set of template events. * - * @var \WC_Logger + * @param array $template_events Template events. */ - private $error_logger; + private function generate_template_events_hash(array $template_events): string + { + } /** - * Array of objects used to perform the migration. + * Set the template events hash for a given template. * - * @var \Automattic\WooCommerce\Database\Migrations\TableMigrator[] + * @param string $template_id Template ID. + * @param string $hash Hash of template events. */ - private $all_migrators; + private function set_template_events_log_hash(string $template_id, string $hash) + { + } /** - * The source name to use for logs. + * Log an event. + * + * @param string $event_type Event type. + * @param BlockInterface $block Block. + * @param array $additional_info Additional info. */ - public const LOGS_SOURCE_NAME = 'posts-to-orders-migration'; + private function log(string $event_type, \Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface $block, $additional_info = array()) + { + } /** - * PostsToOrdersMigrationController constructor. + * Should the logger handle a given level? + * + * @param int $level Level to check. */ - public function __construct() + private function should_handle($level) { } /** - * Helper method to get migrated keys for all the tables in this controller. + * Add a template event. * - * @return string[] Array of meta keys. + * @param array $event_type_info Event type info. + * @param BlockTemplateInterface $template Template. + * @param ContainerInterface $container Container. + * @param BlockInterface $block Block. + * @param array $additional_info Additional info. */ - public function get_migrated_meta_keys() + private function add_template_event(array $event_type_info, \Automattic\WooCommerce\Admin\BlockTemplates\BlockTemplateInterface $template, \Automattic\WooCommerce\Admin\BlockTemplates\ContainerInterface $container, \Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface $block, array $additional_info = array()) { } /** - * Migrates a set of orders from the posts table to the custom orders tables. + * Format a message for logging. * - * @param array $order_post_ids List of post IDs of the orders to migrate. + * @param string $message Message to log. + * @param array $info Additional info to log. */ - public function migrate_orders(array $order_post_ids): void + private function format_message(string $message, array $info = array()): string { } /** - * Log migration errors if any. + * Format info for logging. * - * @param array $order_post_ids List of post IDs of the orders to migrate. - * @param array $errors List of errors to log. - * @param \Exception|null $exception Exception to log. - * @param bool|null $using_transactions Whether transactions were used. - * @param string $name Name of the migrator. + * @param array $info Info to log. */ - private function handle_migration_error(array $order_post_ids, array $errors, ?\Exception $exception, ?bool $using_transactions, string $name) + private function format_info(array $info): array { } /** - * Clear the cache of order data for modified orders during migration if cache is enabled. - * - * @param array $order_post_ids List of order IDs of the orders to clear from cache. + * Format an exception for logging. * - * @return void + * @param \Exception $exception Exception to format. */ - private function maybe_clear_order_datastore_cache_for_ids(array $order_post_ids) + private function format_exception(\Exception $exception): array { } /** - * Start a database transaction if the configuration mandates so. - * - * @return bool|null True if transaction started, false if transactions won't be used, null if transaction failed to start. + * Format an exception trace for logging. * - * @throws \Exception If the transaction isolation level is invalid. + * @param array $trace Exception trace to format. */ - private function maybe_start_transaction(): ?bool + private function format_exception_trace(array $trace): array { } /** - * Commit the current database transaction. + * Format a block template for logging. * - * @return bool True on success, false on error. + * @param BlockTemplateInterface $template Template to format. */ - private function commit_transaction(): bool + private function format_template(\Automattic\WooCommerce\Admin\BlockTemplates\BlockTemplateInterface $template): string { } /** - * Rollback the current database transaction. + * Format a block for logging. * - * @return bool True on success, false on error. + * @param BlockInterface $block Block to format. */ - private function rollback_transaction(): bool + private function format_block(\Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface $block): string { } + } +} +namespace Automattic\WooCommerce\Internal\CostOfGoodsSold { + /** + * Trait with common functionality for unit tests related to the Cost of Goods Sold feature. + */ + trait CogsAwareUnitTestSuiteTrait + { /** - * Execute a database query and log any errors. - * - * @param string $query The SQL query to execute. - * @param bool $supress_errors Whether to suppress errors. - * - * @return bool True if the query succeeded, false if there were errors. + * Enable the Cost of Goods Sold feature. */ - private function db_query(string $query, bool $supress_errors = false): bool + private function enable_cogs_feature() { } /** - * Verify whether the given order IDs were migrated properly or not. - * - * @param array $order_post_ids Order IDs. - * - * @return array Array of failed IDs along with columns. + * Enable the Cost of Goods Sold feature. */ - public function verify_migrated_orders(array $order_post_ids): array + private function disable_cogs_feature() { } /** - * Migrates an order from the posts table to the custom orders tables. + * Sets the expectation for a "doing it wrong" being thrown. * - * @param int $order_post_id Post ID of the order to migrate. + * @param string $method_name The method name inside the error message. */ - public function migrate_order(int $order_post_id): void + private function expect_doing_it_wrong_cogs_disabled(string $method_name) { } } } -namespace Automattic\WooCommerce\Database\Migrations { +namespace Automattic\WooCommerce\Internal { /** - * Helper class to assist with migration related operations. + * Interface RegisterHooksInterface + * + * The following must be added at the end of the 'init_hooks' method in the 'WooCommerce' class + * for each class implementing this interface: + * $container->get( ::class )->register(); + * + * @since 8.5.0 */ - class MigrationHelper + interface RegisterHooksInterface { /** - * Placeholders that we will use in building $wpdb queries. + * Register this class instance to the appropriate hooks. * - * @var string[] + * @return void */ - private static $wpdb_placeholder_for_type = array('int' => '%d', 'decimal' => '%f', 'string' => '%s', 'date' => '%s', 'date_epoch' => '%s', 'bool' => '%d'); + public function register(); + } +} +namespace Automattic\WooCommerce\Internal\CostOfGoodsSold { + /** + * Main controller for the Cost of Goods Sold feature. + */ + class CostOfGoodsSoldController implements \Automattic\WooCommerce\Internal\RegisterHooksInterface + { /** - * Helper method to escape backtick in various schema fields. - * - * @param array $schema_config Schema config. + * The instance of FeaturesController to use. * - * @return array Schema config escaped for backtick. + * @var FeaturesController */ - public static function escape_schema_for_backtick(array $schema_config): array - { - } + private \Automattic\WooCommerce\Internal\Features\FeaturesController $features_controller; /** - * Helper method to escape backtick in column and table names. - * WP does not provide a method to escape table/columns names yet, but hopefully soon in @link https://core.trac.wordpress.org/ticket/52506 - * - * @param string|array $identifier Column or table name. - * - * @return array|string|string[] Escaped identifier. + * Register hooks. */ - public static function escape_and_add_backtick($identifier) + public function register() { } /** - * Return $wpdb->prepare placeholder for data type. - * - * @param string $type Data type. + * Initialize the instance, runs when the instance is created by the dependency injection container. * - * @return string $wpdb placeholder. + * @internal + * @param FeaturesController $features_controller The instance of FeaturesController to use. */ - public static function get_wpdb_placeholder_for_type(string $type): string + final public function init(\Automattic\WooCommerce\Internal\Features\FeaturesController $features_controller) { } /** - * Generates ON DUPLICATE KEY UPDATE clause to be used in migration. - * - * @param array $columns List of column names. + * Is the Cost of Goods Sold engine enabled? * - * @return string SQL clause for INSERT...ON DUPLICATE KEY UPDATE + * @return bool True if the engine is enabled, false otherwise. */ - public static function generate_on_duplicate_statement_clause(array $columns): string + public function feature_is_enabled(): bool { } /** - * Migrate state codes in all the required places in the database, needed after they change for a given country. + * Add the feature information for the features settings page. * - * @param string $country_code The country that has the states for which the migration is needed. - * @param array $old_to_new_states_mapping An associative array where keys are the old state codes and values are the new state codes. - * @return bool True if there are more records that need to be migrated, false otherwise. + * @param FeaturesController $features_controller The instance of FeaturesController to use. + * + * @internal For exclusive usage of WooCommerce core, backwards compatibility not guaranteed. */ - public static function migrate_country_states(string $country_code, array $old_to_new_states_mapping): bool + public function add_feature_definition($features_controller) { } /** - * Migrate state codes in all the required places in the database (except orders). + * Add the entry for "add/remove COGS value column to/from the product meta lookup table" to the WooCommerce admin tools. * - * @param string $country_code The country that has the states for which the migration is needed. - * @param array $old_to_new_states_mapping An associative array where keys are the old state codes and values are the new state codes. - * @return void + * @internal Hook handler, not to be explicitly used from outside the class. + * + * @param array $tools_array Array to add the tool to. + * @return array Updated tools array. */ - private static function migrate_country_states_for_misc_data(string $country_code, array $old_to_new_states_mapping): void + public function add_debug_tools_entry(array $tools_array): array { } /** - * Migrate state codes in the shipping locations table. + * Handler for the "add COGS value column to the product meta lookup table" admin tool. * - * @param string $country_code The country that has the states for which the migration is needed. - * @param array $old_to_new_states_mapping An associative array where keys are the old state codes and values are the new state codes. - * @return void + * @internal Tool callback, not to be explicitly used from outside the class. */ - private static function migrate_country_states_for_shipping_locations(string $country_code, array $old_to_new_states_mapping): void + public function generate_lookup_cogs_columns() { } /** - * Migrate the state code for the store location. + * Handler for the "remove COGS value column to the product meta lookup table" admin tool. * - * @param string $country_code The country that has the states for which the migration is needed. - * @param array $old_to_new_states_mapping An associative array where keys are the old state codes and values are the new state codes. - * @return void + * @internal Tool callback, not to be explicitly used from outside the class. */ - private static function migrate_country_states_for_store_location(string $country_code, array $old_to_new_states_mapping): void + public function remove_lookup_cogs_columns() { } /** - * Migrate state codes for orders in the orders table and in the posts table. - * It will migrate only N*2*(number of states) records, being N equal to 100 by default - * but this number can be modified via the woocommerce_migrate_country_states_for_orders_batch_size filter. + * Tells if the COGS value column exists in the product meta lookup table. * - * @param string $country_code The country that has the states for which the migration is needed. - * @param array $old_to_new_states_mapping An associative array where keys are the old state codes and values are the new state codes. - * @return bool True if there are more records that need to be migrated, false otherwise. + * @return bool True if the column exists, false otherwise. */ - private static function migrate_country_states_for_orders(string $country_code, array $old_to_new_states_mapping): bool + public function product_meta_lookup_table_cogs_value_columns_exist(): bool { } /** - * Migrate state codes in the tax rates table. + * Get the tooltip text for the COGS value field in the product editor. * - * @param string $country_code The country that has the states for which the migration is needed. - * @param array $old_to_new_states_mapping An associative array where keys are the old state codes and values are the new state codes. - * @return void + * @param bool $for_variable_products True to get the value for variable products, false for other types of products. + * @return string The string to use as tooltip (translated but not escaped). */ - private static function migrate_country_states_for_tax_rates(string $country_code, array $old_to_new_states_mapping): void + public function get_general_cost_edit_field_tooltip(bool $for_variable_products) { } } } -namespace Automattic\WooCommerce\Enums { +namespace Automattic\WooCommerce\Internal\ProductFilters\Interfaces { /** - * Enum class for all the catalog visibility values. + * MainQueryClausesGenerator interface. + * + * @internal For exclusive usage of WooCommerce core, backwards compatibility not guaranteed. */ - final class CatalogVisibility + interface MainQueryClausesGenerator { /** - * Product is visible on both shop and search results. + * Add conditional query clauses for main query based on the filter params in query vars. * - * @var string - */ - public const VISIBLE = 'visible'; - /** - * Product is visible on the shop page only. - */ - public const CATALOG = 'catalog'; - /** - * Product visible in the search results only. - */ - public const SEARCH = 'search'; - /** - * Product is invisible on both shop and search results, but can still be accessed directly. + * @param array $args Query args. + * @param \WP_Query $wp_query WP_Query object. + * @return array */ - public const HIDDEN = 'hidden'; + public function add_query_clauses_for_main_query(array $args, \WP_Query $wp_query): array; } /** - * Enum class for all the order statuses. + * QueryClausesGenerator interface. * - * For a full documentation on the public order statuses, please refer to the following link: - * https://woocommerce.com/document/managing-orders/order-statuses/ + * @internal For exclusive usage of WooCommerce core, backwards compatibility not guaranteed. */ - final class OrderStatus + interface QueryClausesGenerator { /** - * The order has been received, but no payment has been made. + * Add conditional query clauses based on the filter params in query vars. * - * @var string + * @param array $args Query args. + * @param \WP_Query $wp_query WP_Query object. + * @return array */ - public const PENDING = 'pending'; + public function add_query_clauses(array $args, \WP_Query $wp_query): array; + } +} +namespace Automattic\WooCommerce\Internal\Traits { + /** + * DON'T USE THIS TRAIT. It will be removed in WooCommerce 10.5. + * Instead, make the hook target methods public and mark them with an @internal annotation. + * + * This trait allows making private methods of a class accessible from outside. + * This is useful to define hook handlers with the [$this, 'method'] or [__CLASS__, 'method'] syntax + * without having to make the method public (and thus having to keep it forever for backwards compatibility). + * + * Example: + * + * class Foobar { + * use AccessiblePrivateMethods; + * + * public function __construct() { + * self::add_action('some_action', [$this, 'handle_some_action']); + * } + * + * public static function init() { + * self::add_filter('some_filter', [__CLASS__, 'handle_some_filter']); + * } + * + * private function handle_some_action() { + * } + * + * private static function handle_some_filter() { + * } + * } + * + * For this to work the callback must be an array and the first element of the array must be either '$this', '__CLASS__', + * or another instance of the same class; otherwise the method won't be marked as accessible + * (but the corresponding WordPress 'add_action' and 'add_filter' functions will still be called). + * + * No special procedure is needed to remove hooks set up with these methods, the regular 'remove_action' + * and 'remove_filter' functions provided by WordPress can be used as usual. + * + * @deprecated 9.6.0 Make the hook target methods public and mark them with an @internal annotation. This trait will be removed in WooCommerce 10.5. + */ + trait AccessiblePrivateMethods + { + //phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore /** - * The customer’s payment failed or was declined, and no payment has been successfully made. + * List of instance methods marked as externally accessible. * - * @var string + * @var array */ - public const FAILED = 'failed'; + private $_accessible_private_methods = array(); /** - * The order is awaiting payment confirmation. + * List of static methods marked as externally accessible. * - * @var string + * @var array */ - public const ON_HOLD = 'on-hold'; + private static $_accessible_static_private_methods = array(); + //phpcs:enable PSR2.Classes.PropertyDeclaration.Underscore /** - * Order fulfilled and complete. + * Register a WordPress action. + * If the callback refers to a private or protected instance method in this class, the method is marked as externally accessible. * - * @var string - */ - public const COMPLETED = 'completed'; - /** - * Payment has been received (paid), and the stock has been reduced. + * $callback can be a standard callable, or a string representing the name of a method in this class. * - * @var string + * @param string $hook_name The name of the action to add the callback to. + * @param callable|string $callback The callback to be run when the action is called. + * @param int $priority Optional. Used to specify the order in which the functions + * associated with a particular action are executed. + * Lower numbers correspond with earlier execution, + * and functions with the same priority are executed + * in the order in which they were added to the action. Default 10. + * @param int $accepted_args Optional. The number of arguments the function accepts. Default 1. */ - public const PROCESSING = 'processing'; + protected static function add_action(string $hook_name, $callback, int $priority = 10, int $accepted_args = 1): void + { + } /** - * Orders are automatically put in the Refunded status when an admin or shop manager has fully refunded the order’s value after payment. + * Register a WordPress filter. + * If the callback refers to a private or protected instance method in this class, the method is marked as externally accessible. * - * @var string - */ - public const REFUNDED = 'refunded'; - /** - * The order was canceled by an admin or the customer. + * $callback can be a standard callable, or a string representing the name of a method in this class. * - * @var string + * @param string $hook_name The name of the filter to add the callback to. + * @param callable|string $callback The callback to be run when the filter is called. + * @param int $priority Optional. Used to specify the order in which the functions + * associated with a particular filter are executed. + * Lower numbers correspond with earlier execution, + * and functions with the same priority are executed + * in the order in which they were added to the filter. Default 10. + * @param int $accepted_args Optional. The number of arguments the function accepts. Default 1. */ - public const CANCELLED = 'cancelled'; + protected static function add_filter(string $hook_name, $callback, int $priority = 10, int $accepted_args = 1): void + { + } /** - * The order is in the trash. + * Do the required processing to a callback before invoking the WordPress 'add_action' or 'add_filter' function. * - * @var string + * @param callable $callback The callback to process. + * @return void */ - public const TRASH = 'trash'; + protected static function process_callback_before_hooking($callback): void + { + } /** - * The order is a draft (legacy status). + * Register a private or protected instance method of this class as externally accessible. * - * @var string + * @param string $method_name Method name. + * @return bool True if the method has been marked as externally accessible, false if the method doesn't exist. */ - public const NEW = 'new'; + protected function mark_method_as_accessible(string $method_name): bool + { + } /** - * The order is an automatically generated draft. + * Register a private or protected static method of this class as externally accessible. * - * @var string + * @param string $method_name Method name. + * @return bool True if the method has been marked as externally accessible, false if the method doesn't exist. */ - public const AUTO_DRAFT = 'auto-draft'; + protected static function mark_static_method_as_accessible(string $method_name): bool + { + } /** - * Draft orders are created when customers start the checkout process while the block version of the checkout is in place. + * Undefined/inaccessible instance method call handler. * - * @var string + * @param string $name Called method name. + * @param array $arguments Called method arguments. + * @return mixed + * @throws \Error The called instance method doesn't exist or is private/protected and not marked as externally accessible. */ - public const DRAFT = 'draft'; + public function __call($name, $arguments) + { + } /** - * Array of all the valid order statuses for a complete payment. + * Undefined/inaccessible static method call handler. * - * @var string[] + * @param string $name Called method name. + * @param array $arguments Called method arguments. + * @return mixed + * @throws \Error The called static method doesn't exist or is private/protected and not marked as externally accessible. */ - public const PAYMENT_COMPLETE_STATUSES = array(self::ON_HOLD, self::PENDING, self::FAILED, self::CANCELLED); + public static function __callStatic($name, $arguments) + { + } } +} +namespace Automattic\WooCommerce\LayoutTemplates { /** - * Enum class for all the payment gateway feature's values. + * Layout template registry. */ - final class PaymentGatewayFeature + final class LayoutTemplateRegistry { /** - * Payment gateway supports add payment methods. - * - * @var string - */ - public const ADD_PAYMENT_METHOD = 'add_payment_method'; - /** - * Payment gateway supports credit card form on saved method. - * - * @var string - */ - public const CREDIT_CARD_FORM_CVC_ON_SAVED_METHOD = 'credit_card_form_cvc_on_saved_method'; - /** - * Payment gateway supports default credit card form. - * - * @var string - */ - public const DEFAULT_CREDIT_CARD_FORM = 'default_credit_card_form'; - /** - * Payment gateway supports deposits. + * Class instance. * - * @var string + * @var LayoutTemplateRegistry|null */ - public const DEPOSITS = 'deposits'; + private static $instance = null; /** - * Payment gateway supports multiple subscriptions. + * Layout templates info. * - * @var string + * @var array */ - public const MULTIPLE_SUBSCRIPTIONS = 'multiple_subscriptions'; + protected $layout_templates_info = array(); /** - * Payment gateway supports pay button. + * Layout template instances. * - * @var string + * @var array */ - public const PAY_BUTTON = 'pay_button'; + protected $layout_template_instances = array(); /** - * Payment gateway supports pre-orders. - * - * @var string + * Get the instance of the class. */ - public const PRE_ORDERS = 'pre-orders'; + public static function get_instance(): \Automattic\WooCommerce\LayoutTemplates\LayoutTemplateRegistry + { + } /** - * Payment gateway supports products. - * - * @var string + * Unregister all layout templates. */ - public const PRODUCTS = 'products'; + public function unregister_all() + { + } /** - * Payment gateway supports refunds. + * Check if a layout template is registered. * - * @var string + * @param string $layout_template_id Layout template ID. */ - public const REFUNDS = 'refunds'; + public function is_registered($layout_template_id): bool + { + } /** - * Payment gateway supports subscription amount changes. + * Register a single layout template. * - * @var string + * @param string $layout_template_id Layout template ID. + * @param string $layout_template_area Layout template area. + * @param string $layout_template_class_name Layout template class to register. + * + * @throws \ValueError If a layout template with the same ID already exists. + * @throws \ValueError If the specified layout template area is empty. + * @throws \ValueError If the specified layout template class does not exist. + * @throws \ValueError If the specified layout template class does not implement the BlockTemplateInterface. */ - public const SUBSCRIPTION_AMOUNT_CHANGES = 'subscription_amount_changes'; + public function register($layout_template_id, $layout_template_area, $layout_template_class_name) + { + } /** - * Payment gateway supports subscription cancellation. + * Instantiate the matching layout templates and return them. * - * @var string + * @param array $query_params Query params. */ - public const SUBSCRIPTION_CANCELLATION = 'subscription_cancellation'; + public function instantiate_layout_templates(array $query_params = array()): array + { + } /** - * Payment gateway supports subscription date changes. + * Instantiate a single layout template and return it. * - * @var string + * @param array $layout_template_info Layout template info. */ - public const SUBSCRIPTION_DATE_CHANGES = 'subscription_date_changes'; + private function get_layout_template_instance($layout_template_info): \Automattic\WooCommerce\Admin\BlockTemplates\BlockTemplateInterface + { + } /** - * Payment gateway supports subscription payment method changes. + * Get matching layout templates info. * - * @var string + * @param array $query_params Query params. */ - public const SUBSCRIPTION_PAYMENT_METHOD_CHANGE = 'subscription_payment_method_change'; + private function get_matching_layout_templates_info(array $query_params = array()): array + { + } + } +} +namespace Automattic\WooCommerce { + /** + * Packages class. + * + * @since 3.7.0 + */ + class Packages + { /** - * Payment gateway supports subscription payment method changes by admin. - * - * @var string + * Static-only class. */ - public const SUBSCRIPTION_PAYMENT_METHOD_CHANGE_ADMIN = 'subscription_payment_method_change_admin'; + private function __construct() + { + } /** - * Payment gateway supports subscription payment method changes by customer or admin. + * Array of package names and their main package classes. Once a package has been merged into WooCommerce + * directly it should be removed from here and added to the merged packages array. * - * @var string + * @var array Key is the package name/directory, value is the main package class which handles init. */ - public const SUBSCRIPTION_PAYMENT_METHOD_CHANGE_CUSTOMER = 'subscription_payment_method_change_customer'; + protected static $packages = array('email-editor' => '\Automattic\WooCommerce\Internal\EmailEditor\Package'); /** - * Payment gateway supports subscription reactivation. + * Array of package names and their main package classes. * - * @var string + * One a package has been merged into WooCommerce Core it should be moved from the package list and placed in + * this list. This will ensure that the feature plugin is disabled as well as provide the class to handle + * initialization for the now-merged feature plugin. + * + * Once a package has been merged into WooCommerce Core it should have its slug added here. This will ensure + * that we deactivate the feature plugin automatically to prevent any problems caused by conflicts between + * the two versions caused by them both being active. + * + * The packages included in this array cannot be deactivated and will always load with WooCommerce core. + * + * @var array Key is the package name/directory, value is the main package class which handles init. */ - public const SUBSCRIPTION_REACTIVATION = 'subscription_reactivation'; + protected static $base_packages = array('woocommerce-admin' => '\Automattic\WooCommerce\Admin\Composer\Package', 'woocommerce-gutenberg-products-block' => '\Automattic\WooCommerce\Blocks\Package'); /** - * Payment gateway supports subscription suspension. + * Similar to $base_packages, but + * the packages included in this array can be deactivated via the 'woocommerce_merged_packages' filter. * - * @var string + * @var array Key is the package name/directory, value is the main package class which handles init. */ - public const SUBSCRIPTION_SUSPENSION = 'subscription_suspension'; + protected static $merged_packages = array('woocommerce-brands' => '\Automattic\WooCommerce\Internal\Brands'); /** - * Payment gateway supports subscriptions. + * Init the package loader. * - * @var string + * @since 3.7.0 */ - public const SUBSCRIPTIONS = 'subscriptions'; + public static function init() + { + } /** - * Payment gateway supports tokenization. - * - * @var string + * Callback for WordPress init hook. */ - public const TOKENIZATION = 'tokenization'; - } - /** - * Enum class for all the product statuses. - */ - final class ProductStatus - { + public static function on_init() + { + } /** - * The product is in auto-draft status. + * Checks a package exists by looking for it's directory. * - * @var string + * @param string $package Package name. + * @return boolean */ - public const AUTO_DRAFT = 'auto-draft'; + public static function package_exists($package) + { + } /** - * The product is in draft status. + * Checks a package exists by looking for it's directory. * - * @var string + * @param string $class_name Class name. + * @return boolean */ - public const DRAFT = 'draft'; + public static function should_load_class($class_name) + { + } /** - * The product is in pending status. + * Gets all merged, enabled packages. * - * @var string + * @return array */ - public const PENDING = 'pending'; + protected static function get_enabled_packages() + { + } /** - * The product is in private status. + * Checks if a package is enabled. * - * @var string + * @param string $package Package name. + * @return boolean */ - public const PRIVATE = 'private'; + public static function is_package_enabled($package) + { + } /** - * The product is in publish status. - * - * @var string + * Prepare merged packages for initialization. + * Especially useful when running actions early in the 'plugins_loaded' timeline. */ - public const PUBLISH = 'publish'; + public static function prepare_packages() + { + } /** - * The product is in trash status. + * Deactivates merged feature plugins. * - * @var string + * Once a feature plugin is merged into WooCommerce Core it should be deactivated. This method will + * ensure that a plugin gets deactivated. Note that for the first request it will still be active, + * and as such, there may be some odd behavior. This is unlikely to cause any issues though + * because it will be deactivated on the request that updates or activates WooCommerce. */ - public const TRASH = 'trash'; + protected static function deactivate_merged_packages() + { + } /** - * The product is in future status. + * Prevent plugins already merged into WooCommerce core from getting activated as standalone plugins. * - * @var string + * @param string $plugin Plugin name. */ - public const FUTURE = 'future'; - } - /** - * Enum class for all the product stock statuses. - */ - final class ProductStockStatus - { + public static function deactivate_merged_plugins($plugin) + { + } /** - * The product is in stock. + * Mark merged plugins as pending update. + * This is required for correctly displaying maintenance notices. * - * @var string + * @param array $plugins Plugins list. */ - public const IN_STOCK = 'instock'; + public static function mark_merged_plugins_as_pending_update($plugins) + { + } /** - * The product is out of stock. + * Displays a maintenance notice next to merged plugins, to inform users + * that the plugin functionality is now offered by WooCommerce core. * - * @var string + * Requires 'mark_merged_plugins_as_pending_update' to properly display this notice. + * + * @param string $plugin_file Plugin file. */ - public const OUT_OF_STOCK = 'outofstock'; + public static function display_notice_for_merged_plugins($plugin_file) + { + } /** - * The product is on backorder. + * Loads packages after plugins_loaded hook. * - * @var string + * Each package should include an init file which loads the package so it can be used by core. */ - public const ON_BACKORDER = 'onbackorder'; + protected static function initialize_packages() + { + } /** - * The product is low in stock. + * If a package is missing, add an admin notice. * - * @var string + * @param string $package Package name. */ - public const LOW_STOCK = 'lowstock'; + protected static function missing_package($package) + { + } } +} +namespace Automattic\WooCommerce\Proxies { /** - * Enum class for all the product tax statuses. + * Proxy for interacting with WordPress actions and filters. + * + * This class should be used instead of directly accessing the WordPress functions, to ease unit testing. */ - class ProductTaxStatus + class ActionsProxy { /** - * Tax status for products that are taxable. + * Retrieve the number of times an action is fired. * - * @var string - */ - public const TAXABLE = 'taxable'; - /** - * Indicates that only the shipping cost should be taxed, not the product itself. + * @param string $tag The name of the action hook. * - * @var string + * @return int The number of times action hook $tag is fired. */ - public const SHIPPING = 'shipping'; + public function did_action($tag) + { + } /** - * Tax status for products that are not taxable. + * Calls the callback functions that have been added to a filter hook. * - * @var string + * @param string $tag The name of the filter hook. + * @param mixed $value The value to filter. + * @param mixed ...$parameters Additional parameters to pass to the callback functions. + * + * @return mixed The filtered value after all hooked functions are applied to it. */ - public const NONE = 'none'; + public function apply_filters($tag, $value, ...$parameters) + { + } + // TODO: Add the rest of the actions and filters related methods. } /** - * Enum class for all the product types. + * Proxy class to access legacy WooCommerce functionality. + * + * This class should be used to interact with code outside the `src` directory, especially functions and classes + * in the `includes` directory, unless a more specific proxy exists for the functionality at hand (e.g. `ActionsProxy`). + * Idempotent functions can be executed directly. */ - final class ProductType + class LegacyProxy { /** - * Simple product type. + * Gets an instance of a given legacy class. + * This must not be used to get instances of classes in the `src` directory. * - * @var string - */ - public const SIMPLE = 'simple'; - /** - * Variable product type. + * If a given class needs a special procedure to get an instance of it, + * please add a private get_instance_of_(lowercased_class_name) and it will be + * automatically invoked. See also how objects of classes having a static `instance` + * method are retrieved, similar approaches can be used as needed to make use + * of existing factory methods such as e.g. 'load'. * - * @var string - */ - public const VARIABLE = 'variable'; - /** - * Grouped product type. + * @param string $class_name The name of the class to get an instance for. + * @param mixed ...$args Parameters to be passed to the class constructor or to the appropriate internal 'get_instance_of_' method. * - * @var string + * @return object The instance of the class. + * @throws \Exception The requested class has a namespace starting with ' Automattic\WooCommerce', or there was an error creating an instance of the class. */ - public const GROUPED = 'grouped'; + public function get_instance_of(string $class_name, ...$args) + { + } /** - * External/Affiliate product type. + * Get an instance of a class implementing WC_Queue_Interface. * - * @var string + * @return \WC_Queue_Interface The instance. */ - public const EXTERNAL = 'external'; + private function get_instance_of_wc_queue_interface() + { + } /** - * Variation product type. + * Call a user function. This should be used to execute any non-idempotent function, especially + * those in the `includes` directory or provided by WordPress. * - * @var string - */ - public const VARIATION = 'variation'; - } -} -namespace Automattic\WooCommerce\Internal\Admin\BlockTemplates { - /** - * Trait for block formatted template. - */ - trait BlockFormattedTemplateTrait - { - /** - * Get the block configuration as a formatted template. + * @param string $function_name The function to execute. + * @param mixed ...$parameters The parameters to pass to the function. * - * @return array The block configuration as a formatted template. + * @return mixed The result from the function. */ - public function get_formatted_template(): array + public function call_function($function_name, ...$parameters) { } /** - * Get the block hide conditions formatted for inclusion in a formatted template. + * Call a static method in a class. This should be used to execute any non-idempotent method in classes + * from the `includes` directory. + * + * @param string $class_name The name of the class containing the method. + * @param string $method_name The name of the method. + * @param mixed ...$parameters The parameters to pass to the method. + * + * @return mixed The result from the method. */ - private function get_formatted_hide_conditions(): array + public function call_static($class_name, $method_name, ...$parameters) { } /** - * Get the block disable conditions formatted for inclusion in a formatted template. + * Get the value of a global. + * + * @param string $global_name The name of the global to get the value for. + * @return mixed The value of the global. */ - private function get_formatted_disable_conditions(): array + public function get_global(string $global_name) { } /** - * Formats conditions in the expected format to include in the template. + * Terminates execution of the script. * - * @param array $conditions The conditions to format. + * @param int|string $status An error code to be returned, or an error message to be shown. + * @return void */ - private function format_conditions($conditions): array + public function exit($status = '') { } } +} +namespace Automattic\WooCommerce\RestApi\Routes\V4 { /** - * Block configuration used to specify blocks in BlockTemplate. + * AbstractCollectionQuery class. + * + * @internal This class is for internal use only and should not be used by external code. */ - class AbstractBlock implements \Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface + abstract class AbstractCollectionQuery { - use \Automattic\WooCommerce\Internal\Admin\BlockTemplates\BlockFormattedTemplateTrait; - /** - * The block name. - * - * @var string - */ - private $name; /** - * The block ID. - * - * @var string + * Operator constants for easy access. */ - private $id; + const OPERATOR_IS = 'is'; + const OPERATOR_IS_NOT = 'isNot'; + const OPERATOR_LESS_THAN = 'lessThan'; + const OPERATOR_GREATER_THAN = 'greaterThan'; + const OPERATOR_LESS_THAN_OR_EQUAL = 'lessThanOrEqual'; + const OPERATOR_GREATER_THAN_OR_EQUAL = 'greaterThanOrEqual'; + const OPERATOR_BETWEEN = 'between'; /** - * The block order. - * - * @var int + * Array of operators for validation. */ - private $order = 10000; + const OPERATORS = array(self::OPERATOR_IS, self::OPERATOR_IS_NOT, self::OPERATOR_LESS_THAN, self::OPERATOR_GREATER_THAN, self::OPERATOR_LESS_THAN_OR_EQUAL, self::OPERATOR_GREATER_THAN_OR_EQUAL, self::OPERATOR_BETWEEN); /** - * The block attributes. + * Get query schema for collection. * - * @var array + * @return array */ - private $attributes = array(); + abstract public function get_query_schema(): array; /** - * The block hide conditions. + * Prepares query args. * - * @var array + * @param WP_REST_Request $request The request object. + * @return array */ - private $hide_conditions = array(); + abstract public function get_query_args(\WP_REST_Request $request): array; /** - * The block hide conditions counter. + * Get results of the query. * - * @var int + * @param array $query_args The query arguments. + * @param WP_REST_Request $request The request object. + * @return array */ - private $hide_conditions_counter = 0; + abstract public function get_query_results(array $query_args, \WP_REST_Request $request): array; + } + /** + * Abstract REST Controller for WooCommerce REST API V4. + * + * Provides common functionality for all V4 route controllers including + * schema generation, error handling, and hook management. + * + * @since 10.2.0 + */ + abstract class AbstractController extends \WP_REST_Controller + { /** - * The block disable conditions. - * - * @var array + * Shared error codes. */ - private $disable_conditions = array(); + const INVALID_ID = 'invalid_id'; + const RESOURCE_EXISTS = 'resource_exists'; + const CANNOT_CREATE = 'cannot_create'; + const CANNOT_DELETE = 'cannot_delete'; + const CANNOT_TRASH = 'cannot_trash'; + const TRASH_NOT_SUPPORTED = 'trash_not_supported'; /** - * The block disable conditions counter. + * Route namespace. * - * @var int + * @var string */ - private $disable_conditions_counter = 0; + protected $namespace = 'wc/v4'; /** - * The block template that this block belongs to. + * Route base. * - * @var BlockTemplate + * @var string */ - private $root_template; + protected $rest_base = ''; /** - * The parent container. + * Cache for the item schema populated after calling get_item_schema(). * - * @var ContainerInterface + * @var array */ - private $parent; + protected $schema; /** - * Block constructor. + * Get the schema for the current resource. This use consumed by the AbstractController to generate the item schema + * after running various hooks on the response. * - * @param array $config The block configuration. - * @param BlockTemplateInterface $root_template The block template that this block belongs to. - * @param BlockContainerInterface|null $parent The parent block container. + * This should return the full schema object, not just the properties. * - * @throws \ValueError If the block configuration is invalid. - * @throws \ValueError If the parent block container does not belong to the same template as the block. + * @return array The full item schema. */ - public function __construct(array $config, \Automattic\WooCommerce\Admin\BlockTemplates\BlockTemplateInterface &$root_template, ?\Automattic\WooCommerce\Admin\BlockTemplates\ContainerInterface &$parent = null) - { - } + abstract protected function get_schema(): array; /** - * Validate block configuration. - * - * @param array $config The block configuration. - * @param BlockTemplateInterface $root_template The block template that this block belongs to. - * @param ContainerInterface|null $parent The parent block container. + * Get the collection args schema. * - * @throws \ValueError If the block configuration is invalid. - * @throws \ValueError If the parent block container does not belong to the same template as the block. + * @return array */ - protected function validate(array $config, \Automattic\WooCommerce\Admin\BlockTemplates\BlockTemplateInterface &$root_template, ?\Automattic\WooCommerce\Admin\BlockTemplates\ContainerInterface &$parent = null) + protected function get_query_schema(): array { } /** - * Get the block name. + * Add default context collection params and filter the result. This does not inherit from + * WP_REST_Controller::get_collection_params because some endpoints do not paginate results. + * + * @return array */ - public function get_name(): string + public function get_collection_params() { } /** - * Get the block ID. + * Get item schema, conforming to JSON Schema. Extended by routes. + * + * @return array The item schema. + * @since 10.2.0 */ - public function get_id(): string + public function get_item_schema() { } /** - * Get the block order. + * Get the item response. + * + * @param mixed $item WooCommerce representation of the item. + * @param WP_REST_Request $request Request object. + * @return array The item response. + * @since 10.2.0 */ - public function get_order(): int - { - } + abstract protected function get_item_response($item, \WP_REST_Request $request): array; /** - * Set the block order. + * Prepare links for the request. * - * @param int $order The block order. + * @param mixed $item WordPress representation of the item. + * @param WP_REST_Request $request Request object. + * @param WP_REST_Response $response Response object. + * @return array */ - public function set_order(int $order) + protected function prepare_links($item, \WP_REST_Request $request, \WP_REST_Response $response): array { } /** - * Get the block attributes. + * Prepares the item for the REST response. Controllers do not need to override this method as they can define a + * get_item_response method to prepare items. This method will take care of filter hooks. + * + * @param mixed $item WordPress representation of the item. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. + * @since 10.2.0 */ - public function get_attributes(): array + public function prepare_item_for_response($item, $request) { } /** - * Set the block attributes. + * Get the hook prefix for actions and filters. * - * @param array $attributes The block attributes. + * Example: woocommerce_rest_api_v4_orders_ + * + * @return string The hook prefix. + * @since 10.2.0 */ - public function set_attributes(array $attributes) + protected function get_hook_prefix(): string { } /** - * Set a block attribute value without replacing the entire attributes object. + * Get the error prefix for errors. * - * @param string $key The attribute key. - * @param mixed $value The attribute value. + * Example: woocommerce_rest_api_v4_orders_ + * + * @return string The error prefix. + * @since 10.2.0 */ - public function set_attribute(string $key, $value) + protected function get_error_prefix(): string { } /** - * Get the template that this block belongs to. + * Get route response when something went wrong. + * + * @param string $error_code String based error code. + * @param string $error_message User facing error message. + * @param int $http_status_code HTTP status. Defaults to 400. + * @param array $additional_data Extra data (key value pairs) to expose in the error response. + * @return WP_Error WP Error object. + * @since 10.2.0 */ - public function &get_root_template(): \Automattic\WooCommerce\Admin\BlockTemplates\BlockTemplateInterface + protected function get_route_error_response(string $error_code, string $error_message, int $http_status_code = \WP_Http::BAD_REQUEST, array $additional_data = array()): \WP_Error { } /** - * Get the parent block container. + * Get route response when something went wrong and the supplied error is a WP_Error. + * + * @param WP_Error $error_object The WP_Error object containing the error. + * @param int $http_status_code HTTP status. Defaults to 400. + * @param array $additional_data Extra data (key value pairs) to expose in the error response. + * @return WP_Error WP Error object. + * @since 10.2.0 */ - public function &get_parent(): \Automattic\WooCommerce\Admin\BlockTemplates\ContainerInterface + protected function get_route_error_response_from_object(\WP_Error $error_object, int $http_status_code = \WP_Http::BAD_REQUEST, array $additional_data = array()): \WP_Error { } /** - * Remove the block from its parent. + * Returns an authentication error for a given HTTP verb. + * + * @param string $method HTTP method. + * @return WP_Error|false WP Error object or false if no error is found. */ - public function remove() + protected function get_authentication_error_by_method(string $method) { } /** - * Check if the block is detached from its parent block container or the template it belongs to. + * Get an error response for a given error code. * - * @return bool True if the block is detached from its parent block container or the template it belongs to. + * @param string $error_code The error code. + * @return WP_Error WP Error object. */ - public function is_detached(): bool + protected function get_route_error_by_code(string $error_code): \WP_Error { } + } + /** + * Abstract REST Schema for WooCommerce REST API V4. + * + * Provides common functionality for all V4 schema controllers including + * property generation, context filtering, and validation. + * + * @since 10.2.0 + */ + abstract class AbstractSchema + { /** - * Add a hide condition to the block. + * The schema item identifier. * - * The hide condition is a JavaScript-like expression that will be evaluated on the client to determine if the block should be hidden. - * See [@woocommerce/expression-evaluation](https://github.com/woocommerce/woocommerce/blob/trunk/packages/js/expression-evaluation/README.md) for more details. + * @var string + * @since 10.2.0 + */ + const IDENTIFIER = ''; + /** + * Context for the item schema - view, edit, and embed. * - * @param string $expression An expression, which if true, will hide the block. + * @var array + * @since 10.2.0 */ - public function add_hide_condition(string $expression): string - { - } + const VIEW_EDIT_EMBED_CONTEXT = array('view', 'edit', 'embed'); /** - * Remove a hide condition from the block. + * Context for the item schema - view and edit only. * - * @param string $key The key of the hide condition to remove. + * @var array + * @since 10.2.0 */ - public function remove_hide_condition(string $key) - { - } + const VIEW_EDIT_CONTEXT = array('view', 'edit'); /** - * Get the hide conditions of the block. + * Get the item schema. + * + * @return array The item schema. + * @since 10.2.0 */ - public function get_hide_conditions(): array + public function get_item_schema(): array { } /** - * Add a disable condition to the block. + * Get the item response. * - * The disable condition is a JavaScript-like expression that will be evaluated on the client to determine if the block should be hidden. - * See [@woocommerce/expression-evaluation](https://github.com/woocommerce/woocommerce/blob/trunk/packages/js/expression-evaluation/README.md) for more details. + * @param mixed $item WordPress representation of the item. + * @param WP_REST_Request $request Request object. + * @param array $include_fields Fields to include in the response. + * @return array The item response. + */ + abstract public function get_item_response($item, \WP_REST_Request $request, array $include_fields = array()): array; + /** + * Return all properties for the item schema. * - * @param string $expression An expression, which if true, will disable the block. + * @return array The schema properties. + * @since 10.2.0 */ - public function add_disable_condition(string $expression): string + public function get_item_schema_properties(): array { } /** - * Remove a disable condition from the block. + * Return all writable properties for the item schema. * - * @param string $key The key of the disable condition to remove. + * @return array The schema properties. + * @since 10.2.0 */ - public function remove_disable_condition(string $key) + public function get_writable_item_schema_properties(): array { } /** - * Get the disable conditions of the block. + * Filter schema properties to only return writable ones. + * + * @param array $schema The schema property to check. + * @return bool True if the property is writable, false otherwise. + * @since 10.2.0 */ - public function get_disable_conditions(): array + protected function filter_writable_props(array $schema): bool { } } +} +namespace Automattic\WooCommerce\RestApi\Routes\V4\OrderNotes { /** - * Trait for block containers. + * CollectionQuery class. + * + * @internal This class is for internal use only and should not be used by external code. */ - trait BlockContainerTrait + final class CollectionQuery extends \Automattic\WooCommerce\RestApi\Routes\V4\AbstractCollectionQuery { - use \Automattic\WooCommerce\Internal\Admin\BlockTemplates\BlockFormattedTemplateTrait { - get_formatted_template as get_block_formatted_template; - } /** - * The inner blocks. + * Get query schema. * - * @var BlockInterface[] + * @return array */ - private $inner_blocks = array(); - // phpcs doesn't take into account exceptions thrown by called methods. - // phpcs:disable Squiz.Commenting.FunctionCommentThrowTag.WrongNumber + public function get_query_schema(): array + { + } /** - * Add a block to the block container. + * Prepares query args. * - * @param BlockInterface $block The block. - * - * @throws \ValueError If the block configuration is invalid. - * @throws \ValueError If a block with the specified ID already exists in the template. - * @throws \UnexpectedValueException If the block container is not the parent of the block. - * @throws \UnexpectedValueException If the block container's root template is not the same as the block's root template. + * @param WP_REST_Request $request The request object. + * @return array */ - protected function &add_inner_block(\Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface $block): \Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface + public function get_query_args(\WP_REST_Request $request): array { } - // phpcs:enable Squiz.Commenting.FunctionCommentThrowTag.WrongNumber /** - * Checks if a block is a descendant of the block container. + * Get results of the query. * - * @param BlockInterface $block The block. + * @param array $query_args The query arguments. + * @param WP_REST_Request $request The request object. + * @return array */ - private function is_block_descendant(\Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface $block): bool + public function get_query_results(array $query_args, \WP_REST_Request $request): array { } + } + /** + * OrdersNotes Controller. + */ + class Controller extends \Automattic\WooCommerce\RestApi\Routes\V4\AbstractController + { /** - * Get a block by ID. + * Route base. * - * @param string $block_id The block ID. + * @var string */ - public function get_block(string $block_id): ?\Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface - { - } + protected $rest_base = 'order-notes'; /** - * Remove a block from the block container. + * Schema class for this route. * - * @param string $block_id The block ID. + * @var OrderNoteSchema + */ + protected $item_schema; + /** + * Query utils class. * - * @throws \UnexpectedValueException If the block container is not an ancestor of the block. + * @var QueryUtils */ - public function remove_block(string $block_id) - { - } + protected $query_utils; /** - * Remove all blocks from the block container. + * Initialize the controller. + * + * @param OrderNoteSchema $item_schema Order schema class. + * @param CollectionQuery $query_utils Query utils class. + * @internal */ - public function remove_blocks() + final public function init(\Automattic\WooCommerce\RestApi\Routes\V4\OrderNotes\Schema\OrderNoteSchema $item_schema, \Automattic\WooCommerce\RestApi\Routes\V4\OrderNotes\CollectionQuery $query_utils) { } /** - * Remove a block from the block container's inner blocks. This is an internal method and should not be called directly - * except for from the BlockContainerTrait's remove_block() method. - * - * @param BlockInterface $block The block. + * Get the schema for the current resource. This use consumed by the AbstractController to generate the item schema + * after running various hooks on the response. */ - public function remove_inner_block(\Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface $block) + protected function get_schema(): array { } /** - * Get the inner blocks sorted by order. + * Get the collection args schema. + * + * @return array */ - private function get_inner_blocks_sorted_by_order(): array + protected function get_query_schema(): array { } /** - * Get the inner blocks as a formatted template. + * Register the routes for orders. */ - public function get_formatted_template(): array + public function register_routes() { } /** - * Do the `woocommerce_block_template_after_add_block` action. - * Handle exceptions thrown by the action. + * Prepare links for the request. * - * @param BlockInterface $block The block. + * @param mixed $item WordPress representation of the item. + * @param WP_REST_Request $request Request object. + * @param WP_REST_Response $response Response object. + * @return array */ - private function do_after_add_block_action(\Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface $block) + protected function prepare_links($item, \WP_REST_Request $request, \WP_REST_Response $response): array { } /** - * Do the `woocommerce_block_template_area_{template_area}_after_add_block_{block_id}` action. - * Handle exceptions thrown by the action. + * Prepare a single order note item for response. * - * @param BlockInterface $block The block. + * @param WP_Comment $note Note object. + * @param WP_REST_Request $request Request object. + * @return array */ - private function do_after_add_specific_block_action(\Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface $block) + protected function get_item_response($note, \WP_REST_Request $request): array { } /** - * Do the `woocommerce_block_after_add_block_error` action. + * Check if a given request has access to read an item. * - * @param BlockInterface $block The block. - * @param string $action The action that threw the exception. - * @param \Exception $e The exception. + * @param WP_REST_Request $request The request object. + * @return WP_Error|boolean */ - private function do_after_add_block_error_action(\Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface $block, string $action, \Exception $e) + public function get_item_permissions_check($request) { } /** - * Do the `woocommerce_block_template_after_remove_block` action. - * Handle exceptions thrown by the action. + * Check if a given request has access to read items. * - * @param BlockInterface $block The block. + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean */ - private function do_after_remove_block_action(\Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface $block) + public function get_items_permissions_check($request) { } /** - * Do the `woocommerce_block_template_area_{template_area}_after_remove_block_{block_id}` action. - * Handle exceptions thrown by the action. + * Check if a given request has access to create an item. * - * @param BlockInterface $block The block. + * @param WP_REST_Request $request The request object. + * @return WP_Error|boolean */ - private function do_after_remove_specific_block_action(\Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface $block) + public function create_item_permissions_check($request) { } /** - * Do the `woocommerce_block_after_remove_block_error` action. + * Check if a given request has access to delete an item. * - * @param BlockInterface $block The block. - * @param string $action The action that threw the exception. - * @param \Exception $e The exception. + * @param WP_REST_Request $request The request object. + * @return bool|WP_Error */ - private function do_after_remove_block_error_action(\Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface $block, string $action, \Exception $e) + public function delete_item_permissions_check($request) { } - } - /** - * Block template class. - */ - abstract class AbstractBlockTemplate implements \Automattic\WooCommerce\Admin\BlockTemplates\BlockTemplateInterface - { - use \Automattic\WooCommerce\Internal\Admin\BlockTemplates\BlockContainerTrait; - /** - * Get the template ID. - */ - abstract public function get_id(): string; /** - * Get the template title. + * Get a single item. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response */ - public function get_title(): string + public function get_item($request) { } /** - * Get the template description. + * Get collection of orders. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response */ - public function get_description(): string + public function get_items($request) { } /** - * Get the template area. + * Create a single item. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response */ - public function get_area(): string + public function create_item($request) { } /** - * The block cache. + * Delete a single item. * - * @var BlockInterface[] + * @param WP_REST_Request $request Full details about the request. + * @return WP_REST_Response|WP_Error */ - private $block_cache = []; + public function delete_item($request) + { + } /** - * Get a block by ID. + * Check if an order is valid. * - * @param string $block_id The block ID. + * @param mixed $order_id The order ID. + * @return bool True if the order is valid, false otherwise. */ - public function get_block(string $block_id): ?\Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface + protected function is_valid_order_id($order_id): bool { } /** - * Caches a block in the template. This is an internal method and should not be called directly - * except for from the BlockContainerTrait's add_inner_block() method. - * - * @param BlockInterface $block The block to cache. + * Get an order by ID. * - * @throws \ValueError If a block with the specified ID already exists in the template. - * @throws \ValueError If the block template that the block belongs to is not this template. - * - * @ignore + * @param int $order_id The order ID. + * @return WC_Order|null */ - public function cache_block(\Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface &$block) + protected function get_order_by_id(int $order_id) { } /** - * Uncaches a block in the template. This is an internal method and should not be called directly - * except for from the BlockContainerTrait's remove_block() method. + * Get the parent order of a note. * - * @param string $block_id The block ID. - * - * @ignore + * @param int|WP_Comment $note_id The note ID or note object. + * @return WC_Order|null */ - public function uncache_block(string $block_id) + protected function get_order_by_note_id($note_id) { } /** - * Generate a block ID based on a base. + * Get a note by ID. * - * @param string $id_base The base to use when generating an ID. - * @return string + * @param int $note_id The note ID. + * @return WP_Comment|null */ - public function generate_block_id(string $id_base): string + protected function get_note_by_id(int $note_id) { } + } +} +namespace Automattic\WooCommerce\RestApi\Routes\V4\OrderNotes\Schema { + /** + * OrderNoteSchema class. + */ + class OrderNoteSchema extends \Automattic\WooCommerce\RestApi\Routes\V4\AbstractSchema + { /** - * Get the root template. + * The schema item identifier. + * + * @var string */ - public function &get_root_template(): \Automattic\WooCommerce\Admin\BlockTemplates\BlockTemplateInterface - { - } + const IDENTIFIER = 'order_note'; /** - * Get the inner blocks as a formatted template. + * Return all properties for the item schema. + * + * Note that context determines under which context data should be visible. For example, edit would be the context + * used when getting records with the intent of editing them. embed context allows the data to be visible when the + * item is being embedded in another response. + * + * @return array */ - public function get_formatted_template(): array + public function get_item_schema_properties(): array { } /** - * Get the template as JSON like array. + * Get the item response. * - * @return array The JSON. + * @param WP_Comment $note Order note object. + * @param WP_REST_Request $request Request object. + * @param array $include_fields Fields to include in the response. + * @return array The item response. */ - public function to_json(): array + public function get_item_response($note, \WP_REST_Request $request, array $include_fields = array()): array { } } +} +namespace Automattic\WooCommerce\RestApi\Routes\V4\Orders { /** - * Generic block with container properties to be used in BlockTemplate. + * CollectionQuery class. + * + * @internal This class is for internal use only and should not be used by external code. */ - class Block extends \Automattic\WooCommerce\Internal\Admin\BlockTemplates\AbstractBlock implements \Automattic\WooCommerce\Admin\BlockTemplates\BlockContainerInterface + class CollectionQuery extends \Automattic\WooCommerce\RestApi\Routes\V4\AbstractCollectionQuery { - use \Automattic\WooCommerce\Internal\Admin\BlockTemplates\BlockContainerTrait; /** - * Add an inner block to this block. + * Get query schema. * - * @param array $block_config The block data. + * @return array */ - public function &add_block(array $block_config): \Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface + public function get_query_schema(): array { } - } - /** - * Block template class. - */ - class BlockTemplate extends \Automattic\WooCommerce\Internal\Admin\BlockTemplates\AbstractBlockTemplate - { /** - * Get the template ID. + * Prepares query args. + * + * @param WP_REST_Request $request The request object. + * @return array */ - public function get_id(): string + public function get_query_args(\WP_REST_Request $request): array { } /** - * Add an inner block to this template. + * Get results of the query. * - * @param array $block_config The block data. + * @param array $query_args The query arguments from prepare_query(). + * @param WP_REST_Request $request The request object. + * @return array */ - public function add_block(array $block_config): \Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface + public function get_query_results(array $query_args, \WP_REST_Request $request): array { } } /** - * Logger for block template modifications. + * Orders Controller. */ - class BlockTemplateLogger + class Controller extends \Automattic\WooCommerce\RestApi\Routes\V4\AbstractController { - const BLOCK_ADDED = 'block_added'; - const BLOCK_REMOVED = 'block_removed'; - const BLOCK_MODIFIED = 'block_modified'; - const BLOCK_ADDED_TO_DETACHED_CONTAINER = 'block_added_to_detached_container'; - const HIDE_CONDITION_ADDED = 'hide_condition_added'; - const HIDE_CONDITION_REMOVED = 'hide_condition_removed'; - const HIDE_CONDITION_ADDED_TO_DETACHED_BLOCK = 'hide_condition_added_to_detached_block'; - const ERROR_AFTER_BLOCK_ADDED = 'error_after_block_added'; - const ERROR_AFTER_BLOCK_REMOVED = 'error_after_block_removed'; - const LOG_HASH_TRANSIENT_BASE_NAME = 'wc_block_template_events_log_hash_'; /** - * Event types. + * Route base. * - * @var array + * @var string */ - public static $event_types = array(self::BLOCK_ADDED => array('level' => \WC_Log_Levels::DEBUG, 'message' => 'Block added to template.'), self::BLOCK_REMOVED => array('level' => \WC_Log_Levels::NOTICE, 'message' => 'Block removed from template.'), self::BLOCK_MODIFIED => array('level' => \WC_Log_Levels::NOTICE, 'message' => 'Block modified in template.'), self::BLOCK_ADDED_TO_DETACHED_CONTAINER => array('level' => \WC_Log_Levels::WARNING, 'message' => 'Block added to detached container. Block will not be included in the template, since the container will not be included in the template.'), self::HIDE_CONDITION_ADDED => array('level' => \WC_Log_Levels::NOTICE, 'message' => 'Hide condition added to block.'), self::HIDE_CONDITION_REMOVED => array('level' => \WC_Log_Levels::NOTICE, 'message' => 'Hide condition removed from block.'), self::HIDE_CONDITION_ADDED_TO_DETACHED_BLOCK => array('level' => \WC_Log_Levels::WARNING, 'message' => 'Hide condition added to detached block. Block will not be included in the template, so the hide condition is not needed.'), self::ERROR_AFTER_BLOCK_ADDED => array('level' => \WC_Log_Levels::WARNING, 'message' => 'Error after block added to template.'), self::ERROR_AFTER_BLOCK_REMOVED => array('level' => \WC_Log_Levels::WARNING, 'message' => 'Error after block removed from template.')); + protected $rest_base = 'orders'; /** - * Singleton instance. + * Post type used for orders. * - * @var BlockTemplateLogger + * @var string */ - protected static $instance = null; + protected $post_type = 'shop_order'; /** - * Logger instance. + * Schema class for this route. * - * @var \WC_Logger + * @var OrderSchema */ - protected $logger = null; + protected $item_schema; /** - * All template events. + * Query utils class. * - * @var array + * @var QueryUtils */ - private $all_template_events = array(); + protected $query_utils; /** - * Templates. + * Update utils class. * - * @var array + * @var UpdateUtils */ - private $templates = array(); + protected $update_utils; /** - * Threshold severity. + * Initialize the controller. * - * @var int - */ - private $threshold_severity = null; - /** - * Get the singleton instance. + * @param OrderSchema $item_schema Order schema class. + * @param CollectionQuery $query_utils Query utils class. + * @param UpdateUtils $update_utils Update utils class. + * @internal */ - public static function get_instance(): \Automattic\WooCommerce\Internal\Admin\BlockTemplates\BlockTemplateLogger + final public function init(\Automattic\WooCommerce\RestApi\Routes\V4\Orders\Schema\OrderSchema $item_schema, \Automattic\WooCommerce\RestApi\Routes\V4\Orders\CollectionQuery $query_utils, \Automattic\WooCommerce\RestApi\Routes\V4\Orders\UpdateUtils $update_utils) { } /** - * Constructor. + * Get the schema for the current resource. This use consumed by the AbstractController to generate the item schema + * after running various hooks on the response. */ - protected function __construct() + protected function get_schema(): array { } /** - * Get all template events for a given template as a JSON like array. + * Get the collection args schema. * - * @param string $template_id Template ID. + * @return array */ - public function template_events_to_json(string $template_id): array + protected function get_query_schema(): array { } /** - * Get all template events as a JSON like array. - * - * @param array $template_events Template events. - * - * @return array The JSON. + * Register the routes for orders. */ - private function to_json(array $template_events): array + public function register_routes() { } /** - * Log all template events for a given template to the log file. + * Prepare links for the request. * - * @param string $template_id Template ID. + * @param mixed $item WordPress representation of the item. + * @param WP_REST_Request $request Request object. + * @param WP_REST_Response $response Response object. + * @return array */ - public function log_template_events_to_file(string $template_id) + protected function prepare_links($item, \WP_REST_Request $request, \WP_REST_Response $response): array { } /** - * Has the template events changed since the last time they were logged? + * Prepare a single order object for response. * - * @param string $template_id Template ID. - * @param string $events_hash Events hash. + * @param WC_Order $order Order object. + * @param WP_REST_Request $request Request object. + * @return array */ - private function has_template_events_changed(string $template_id, string $events_hash) + protected function get_item_response($order, \WP_REST_Request $request): array { } /** - * Generate a hash for a given set of template events. + * Get a single item. * - * @param array $template_events Template events. + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response */ - private function generate_template_events_hash(array $template_events): string + public function get_item($request) { } /** - * Set the template events hash for a given template. + * Get collection of orders. * - * @param string $template_id Template ID. - * @param string $hash Hash of template events. + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response */ - private function set_template_events_log_hash(string $template_id, string $hash) + public function get_items($request) { } /** - * Log an event. + * Create a single item. * - * @param string $event_type Event type. - * @param BlockInterface $block Block. - * @param array $additional_info Additional info. + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response */ - private function log(string $event_type, \Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface $block, $additional_info = array()) + public function create_item($request) { } /** - * Should the logger handle a given level? + * Update a single item. * - * @param int $level Level to check. + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|WP_REST_Response */ - private function should_handle($level) + public function update_item($request) { } /** - * Add a template event. + * Delete a single item. * - * @param array $event_type_info Event type info. - * @param BlockTemplateInterface $template Template. - * @param ContainerInterface $container Container. - * @param BlockInterface $block Block. - * @param array $additional_info Additional info. + * @param WP_REST_Request $request Full details about the request. + * @return WP_REST_Response|WP_Error */ - private function add_template_event(array $event_type_info, \Automattic\WooCommerce\Admin\BlockTemplates\BlockTemplateInterface $template, \Automattic\WooCommerce\Admin\BlockTemplates\ContainerInterface $container, \Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface $block, array $additional_info = array()) + public function delete_item($request) { } /** - * Format a message for logging. + * Check if an order is valid. * - * @param string $message Message to log. - * @param array $info Additional info to log. + * @param WC_Order $order The order object. + * @return bool True if the order is valid, false otherwise. */ - private function format_message(string $message, array $info = array()): string + protected function is_valid_order_for_request($order): bool { } /** - * Format info for logging. + * Check if a given request has access to read items. * - * @param array $info Info to log. + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean */ - private function format_info(array $info): array + public function get_items_permissions_check($request) { } /** - * Format an exception for logging. + * Check if a given request has access to read an item. * - * @param \Exception $exception Exception to format. + * @param WP_REST_Request $request The request object. + * @return WP_Error|boolean */ - private function format_exception(\Exception $exception): array + public function get_item_permissions_check($request) { } /** - * Format an exception trace for logging. + * Check if a given request has access to create an item. * - * @param array $trace Exception trace to format. + * @param WP_REST_Request $request The request object. + * @return WP_Error|boolean */ - private function format_exception_trace(array $trace): array + public function create_item_permissions_check($request) { } /** - * Format a block template for logging. + * Check if a given request has access to update an item. * - * @param BlockTemplateInterface $template Template to format. + * @param WP_REST_Request $request The request object. + * @return WP_Error|boolean */ - private function format_template(\Automattic\WooCommerce\Admin\BlockTemplates\BlockTemplateInterface $template): string + public function update_item_permissions_check($request) { } /** - * Format a block for logging. + * Check if a given request has access to delete an item. * - * @param BlockInterface $block Block to format. + * @param WP_REST_Request $request The request object. + * @return bool|WP_Error */ - private function format_block(\Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface $block): string + public function delete_item_permissions_check($request) { } } } -namespace Automattic\WooCommerce\Internal\CostOfGoodsSold { +namespace Automattic\WooCommerce\RestApi\Routes\V4\Orders\Schema { /** - * Trait with common functionality for unit tests related to the Cost of Goods Sold feature. + * AbstractLineItemSchema class. */ - trait CogsAwareUnitTestSuiteTrait + abstract class AbstractLineItemSchema extends \Automattic\WooCommerce\RestApi\Routes\V4\AbstractSchema { /** - * Enable the Cost of Goods Sold feature. + * Get the meta data schema shared by all line item schemas. + * + * @return array */ - private function enable_cogs_feature() + protected function get_meta_data_schema(): array { } /** - * Enable the Cost of Goods Sold feature. + * Prepare the meta data for the order item. + * + * @param WC_Order_Item $order_item Order item instance. + * @return array */ - private function disable_cogs_feature() + protected function prepare_meta_data($order_item) { } /** - * Sets the expectation for a "doing it wrong" being thrown. + * Get the taxes schema shared by line item schemas. * - * @param string $method_name The method name inside the error message. + * @return array */ - private function expect_doing_it_wrong_cogs_disabled(string $method_name) + protected function get_taxes_schema(): array + { + } + /** + * Prepare the taxes for the order item. + * + * @param WC_Order_Item_Product|WC_Order_Item_Fee $order_item Order item instance. + * @param WP_REST_Request $request Request object. + * @return array + */ + protected function prepare_taxes($order_item, \WP_REST_Request $request) { } } -} -namespace Automattic\WooCommerce\Internal { /** - * Interface RegisterHooksInterface - * - * The following must be added at the end of the 'init_hooks' method in the 'WooCommerce' class - * for each class implementing this interface: - * $container->get( ::class )->register(); - * - * @since 8.5.0 + * OrderCouponSchema class. */ - interface RegisterHooksInterface + class OrderCouponSchema extends \Automattic\WooCommerce\RestApi\Routes\V4\Orders\Schema\AbstractLineItemSchema { /** - * Register this class instance to the appropriate hooks. + * The schema item identifier. * - * @return void + * @var string */ - public function register(); + const IDENTIFIER = 'order-coupon'; + /** + * Return all properties for the item schema. + * + * Note that context determines under which context data should be visible. For example, edit would be the context + * used when getting records with the intent of editing them. embed context allows the data to be visible when the + * item is being embedded in another response. + * + * @return array + */ + public function get_item_schema_properties(): array + { + } + /** + * Get an item response. + * + * @param WC_Order_Item_Coupon $order_item Order item instance. + * @param WP_REST_Request $request Request object. + * @param array $include_fields Fields to include in the response. + * @return array + */ + public function get_item_response($order_item, \WP_REST_Request $request, array $include_fields = array()): array + { + } } -} -namespace Automattic\WooCommerce\Internal\CostOfGoodsSold { /** - * Main controller for the Cost of Goods Sold feature. + * OrderFeeSchema class. */ - class CostOfGoodsSoldController implements \Automattic\WooCommerce\Internal\RegisterHooksInterface + class OrderFeeSchema extends \Automattic\WooCommerce\RestApi\Routes\V4\Orders\Schema\AbstractLineItemSchema { /** - * The instance of FeaturesController to use. + * The schema item identifier. * - * @var FeaturesController + * @var string */ - private \Automattic\WooCommerce\Internal\Features\FeaturesController $features_controller; + const IDENTIFIER = 'order-fee'; /** - * Register hooks. + * Return all properties for the item schema. + * + * Note that context determines under which context data should be visible. For example, edit would be the context + * used when getting records with the intent of editing them. embed context allows the data to be visible when the + * item is being embedded in another response. + * + * @return array */ - public function register() + public function get_item_schema_properties(): array { } /** - * Initialize the instance, runs when the instance is created by the dependency injection container. + * Get an item response. * - * @internal - * @param FeaturesController $features_controller The instance of FeaturesController to use. + * @param WC_Order_Item_Fee $order_item Order item instance. + * @param WP_REST_Request $request Request object. + * @param array $include_fields Fields to include in the response. + * @return array */ - final public function init(\Automattic\WooCommerce\Internal\Features\FeaturesController $features_controller) + public function get_item_response($order_item, \WP_REST_Request $request, array $include_fields = array()): array { } + } + /** + * OrderItemSchema class. + */ + class OrderItemSchema extends \Automattic\WooCommerce\RestApi\Routes\V4\Orders\Schema\AbstractLineItemSchema + { + use \Automattic\WooCommerce\Internal\CostOfGoodsSold\CogsAwareTrait; /** - * Is the Cost of Goods Sold engine enabled? + * The schema item identifier. * - * @return bool True if the engine is enabled, false otherwise. + * @var string */ - public function feature_is_enabled(): bool + const IDENTIFIER = 'order-item'; + /** + * Return all properties for the item schema. + * + * Note that context determines under which context data should be visible. For example, edit would be the context + * used when getting records with the intent of editing them. embed context allows the data to be visible when the + * item is being embedded in another response. + * + * @return array + */ + public function get_item_schema_properties(): array { } /** - * Add the feature information for the features settings page. - * - * @param FeaturesController $features_controller The instance of FeaturesController to use. + * Add the Cost of Goods Sold related fields to the schema. * - * @internal For exclusive usage of WooCommerce core, backwards compatibility not guaranteed. + * @param array $schema The original schema. + * @return array The updated schema. */ - public function add_feature_definition($features_controller) + private function add_cogs_related_schema(array $schema): array { } /** - * Add the entry for "add/remove COGS value column to/from the product meta lookup table" to the WooCommerce admin tools. - * - * @internal Hook handler, not to be explicitly used from outside the class. + * Get an item response. * - * @param array $tools_array Array to add the tool to. - * @return array Updated tools array. + * @param WC_Order_Item_Product $order_item Order item instance. + * @param WP_REST_Request $request Request object. + * @param array $include_fields Fields to include in the response. + * @return array */ - public function add_debug_tools_entry(array $tools_array): array + public function get_item_response($order_item, \WP_REST_Request $request, array $include_fields = array()): array { } /** - * Handler for the "add COGS value column to the product meta lookup table" admin tool. + * Filter the meta data for the order item. * - * @internal Tool callback, not to be explicitly used from outside the class. + * @param array $meta_data Meta data. + * @param WC_Order_Item_Product $order_item Order item instance. + * @param WP_REST_Request $request Request object. + * @return array */ - public function generate_lookup_cogs_columns() + protected function filter_meta_data(array $meta_data, \WC_Order_Item_Product $order_item, \WP_REST_Request $request) { } /** - * Handler for the "remove COGS value column to the product meta lookup table" admin tool. + * Get embedded product schema. * - * @internal Tool callback, not to be explicitly used from outside the class. + * @return array */ - public function remove_lookup_cogs_columns() + private function get_product_data_schema(): array { } /** - * Tells if the COGS value column exists in the product meta lookup table. + * Get product data. * - * @return bool True if the column exists, false otherwise. + * @param WC_Order_Item_Product $order_item Order item instance. + * @return array|null */ - public function product_meta_lookup_table_cogs_value_columns_exist(): bool + private function get_product_data(\WC_Order_Item_Product $order_item) { } /** - * Get the tooltip text for the COGS value field in the product editor. + * Get image. * - * @param bool $for_variable_products True to get the value for variable products, false for other types of products. - * @return string The string to use as tooltip (translated but not escaped). + * @param WC_Order_Item_Product $order_item Order item instance. + * @return string */ - public function get_general_cost_edit_field_tooltip(bool $for_variable_products) + private function get_image(\WC_Order_Item_Product $order_item) { } } -} -namespace Automattic\WooCommerce\Internal\ProductFilters\Interfaces { /** - * MainQueryClausesGenerator interface. - * - * @internal For exclusive usage of WooCommerce core, backwards compatibility not guaranteed. + * OrderSchema class. */ - interface MainQueryClausesGenerator + class OrderSchema extends \Automattic\WooCommerce\RestApi\Routes\V4\AbstractSchema { + use \Automattic\WooCommerce\Internal\CostOfGoodsSold\CogsAwareTrait; /** - * Add conditional query clauses for main query based on the filter params in query vars. + * The schema item identifier. * - * @param array $args Query args. - * @param \WP_Query $wp_query WP_Query object. - * @return array + * @var string */ - public function add_query_clauses_for_main_query(array $args, \WP_Query $wp_query): array; - } - /** - * QueryClausesGenerator interface. - * - * @internal For exclusive usage of WooCommerce core, backwards compatibility not guaranteed. - */ - interface QueryClausesGenerator - { + const IDENTIFIER = 'order'; /** - * Add conditional query clauses based on the filter params in query vars. + * The order item schema. * - * @param array $args Query args. - * @param \WP_Query $wp_query WP_Query object. - * @return array + * @var OrderItemSchema */ - public function add_query_clauses(array $args, \WP_Query $wp_query): array; - } -} -namespace Automattic\WooCommerce\Internal\Traits { - /** - * DON'T USE THIS TRAIT. It will be removed in WooCommerce 10.5. - * Instead, make the hook target methods public and mark them with an @internal annotation. - * - * This trait allows making private methods of a class accessible from outside. - * This is useful to define hook handlers with the [$this, 'method'] or [__CLASS__, 'method'] syntax - * without having to make the method public (and thus having to keep it forever for backwards compatibility). - * - * Example: - * - * class Foobar { - * use AccessiblePrivateMethods; - * - * public function __construct() { - * self::add_action('some_action', [$this, 'handle_some_action']); - * } - * - * public static function init() { - * self::add_filter('some_filter', [__CLASS__, 'handle_some_filter']); - * } - * - * private function handle_some_action() { - * } - * - * private static function handle_some_filter() { - * } - * } - * - * For this to work the callback must be an array and the first element of the array must be either '$this', '__CLASS__', - * or another instance of the same class; otherwise the method won't be marked as accessible - * (but the corresponding WordPress 'add_action' and 'add_filter' functions will still be called). - * - * No special procedure is needed to remove hooks set up with these methods, the regular 'remove_action' - * and 'remove_filter' functions provided by WordPress can be used as usual. - * - * @deprecated 9.6.0 Make the hook target methods public and mark them with an @internal annotation. This trait will be removed in WooCommerce 10.5. - */ - trait AccessiblePrivateMethods - { - //phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore + private $order_item_schema; /** - * List of instance methods marked as externally accessible. + * The order coupon schema. * - * @var array + * @var OrderCouponSchema */ - private $_accessible_private_methods = array(); + private $order_coupon_schema; /** - * List of static methods marked as externally accessible. + * The order fee schema. * - * @var array + * @var OrderFeeSchema */ - private static $_accessible_static_private_methods = array(); - //phpcs:enable PSR2.Classes.PropertyDeclaration.Underscore + private $order_fee_schema; /** - * Register a WordPress action. - * If the callback refers to a private or protected instance method in this class, the method is marked as externally accessible. - * - * $callback can be a standard callable, or a string representing the name of a method in this class. + * The order tax schema. * - * @param string $hook_name The name of the action to add the callback to. - * @param callable|string $callback The callback to be run when the action is called. - * @param int $priority Optional. Used to specify the order in which the functions - * associated with a particular action are executed. - * Lower numbers correspond with earlier execution, - * and functions with the same priority are executed - * in the order in which they were added to the action. Default 10. - * @param int $accepted_args Optional. The number of arguments the function accepts. Default 1. + * @var OrderTaxSchema */ - protected static function add_action(string $hook_name, $callback, int $priority = 10, int $accepted_args = 1): void - { - } + private $order_tax_schema; /** - * Register a WordPress filter. - * If the callback refers to a private or protected instance method in this class, the method is marked as externally accessible. + * The order shipping schema. * - * $callback can be a standard callable, or a string representing the name of a method in this class. + * @var OrderShippingSchema + */ + private $order_shipping_schema; + /** + * Initialize the schema. * - * @param string $hook_name The name of the filter to add the callback to. - * @param callable|string $callback The callback to be run when the filter is called. - * @param int $priority Optional. Used to specify the order in which the functions - * associated with a particular filter are executed. - * Lower numbers correspond with earlier execution, - * and functions with the same priority are executed - * in the order in which they were added to the filter. Default 10. - * @param int $accepted_args Optional. The number of arguments the function accepts. Default 1. + * @internal + * @param OrderItemSchema $order_item_schema The order item schema. + * @param OrderCouponSchema $order_coupon_schema The order coupon schema. + * @param OrderFeeSchema $order_fee_schema The order fee schema. + * @param OrderTaxSchema $order_tax_schema The order tax schema. + * @param OrderShippingSchema $order_shipping_schema The order shipping schema. */ - protected static function add_filter(string $hook_name, $callback, int $priority = 10, int $accepted_args = 1): void + final public function init(\Automattic\WooCommerce\RestApi\Routes\V4\Orders\Schema\OrderItemSchema $order_item_schema, \Automattic\WooCommerce\RestApi\Routes\V4\Orders\Schema\OrderCouponSchema $order_coupon_schema, \Automattic\WooCommerce\RestApi\Routes\V4\Orders\Schema\OrderFeeSchema $order_fee_schema, \Automattic\WooCommerce\RestApi\Routes\V4\Orders\Schema\OrderTaxSchema $order_tax_schema, \Automattic\WooCommerce\RestApi\Routes\V4\Orders\Schema\OrderShippingSchema $order_shipping_schema) { } /** - * Do the required processing to a callback before invoking the WordPress 'add_action' or 'add_filter' function. + * Return all properties for the item schema. * - * @param callable $callback The callback to process. - * @return void + * Note that context determines under which context data should be visible. For example, edit would be the context + * used when getting records with the intent of editing them. embed context allows the data to be visible when the + * item is being embedded in another response. + * + * @return array */ - protected static function process_callback_before_hooking($callback): void + public function get_item_schema_properties(): array { } /** - * Register a private or protected instance method of this class as externally accessible. + * Add the Cost of Goods Sold related fields to the schema. * - * @param string $method_name Method name. - * @return bool True if the method has been marked as externally accessible, false if the method doesn't exist. + * @param array $schema The original schema. + * @return array The updated schema. */ - protected function mark_method_as_accessible(string $method_name): bool + private static function add_cogs_related_schema(array $schema): array { } /** - * Register a private or protected static method of this class as externally accessible. + * Get an item response. * - * @param string $method_name Method name. - * @return bool True if the method has been marked as externally accessible, false if the method doesn't exist. + * @param WC_Order $order Order instance. + * @param WP_REST_Request $request Request object. + * @param array $include_fields Fields to include in the response. + * @return array */ - protected static function mark_static_method_as_accessible(string $method_name): bool + public function get_item_response($order, \WP_REST_Request $request, array $include_fields = array()): array { } /** - * Undefined/inaccessible instance method call handler. + * With HPOS, few internal meta keys such as _billing_address_index, _shipping_address_index are not considered internal anymore (since most internal keys were flattened into dedicated columns). * - * @param string $name Called method name. - * @param array $arguments Called method arguments. - * @return mixed - * @throws \Error The called instance method doesn't exist or is private/protected and not marked as externally accessible. + * This function helps in filtering out any remaining internal meta keys with HPOS is enabled. + * + * @param array $meta_data Order meta data. + * @return array Filtered order meta data. */ - public function __call($name, $arguments) + protected function filter_internal_meta_keys($meta_data) { } /** - * Undefined/inaccessible static method call handler. + * Limit the contents of the meta_data property based on certain request parameters. * - * @param string $name Called method name. - * @param array $arguments Called method arguments. - * @return mixed - * @throws \Error The called static method doesn't exist or is private/protected and not marked as externally accessible. + * Note that if both `include_meta` and `exclude_meta` are present in the request, + * `include_meta` will take precedence. + * + * @param array $meta_data All of the meta data for an object. + * @param \WP_REST_Request $request The request. + * + * @return array */ - public static function __callStatic($name, $arguments) + protected function get_meta_data_for_response($meta_data, $request) { } } -} -namespace Automattic\WooCommerce\LayoutTemplates { /** - * Layout template registry. + * OrderShippingSchema class. */ - final class LayoutTemplateRegistry + class OrderShippingSchema extends \Automattic\WooCommerce\RestApi\Routes\V4\Orders\Schema\AbstractLineItemSchema { /** - * Class instance. + * The schema item identifier. * - * @var LayoutTemplateRegistry|null + * @var string */ - private static $instance = null; + const IDENTIFIER = 'order-shipping'; /** - * Layout templates info. + * Return all properties for the item schema. * - * @var array - */ - protected $layout_templates_info = array(); - /** - * Layout template instances. + * Note that context determines under which context data should be visible. For example, edit would be the context + * used when getting records with the intent of editing them. embed context allows the data to be visible when the + * item is being embedded in another response. * - * @var array - */ - protected $layout_template_instances = array(); - /** - * Get the instance of the class. - */ - public static function get_instance(): \Automattic\WooCommerce\LayoutTemplates\LayoutTemplateRegistry - { - } - /** - * Unregister all layout templates. + * @return array */ - public function unregister_all() + public function get_item_schema_properties(): array { } /** - * Check if a layout template is registered. + * Get an item response. * - * @param string $layout_template_id Layout template ID. + * @param WC_Order_Item_Shipping $order_item Order item instance. + * @param WP_REST_Request $request Request object. + * @param array $include_fields Fields to include in the response. + * @return array */ - public function is_registered($layout_template_id): bool + public function get_item_response($order_item, \WP_REST_Request $request, array $include_fields = array()): array { } + } + /** + * OrderFeeSchema class. + */ + class OrderTaxSchema extends \Automattic\WooCommerce\RestApi\Routes\V4\Orders\Schema\AbstractLineItemSchema + { /** - * Register a single layout template. - * - * @param string $layout_template_id Layout template ID. - * @param string $layout_template_area Layout template area. - * @param string $layout_template_class_name Layout template class to register. + * The schema item identifier. * - * @throws \ValueError If a layout template with the same ID already exists. - * @throws \ValueError If the specified layout template area is empty. - * @throws \ValueError If the specified layout template class does not exist. - * @throws \ValueError If the specified layout template class does not implement the BlockTemplateInterface. + * @var string */ - public function register($layout_template_id, $layout_template_area, $layout_template_class_name) - { - } + const IDENTIFIER = 'order-tax'; /** - * Instantiate the matching layout templates and return them. + * Return all properties for the item schema. * - * @param array $query_params Query params. - */ - public function instantiate_layout_templates(array $query_params = array()): array - { - } - /** - * Instantiate a single layout template and return it. + * Note that context determines under which context data should be visible. For example, edit would be the context + * used when getting records with the intent of editing them. embed context allows the data to be visible when the + * item is being embedded in another response. * - * @param array $layout_template_info Layout template info. + * @return array */ - private function get_layout_template_instance($layout_template_info): \Automattic\WooCommerce\Admin\BlockTemplates\BlockTemplateInterface + public function get_item_schema_properties(): array { } /** - * Get matching layout templates info. + * Get an item response. * - * @param array $query_params Query params. + * @param WC_Order_Item_Tax $order_item Order item instance. + * @param WP_REST_Request $request Request object. + * @param array $include_fields Fields to include in the response. + * @return array */ - private function get_matching_layout_templates_info(array $query_params = array()): array + public function get_item_response($order_item, \WP_REST_Request $request, array $include_fields = array()): array { } } } -namespace Automattic\WooCommerce { +namespace Automattic\WooCommerce\RestApi\Routes\V4\Orders { /** - * Packages class. - * - * @since 3.7.0 + * UpdateUtils class. */ - class Packages + class UpdateUtils { + use \Automattic\WooCommerce\Internal\CostOfGoodsSold\CogsAwareTrait; /** - * Static-only class. + * The order schema. + * + * @var OrderSchema */ - private function __construct() - { - } + private $order_schema; /** - * Array of package names and their main package classes. Once a package has been merged into WooCommerce - * directly it should be removed from here and added to the merged packages array. + * Initialize the update utils. * - * @var array Key is the package name/directory, value is the main package class which handles init. + * @internal + * @param OrderSchema $order_schema The order schema. */ - protected static $packages = array('email-editor' => '\Automattic\WooCommerce\Internal\EmailEditor\Package'); + final public function init(\Automattic\WooCommerce\RestApi\Routes\V4\Orders\Schema\OrderSchema $order_schema) + { + } /** - * Array of package names and their main package classes. - * - * One a package has been merged into WooCommerce Core it should be moved from the package list and placed in - * this list. This will ensure that the feature plugin is disabled as well as provide the class to handle - * initialization for the now-merged feature plugin. - * - * Once a package has been merged into WooCommerce Core it should have its slug added here. This will ensure - * that we deactivate the feature plugin automatically to prevent any problems caused by conflicts between - * the two versions caused by them both being active. - * - * The packages included in this array cannot be deactivated and will always load with WooCommerce core. + * Update an order from the request. * - * @var array Key is the package name/directory, value is the main package class which handles init. + * @throws WC_REST_Exception When fails to set any item, \WC_Data_Exception When fails to set any item. + * @param WC_Order $order Order object. + * @param WP_REST_Request $request Request object. + * @param bool $creating True when creating object, false when updating. + * @return void */ - protected static $base_packages = array('woocommerce-admin' => '\Automattic\WooCommerce\Admin\Composer\Package', 'woocommerce-gutenberg-products-block' => '\Automattic\WooCommerce\Blocks\Package'); + public function update_order_from_request(\WC_Order $order, \WP_REST_Request $request, bool $creating = false) + { + } /** - * Similar to $base_packages, but - * the packages included in this array can be deactivated via the 'woocommerce_merged_packages' filter. + * Update address. * - * @var array Key is the package name/directory, value is the main package class which handles init. + * @param WC_Order $order Order data. + * @param string $type Type of address; 'billing' or 'shipping'. + * @param array $request_data Posted data. */ - protected static $merged_packages = array('woocommerce-brands' => '\Automattic\WooCommerce\Internal\Brands'); + protected function update_address(\WC_Order $order, string $type, array $request_data) + { + } /** - * Init the package loader. + * Update meta data. * - * @since 3.7.0 + * @param WC_Order $order Order data. + * @param array $meta_data Posted data. */ - public static function init() + protected function update_meta_data(\WC_Order $order, array $meta_data) { } /** - * Callback for WordPress init hook. + * Update line items from an array of line item data for an order. Non-posted line items are removed. + * + * @throws WC_REST_Exception If line items type is invalid. + * @param WC_Order $order The order to update the line items for. + * @param array $line_items The line items to update. + * @param string $line_items_type The type of line items to update. */ - public static function on_init() + protected function update_line_items(\WC_Order $order, array $line_items, string $line_items_type = 'line_item') { } /** - * Checks a package exists by looking for it's directory. + * Wrapper method to create/update order items. + * When updating, the item ID provided is checked to ensure it is associated with the order. * - * @param string $package Package name. - * @return boolean + * @throws WC_REST_Exception If item ID is not associated with order. + * @param WC_Order $order order object. + * @param string $line_items_type The item type. + * @param array $line_item_data item provided in the request body. + * @return int The ID of the updated or created item. */ - public static function package_exists($package) + protected function update_line_item(\WC_Order $order, string $line_items_type, array $line_item_data) { } /** - * Checks a package exists by looking for it's directory. + * Helper method to check if the resource ID associated with the provided item is null. + * Items can be deleted by setting the resource ID to null. * - * @param string $class_name Class name. - * @return boolean + * @param array $item Item provided in the request body. + * @return bool True if the item resource ID is null, false otherwise. */ - public static function should_load_class($class_name) + protected function item_is_null_or_zero($item) { } /** - * Gets all merged, enabled packages. + * Wrapper method to remove order items. + * When updating, the item ID provided is checked to ensure it is associated with the order. * - * @return array + * @param WC_Order $order The order to remove the item from. + * @param string $line_items_type The item type. + * @param int $item_id The ID of the item to remove. + * + * @return void + * @throws WC_REST_Exception If item ID is not associated with order. */ - protected static function get_enabled_packages() + protected function remove_item_from_order(\WC_Order $order, string $line_items_type, int $item_id): void { } /** - * Checks if a package is enabled. + * Gets the product ID from the SKU or posted ID. * - * @param string $package Package name. - * @return boolean + * @throws WC_REST_Exception When SKU or ID is not valid. + * @param array $request_data Request data. + * @param string $action 'create' to add line item or 'update' to update it. + * @return int */ - public static function is_package_enabled($package) + protected function get_product_id_from_line_item($request_data, $action = 'create') { } /** - * Prepare merged packages for initialization. - * Especially useful when running actions early in the 'plugins_loaded' timeline. + * Create or update a line item, overridden to add COGS data as needed. + * + * @param array $request_data Line item data. + * @param string $action 'create' to add line item or 'update' to update it. + * @param object $item Passed when updating an item. Null during creation. + * @return WC_Order_Item_Product + * @throws WC_REST_Exception Invalid data, server error. */ - public static function prepare_packages() + protected function prepare_line_item_data($request_data, $action = 'create', $item = null) { } /** - * Deactivates merged feature plugins. + * Create or update an order shipping method. * - * Once a feature plugin is merged into WooCommerce Core it should be deactivated. This method will - * ensure that a plugin gets deactivated. Note that for the first request it will still be active, - * and as such, there may be some odd behavior. This is unlikely to cause any issues though - * because it will be deactivated on the request that updates or activates WooCommerce. + * @param array $request_data $shipping Item data. + * @param string $action 'create' to add shipping or 'update' to update it. + * @param object $item Passed when updating an item. Null during creation. + * @return WC_Order_Item_Shipping + * @throws WC_REST_Exception Invalid data, server error. */ - protected static function deactivate_merged_packages() + protected function prepare_shipping_data($request_data, $action = 'create', $item = null) { } /** - * Prevent plugins already merged into WooCommerce core from getting activated as standalone plugins. + * Create or update an order fee. * - * @param string $plugin Plugin name. + * @param array $request_data Item data. + * @param string $action 'create' to add fee or 'update' to update it. + * @param object $item Passed when updating an item. Null during creation. + * @return WC_Order_Item_Fee + * @throws WC_REST_Exception Invalid data, server error. */ - public static function deactivate_merged_plugins($plugin) + protected function prepare_fee_data($request_data, $action = 'create', $item = null) { } /** - * Mark merged plugins as pending update. - * This is required for correctly displaying maintenance notices. + * Create or update an order coupon. * - * @param array $plugins Plugins list. + * @param array $request_data Item data. + * @param string $action 'create' to add coupon or 'update' to update it. + * @param object $item Passed when updating an item. Null during creation. + * @return WC_Order_Item_Coupon + * @throws WC_REST_Exception Invalid data, server error. */ - public static function mark_merged_plugins_as_pending_update($plugins) + protected function prepare_coupon_data($request_data, $action = 'create', $item = null) { } /** - * Displays a maintenance notice next to merged plugins, to inform users - * that the plugin functionality is now offered by WooCommerce core. - * - * Requires 'mark_merged_plugins_as_pending_update' to properly display this notice. + * Maybe set an item prop if the value was posted. * - * @param string $plugin_file Plugin file. + * @param WC_Order_Item $item Order item. + * @param string $prop Order property. + * @param array $request_data Request data. */ - public static function display_notice_for_merged_plugins($plugin_file) + protected function maybe_set_item_prop($item, $prop, $request_data) { } /** - * Loads packages after plugins_loaded hook. + * Maybe set item props if the values were posted. * - * Each package should include an init file which loads the package so it can be used by core. + * @param WC_Order_Item $item Order item data. + * @param string[] $props Properties. + * @param array $request_data Request data. */ - protected static function initialize_packages() + protected function maybe_set_item_props($item, $props, $request_data) { } /** - * If a package is missing, add an admin notice. + * Maybe set item meta if posted. * - * @param string $package Package name. + * @param WC_Order_Item $item Order item data. + * @param array $request_data Request data. */ - protected static function missing_package($package) + protected function maybe_set_item_meta_data($item, $request_data) { } } } -namespace Automattic\WooCommerce\Proxies { +namespace Automattic\WooCommerce\RestApi\Routes\V4\ShippingZones { /** - * Proxy for interacting with WordPress actions and filters. + * REST API Shipping Zones Controller Class. * - * This class should be used instead of directly accessing the WordPress functions, to ease unit testing. + * @extends AbstractController */ - class ActionsProxy + class Controller extends \Automattic\WooCommerce\RestApi\Routes\V4\AbstractController { /** - * Retrieve the number of times an action is fired. + * Route base. * - * @param string $tag The name of the action hook. + * @var string + */ + protected $rest_base = 'shipping-zones'; + /** + * Schema instance. * - * @return int The number of times action hook $tag is fired. + * @var ShippingZoneSchema */ - public function did_action($tag) + protected $item_schema; + /** + * Initialize the controller. + * + * @param ShippingZoneSchema $zone_schema Order schema class. + * @internal + */ + final public function init(\Automattic\WooCommerce\RestApi\Routes\V4\ShippingZones\ShippingZoneSchema $zone_schema) { } /** - * Calls the callback functions that have been added to a filter hook. + * Get the schema for the current resource. This use consumed by the AbstractController to generate the item schema + * after running various hooks on the response. + */ + protected function get_schema(): array + { + } + /** + * Register the routes for shipping zones. + */ + public function register_routes() + { + } + /** + * Get shipping zone by ID. * - * @param string $tag The name of the filter hook. - * @param mixed $value The value to filter. - * @param mixed ...$parameters Additional parameters to pass to the callback functions. + * @param WP_REST_Request $request Full details about the request. + * @return WP_REST_Response|WP_Error + */ + public function get_item($request) + { + } + /** + * Get all shipping zones. * - * @return mixed The filtered value after all hooked functions are applied to it. + * @param WP_REST_Request $request Full details about the request. + * @return WP_REST_Response|WP_Error */ - public function apply_filters($tag, $value, ...$parameters) + public function get_items($request) + { + } + /** + * Prepare a single order object for response. + * + * @param WC_Shipping_Zone $zone Shipping zone object. + * @param WP_REST_Request $request Request object. + * @return array + */ + protected function get_item_response($zone, \WP_REST_Request $request): array + { + } + /** + * Check whether a given request has permission to read shipping zones. + * + * @param WP_REST_Request $request Full details about the request. + * @return WP_Error|boolean + */ + public function get_items_permissions_check($request) { } - // TODO: Add the rest of the actions and filters related methods. } /** - * Proxy class to access legacy WooCommerce functionality. - * - * This class should be used to interact with code outside the `src` directory, especially functions and classes - * in the `includes` directory, unless a more specific proxy exists for the functionality at hand (e.g. `ActionsProxy`). - * Idempotent functions can be executed directly. + * ShippingZoneSchema class. */ - class LegacyProxy + class ShippingZoneSchema extends \Automattic\WooCommerce\RestApi\Routes\V4\AbstractSchema { /** - * Gets an instance of a given legacy class. - * This must not be used to get instances of classes in the `src` directory. - * - * If a given class needs a special procedure to get an instance of it, - * please add a private get_instance_of_(lowercased_class_name) and it will be - * automatically invoked. See also how objects of classes having a static `instance` - * method are retrieved, similar approaches can be used as needed to make use - * of existing factory methods such as e.g. 'load'. + * The schema item identifier. * - * @param string $class_name The name of the class to get an instance for. - * @param mixed ...$args Parameters to be passed to the class constructor or to the appropriate internal 'get_instance_of_' method. + * @var string + */ + const IDENTIFIER = 'shipping_zone'; + /** + * Return all properties for the item schema. * - * @return object The instance of the class. - * @throws \Exception The requested class has a namespace starting with ' Automattic\WooCommerce', or there was an error creating an instance of the class. + * @return array */ - public function get_instance_of(string $class_name, ...$args) + public function get_item_schema_properties(): array { } /** - * Get an instance of a class implementing WC_Queue_Interface. + * Get the item response. * - * @return \WC_Queue_Interface The instance. + * @param WC_Shipping_Zone $zone WordPress representation of the zone. + * @param WP_REST_Request $request Request object. + * @param array $include_fields Fields to include in the response. + * @return array The item response. */ - private function get_instance_of_wc_queue_interface() + public function get_item_response($zone, \WP_REST_Request $request, array $include_fields = array()): array { } /** - * Call a user function. This should be used to execute any non-idempotent function, especially - * those in the `includes` directory or provided by WordPress. - * - * @param string $function_name The function to execute. - * @param mixed ...$parameters The parameters to pass to the function. + * Get array of location names for display. * - * @return mixed The result from the function. + * @param WC_Shipping_Zone $zone Shipping zone object. + * @param string $view The view for which the API is requested ('summary' or 'detailed'). + * @return array */ - public function call_function($function_name, ...$parameters) + protected function get_formatted_zone_locations(\WC_Shipping_Zone $zone, string $view = 'summary'): array { } /** - * Call a static method in a class. This should be used to execute any non-idempotent method in classes - * from the `includes` directory. - * - * @param string $class_name The name of the class containing the method. - * @param string $method_name The name of the method. - * @param mixed ...$parameters The parameters to pass to the method. + * Get formatted methods for a zone. * - * @return mixed The result from the method. + * @param WC_Shipping_Zone $zone Shipping zone object. + * @return array */ - public function call_static($class_name, $method_name, ...$parameters) + protected function get_formatted_zone_methods($zone) { } /** - * Get the value of a global. + * Get raw method settings for frontend processing. * - * @param string $global_name The name of the global to get the value for. - * @return mixed The value of the global. + * @param object $method Shipping method object. + * @return array */ - public function get_global(string $global_name) + protected function get_method_settings($method) { } /** - * Terminates execution of the script. + * Get location name from location object. * - * @param int|string $status An error code to be returned, or an error message to be shown. - * @return void + * @param object $location Location object. + * @return string */ - public function exit($status = '') + protected function get_location_name($location) { } } @@ -114862,6 +118583,15 @@ protected function get_product_id(\WC_Product $product) protected function get_variation_id(\WC_Product $product) { } + /** + * Get product name, hiding it for draft and private products. + * + * @param \WC_Product $product Product instance. + * @return string + */ + protected function get_product_name(\WC_Product $product) + { + } /** * Default exception thrown when an item cannot be added to the cart. * @@ -116801,8 +120531,8 @@ public function generate_incompatible_plugin_feature_warning(string $feature_id, } /** * Filter plugin/feature compatibility info, returning the names of the plugins/features that are considered incompatible. - * "Uncertain" information will be included or not depending on the value of the value of the 'plugins_are_incompatible_by_default' - * flag in the feature definition (default is true). + * "Uncertain" information will be included or not depending on the value of the value of the 'default_plugin_compatibility' + * flag in the feature definition (default is 'compatible'). * * @param string $feature_id Feature id. * @param array $compatibility_info Array containing "compatible', 'incompatible' and 'uncertain' keys.