Merge branch 'trunk' into update/woocommerce-blocks-6.9.0

This commit is contained in:
Roy Ho 2022-02-10 06:45:17 -08:00 committed by GitHub
commit 53d30f7000
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 232 additions and 121 deletions

View File

@ -77,6 +77,15 @@ jest --group=api
## Writing tests ## Writing tests
### Conventions
1. All tests should be placed in the `tests` directory.
1. Always provide a JS doc in all tests, and tag them with `@group`. See the [Test groups](#test-groups) section for more info on grouping tests.
1. Use functions in the `data` folder when generating test data instead of constructing them from scratch within the test.
1. Use functions in the `endpoints` folder to send requests instead of directly using SuperTest's `request()` function.
1. Use `describe.each()` or `it.each()` when writing repetitive tests.
1. Always clean up all test data generated by the tests.
### Test groups ### Test groups
This package makes use of the `jest-runner-groups` package, which allows grouping tests together around semantic groups (such as `orders` API calls, or `coupons` API calls) to make running test suites more granular. This package makes use of the `jest-runner-groups` package, which allows grouping tests together around semantic groups (such as `orders` API calls, or `coupons` API calls) to make running test suites more granular.
@ -116,6 +125,20 @@ const queryString = {
const response = await getRequest('/orders', queryString); const response = await getRequest('/orders', queryString);
``` ```
## Creating test data
Most of the time, test data would be in the form of a request payload. Instead of building them from scratch inside the test, create a test data file inside the `data` directory. Create a model of the request payload within that file, and export it as an object or a function that generates this object.
Afterwards, make sure to add the test data file to the `data/index.js` file.
This way, the test data would be decoupled from the test itself, allowing for easier test data management, and more readable tests.
## Creating endpoint functions
All functions for sending requests to endpoints should be placed in the `endpoints` directory.
Newly created files should be added to the `endpoints/index.js` file.
## Debugging tests ## Debugging tests
You can make use of the REST API log plugin to see how requests are being made, and check the request payload, response, and more. You can make use of the REST API log plugin to see how requests are being made, and check the request payload, response, and more.

View File

@ -4,7 +4,6 @@
"description": "API tests for WooCommerce", "description": "API tests for WooCommerce",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"preinstall": "npx only-allow pnpm",
"test": "jest", "test": "jest",
"test:api": "jest --group=api", "test:api": "jest --group=api",
"test:hello": "jest --group=hello", "test:hello": "jest --group=hello",

View File

@ -26,7 +26,6 @@
], ],
"sideEffects": false, "sideEffects": false,
"scripts": { "scripts": {
"preinstall": "npx only-allow pnpm",
"clean": "rm -rf ./dist ./tsconfig.tsbuildinfo", "clean": "rm -rf ./dist ./tsconfig.tsbuildinfo",
"compile": "tsc -b", "compile": "tsc -b",
"build": "pnpm run clean && npm run compile", "build": "pnpm run clean && npm run compile",

View File

@ -1,16 +1,13 @@
# Unreleased # Unreleased
## Changed
- Updated top level menu css selectors
## Fixed ## Fixed
- Moved `merchant.login()` out of `beforeAll()` block and into test body for retried runs. - Moved `merchant.login()` out of `beforeAll()` block and into test body for retried runs.
## Added ## Added
- A `specs/data` folder to store page element data. - A `specs/data` folder to store page element data.
- Tests to verify that different top-level menu and their associated sub-menus load successfully. - Tests to verify that different top-level menus and their associated sub-menus load successfully.
- Test scaffolding via `npx wc-e2e install @woocommerce/e2e-core-tests` - Test scaffolding via `npx wc-e2e install @woocommerce/e2e-core-tests`
## Changed ## Changed

View File

@ -1,5 +1,12 @@
/**
* External dependencies
*/
const path = require( 'path' );
const buildPath = ( filename ) => `installFiles${path.sep}${filename}`;
module.exports = { module.exports = {
testSpecs: 'installFiles/scaffold-tests.json', testSpecs: buildPath( 'scaffold-tests.json' ),
defaultJson: 'installFiles/default-test-config.json', defaultJson: buildPath( 'default-test-config.json' ),
initializeSh: 'installFiles/initialize.sh.default', initializeSh: buildPath( 'initialize.sh.default' ),
}; };

View File

@ -45,7 +45,6 @@
"access": "public" "access": "public"
}, },
"scripts": { "scripts": {
"preinstall": "npx only-allow pnpm",
"prepare": "pnpm run build", "prepare": "pnpm run build",
"clean": "rm -rf ./build ./build-module", "clean": "rm -rf ./build ./build-module",
"compile": "node ./../bin/build.js", "compile": "node ./../bin/build.js",

View File

@ -1,34 +1,31 @@
# Unreleased # Unreleased
## Changes
- Updated `deleteDownloadedPluginFiles()` to also be able to delete directories.
## Added ## Added
- Added `post-results-to-github-pr.js` to post smoke test results to a GitHub PR. - Added `post-results-to-github-pr.js` to post test results to a GitHub PR.
- Added jest flags to generate a json test report
- Added more entries to `default.json` - Added more entries to `default.json`
- Added test retry support
- Save `test-results.json` from test runs to the `tests/e2e` folder. - Save `test-results.json` from test runs to the `tests/e2e` folder.
- Added `await` for every call to `shopper.logout`
- Updated `getLatestReleaseZipUrl()` to allow passing in an authorization token and simplified arguments to just the repository name
- Added `upload.ini` which increases the limits for uploading files (such as for plugins) in the Docker environment - Added `upload.ini` which increases the limits for uploading files (such as for plugins) in the Docker environment
- Test setup, scaffolding, and removal via `wc-e2e install` and `wc-e2e uninstall` - Test setup, scaffolding, and removal via `wc-e2e install` and `wc-e2e uninstall`
- Added quotes around `WORDPRESS_TITLE` value in .env file to address issue with docker compose 2 "key cannot contain a space" error.
- Added `LATEST_WP_VERSION_MINUS` that allows setting a number to subtract from the current WordPress version for the WordPress Docker image. - Added `LATEST_WP_VERSION_MINUS` that allows setting a number to subtract from the current WordPress version for the WordPress Docker image.
- Support for PHP_VERSION, MARIADB_VERSION environment variables for built in container initialization - Support for PHP_VERSION, MARIADB_VERSION environment variables for built in container initialization
- `resolveLocalE2ePath` to resolve path to local E2E file - `resolveLocalE2ePath()` to resolve path to local E2E file
- `resolvePackagePath()` to resolve path to package file
- `WC_E2E_FOLDER` for mapping plugin root to path within repo - `WC_E2E_FOLDER` for mapping plugin root to path within repo
- Added the `resolveSingleE2EPath` method which builds a path to a specific E2E test - Added the `resolveSingleE2EPath()` method which builds a path to a specific E2E test
- Added the ability to take screenshots from multiple test failures (when retried) in `utils/take-screenshot.js`. - Added the ability to take screenshots from multiple test failures (when retried) in `utils/take-screenshot.js`.
## Changed ## Changed
- Updated `getLatestReleaseZipUrl()` to allow passing in an authorization token and simplified arguments to just the repository name - Updated `getLatestReleaseZipUrl()` to allow passing in an authorization token and simplified arguments to just the repository name
- Updated `deleteDownloadedPluginFiles()` to also be able to delete directories.
## Fixed ## Fixed
- Updated the browserViewport in `jest.setup.js` to match the `defaultViewport` dimensions defined in `jest-puppeteer.config.js` - Updated the browserViewport in `jest.setup.js` to match the `defaultViewport` dimensions defined in `jest-puppeteer.config.js`
- Use consistent `defaultViewport` in both headless and non-headless context - Use consistent `defaultViewport` in both headless and non-headless context
- Fixed issue with docker compose 2 "key cannot contain a space" error.
- Add missing `config` dependency - Add missing `config` dependency
# 0.2.3 # 0.2.3

View File

@ -10,7 +10,7 @@ if [[ $1 ]]; then
if [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+ ]]; then if [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+ ]]; then
export WORDPRESS_VERSION=$WP_VERSION export WORDPRESS_VERSION=$WP_VERSION
else else
export WORDPRESS_VERSION="5.8.0" export WORDPRESS_VERSION="5.9"
fi fi
if [[ $LATEST_WP_VERSION_MINUS ]]; then if [[ $LATEST_WP_VERSION_MINUS ]]; then

View File

@ -24,12 +24,24 @@ const {
} = require( '../utils/scaffold' ); } = require( '../utils/scaffold' );
const args = process.argv.slice( 2 ); const args = process.argv.slice( 2 );
const [ command, packageName ] = args; const command = args[ 0 ];
let packageName = null;
if ( args[ 1 ] && args[ 1 ].substr(0, 2) !== '--' ) {
packageName = args[ 1 ];
}
// Allow multiple spec file extensions and formats. // Allow multiple spec file extensions and formats.
let testExtension = 'test.js'; let testExtension = 'test.js';
let testFormat = ''; let testFormat = '';
for ( let a = 2; a < args.length; a++ ) { let force = false;
for ( let a = 1; a < args.length; a++ ) {
if ( args[ a ] === '--force' ) {
force = true;
continue;
}
// These arguments take a value, eg: --format foo
const nextArg = a + 1; const nextArg = a + 1;
if ( nextArg >= args.length ) { if ( nextArg >= args.length ) {
break; break;
@ -50,7 +62,7 @@ for ( let a = 2; a < args.length; a++ ) {
if ( command == 'install' ) { if ( command == 'install' ) {
// Install some environment defaults if no package is requested. // Install some environment defaults if no package is requested.
if ( ! packageName ) { if ( ! packageName ) {
installDefaults(); installDefaults( force );
return; return;
} }
@ -66,7 +78,7 @@ if ( command == 'install' ) {
if ( defaultJson ) { if ( defaultJson ) {
const defaultJsonName = `config${path.sep}default-${packageSlug}.json`; const defaultJsonName = `config${path.sep}default-${packageSlug}.json`;
createLocalE2ePath( 'config' ); createLocalE2ePath( 'config' );
if ( confirmLocalCopy( defaultJsonName, defaultJson, pkg ) ) { if ( confirmLocalCopy( defaultJsonName, defaultJson, pkg, force ) ) {
console.log( `Created sample test configuration to 'tests/e2e/${defaultJsonName}'.` ); console.log( `Created sample test configuration to 'tests/e2e/${defaultJsonName}'.` );
} }
} }
@ -75,7 +87,7 @@ if ( command == 'install' ) {
if ( initializeSh ) { if ( initializeSh ) {
const defaultInitName = `docker${path.sep}${packageSlug}.sh`; const defaultInitName = `docker${path.sep}${packageSlug}.sh`;
createLocalE2ePath( 'docker' ); createLocalE2ePath( 'docker' );
if ( confirmLocalCopy( defaultInitName, initializeSh, pkg ) ) { if ( confirmLocalCopy( defaultInitName, initializeSh, pkg, force ) ) {
console.log( `Created sample test container initialization script to 'tests/e2e/${defaultInitName}'.` ); console.log( `Created sample test container initialization script to 'tests/e2e/${defaultInitName}'.` );
} }
} }
@ -95,13 +107,16 @@ if ( command == 'install' ) {
const eol = "\n"; const eol = "\n";
const autoGenerate = sprintf( '/* This file was auto-generated by the command `npx wc-e2e install %s`. */', packageName ); const autoGenerate = sprintf( '/* This file was auto-generated by the command `npx wc-e2e install %s`. */', packageName );
let importLineFormat; let importLineFormat;
let overwriteFiles;
let confirmPrompt; let confirmPrompt;
if ( testFormat.toLowerCase() == 'cjs' ) { if ( testFormat.toLowerCase() == 'cjs' ) {
importLineFormat = sprintf( "const {%%s} = require( '%s' );", pkg ); importLineFormat = sprintf( "const {%%s} = require( '%s' );", pkg );
} else { } else {
importLineFormat = sprintf( "import {%%s} from '%s';", pkg ); importLineFormat = sprintf( "import {%%s} from '%s';", pkg );
} }
let overwriteFiles;
if ( force ) {
overwriteFiles = 'a';
}
// Create the specs folder if not present // Create the specs folder if not present
let specFolderPath = createLocalE2ePath( 'specs' ); let specFolderPath = createLocalE2ePath( 'specs' );

View File

@ -5,7 +5,7 @@ const babelConfig = require( './babel.config' );
const esLintConfig = require( './.eslintrc.js' ); const esLintConfig = require( './.eslintrc.js' );
const allE2EConfig = require( './config' ); const allE2EConfig = require( './config' );
const allE2EUtils = require( './utils' ); const allE2EUtils = require( './utils' );
const slackUtils = require( './src/slack' ); const slackUtils = require( './build/slack' );
/** /**
* External dependencies * External dependencies
*/ */

View File

@ -35,7 +35,8 @@
"jest-each": "25.5.0", "jest-each": "25.5.0",
"jest-puppeteer": "^4.4.0", "jest-puppeteer": "^4.4.0",
"node-stream-zip": "^1.13.6", "node-stream-zip": "^1.13.6",
"readline-sync": "^1.4.10", "puppeteer": "2.1.1",
"readline-sync": "^1.4.10",
"request": "^2.88.2", "request": "^2.88.2",
"sprintf-js": "^1.1.2" "sprintf-js": "^1.1.2"
}, },

View File

@ -46,15 +46,16 @@ const confirm = ( prompt, choices ) => {
* @param {string} localE2ePath Destination path * @param {string} localE2ePath Destination path
* @param {string} packageE2ePath Source path * @param {string} packageE2ePath Source path
* @param {string} packageName Source package. Default @woocommerce/e2e-environment package. * @param {string} packageName Source package. Default @woocommerce/e2e-environment package.
* @param {boolean} force Whether to override files if they exist without confirmation.
* @return {boolean} * @return {boolean}
*/ */
const confirmLocalCopy = ( localE2ePath, packageE2ePath, packageName = '' ) => { const confirmLocalCopy = ( localE2ePath, packageE2ePath, packageName = '', force = false ) => {
const localPath = resolveLocalE2ePath( localE2ePath ); const localPath = resolveLocalE2ePath( localE2ePath );
const packagePath = resolvePackagePath( packageE2ePath, packageName ); const packagePath = resolvePackagePath( packageE2ePath, packageName );
const confirmPrompt = `${localE2ePath} already exists. Overwrite? [Y]es/[n]o: `; const confirmPrompt = `${localE2ePath} already exists. Overwrite? [Y]es/[n]o: `;
let overwriteFiles; let overwriteFiles;
if ( fs.existsSync( localPath ) ) { if ( ! force && fs.existsSync( localPath ) ) {
overwriteFiles = confirm( confirmPrompt, 'ny' ); overwriteFiles = confirm( confirmPrompt, 'ny' );
overwriteFiles = overwriteFiles.toLowerCase(); overwriteFiles = overwriteFiles.toLowerCase();
} else { } else {
@ -102,16 +103,16 @@ const getPackageData = ( packageName ) => {
/** /**
* Install test runner and test container defaults * Install test runner and test container defaults
*/ */
const installDefaults = () => { const installDefaults = ( force ) => {
createLocalE2ePath( 'docker' ); createLocalE2ePath( 'docker' );
console.log( 'Writing tests/e2e/docker/initialize.sh' ); console.log( 'Writing tests/e2e/docker/initialize.sh' );
confirmLocalCopy( `docker${path.sep}initialize.sh`, `installFiles${path.sep}initialize.sh` ); confirmLocalCopy( `docker${path.sep}initialize.sh`, `installFiles${path.sep}initialize.sh`, '', force );
createLocalE2ePath( 'config' ); createLocalE2ePath( 'config' );
console.log( 'Writing tests/e2e/config/jest.config.js' ); console.log( 'Writing tests/e2e/config/jest.config.js' );
confirmLocalCopy( `config${path.sep}jest.config.js`, `installFiles${path.sep}jest.config.js.default` ); confirmLocalCopy( `config${path.sep}jest.config.js`, `installFiles${path.sep}jest.config.js.default`, '', force );
console.log( 'Writing tests/e2e/config/jest.setup.js' ); console.log( 'Writing tests/e2e/config/jest.setup.js' );
confirmLocalCopy( `config${path.sep}jest.setup.js`, `installFiles${path.sep}jest.setup.js.default` ); confirmLocalCopy( `config${path.sep}jest.setup.js`, `installFiles${path.sep}jest.setup.js.default`, '', force );
}; };
module.exports = { module.exports = {

View File

@ -4,10 +4,6 @@
- Identified the default product category using `slug == 'uncategorized'` in `deleteAllProductCategories` - Identified the default product category using `slug == 'uncategorized'` in `deleteAllProductCategories`
## Changes
- Removed `page.waitForNavigation()` from `shopper.logout()`
## Added ## Added
- `utils.waitForTimeout( delay )` pause processing for `delay` milliseconds - `utils.waitForTimeout( delay )` pause processing for `delay` milliseconds
@ -15,8 +11,6 @@
- Update `shopper.addToCartFromShopPage()` and `.removeFromCart()` to accept product Id or Title - Update `shopper.addToCartFromShopPage()` and `.removeFromCart()` to accept product Id or Title
- Added `deleteAllProductAttributes()`, `deleteAllProductCategories()`, and `deleteAllProductTags()` to clean up meta data added when products are imported - Added `deleteAllProductAttributes()`, `deleteAllProductCategories()`, and `deleteAllProductTags()` to clean up meta data added when products are imported
- Added `withRestApi.createProductCategory()` that creates a product category and returns the ID - Added `withRestApi.createProductCategory()` that creates a product category and returns the ID
- `deleteAllProductAttributes()`, `deleteAllProductCategories()`, and `deleteAllProductTags()` to clean up meta data added when products are imported
- `withRestApi.createProductCategory()` that creates a product category and returns the ID
- `withRestApi.deleteCoupon()` that deletes a single coupon - `withRestApi.deleteCoupon()` that deletes a single coupon
- `withRestApi.addTaxClasses()` that adds an array of tax classes if they do not exist - `withRestApi.addTaxClasses()` that adds an array of tax classes if they do not exist
- `withRestApi.addTaxRates()` that adds an array of tax rates if they do not exist - `withRestApi.addTaxRates()` that adds an array of tax rates if they do not exist

View File

@ -41,7 +41,6 @@
"access": "public" "access": "public"
}, },
"scripts": { "scripts": {
"preinstall": "npx only-allow pnpm",
"clean": "rm -rf ./build ./build-module", "clean": "rm -rf ./build ./build-module",
"compile": "node ./../bin/build.js", "compile": "node ./../bin/build.js",
"build": "pnpm run clean && pnpm run compile", "build": "pnpm run clean && pnpm run compile",

View File

@ -17,8 +17,8 @@ export function simpleProductFactory( httpClient ) {
} ); } );
return { return {
name: params.name ?? faker.commerce.productName(), name: params.name ? params.name : faker.commerce.productName(),
regularPrice: params.regularPrice ?? faker.commerce.price(), regularPrice: params.regularPrice ? params.regularPrice : faker.commerce.price(),
}; };
} ); } );
} }

View File

@ -21,7 +21,7 @@
"pelago/emogrifier": "3.1.0", "pelago/emogrifier": "3.1.0",
"psr/container": "1.0.0", "psr/container": "1.0.0",
"woocommerce/action-scheduler": "3.4.0", "woocommerce/action-scheduler": "3.4.0",
"woocommerce/woocommerce-admin": "3.1.0", "woocommerce/woocommerce-admin": "3.2.0-rc.1",
"woocommerce/woocommerce-blocks": "6.9.0" "woocommerce/woocommerce-blocks": "6.9.0"
}, },
"require-dev": { "require-dev": {

View File

@ -543,16 +543,16 @@
}, },
{ {
"name": "woocommerce/woocommerce-admin", "name": "woocommerce/woocommerce-admin",
"version": "3.1.0", "version": "3.2.0-rc.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/woocommerce/woocommerce-admin.git", "url": "https://github.com/woocommerce/woocommerce-admin.git",
"reference": "59dfff627d9b7b1d5396686e69b709a820f5e7e5" "reference": "0e3d26c283f3cff3507469478a33b47ca7e70649"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/woocommerce/woocommerce-admin/zipball/59dfff627d9b7b1d5396686e69b709a820f5e7e5", "url": "https://api.github.com/repos/woocommerce/woocommerce-admin/zipball/0e3d26c283f3cff3507469478a33b47ca7e70649",
"reference": "59dfff627d9b7b1d5396686e69b709a820f5e7e5", "reference": "0e3d26c283f3cff3507469478a33b47ca7e70649",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -608,9 +608,9 @@
"homepage": "https://github.com/woocommerce/woocommerce-admin", "homepage": "https://github.com/woocommerce/woocommerce-admin",
"support": { "support": {
"issues": "https://github.com/woocommerce/woocommerce-admin/issues", "issues": "https://github.com/woocommerce/woocommerce-admin/issues",
"source": "https://github.com/woocommerce/woocommerce-admin/tree/v3.1.0" "source": "https://github.com/woocommerce/woocommerce-admin/tree/v3.2.0-rc.1"
}, },
"time": "2022-01-25T02:36:40+00:00" "time": "2022-02-09T15:33:34+00:00"
}, },
{ {
"name": "woocommerce/woocommerce-blocks", "name": "woocommerce/woocommerce-blocks",
@ -2926,5 +2926,5 @@
"platform-overrides": { "platform-overrides": {
"php": "7.0.33" "php": "7.0.33"
}, },
"plugin-api-version": "2.1.0" "plugin-api-version": "2.2.0"
} }

View File

@ -15,7 +15,7 @@ defined( 'ABSPATH' ) || exit;
return array( return array(
'AF' => array(), 'AF' => array(),
'AL' => array( // Albania states. 'AL' => array( // Albanian states.
'AL-01' => __( 'Berat', 'woocommerce' ), 'AL-01' => __( 'Berat', 'woocommerce' ),
'AL-09' => __( 'Dibër', 'woocommerce' ), 'AL-09' => __( 'Dibër', 'woocommerce' ),
'AL-02' => __( 'Durrës', 'woocommerce' ), 'AL-02' => __( 'Durrës', 'woocommerce' ),
@ -29,7 +29,7 @@ return array(
'AL-11' => __( 'Tirana', 'woocommerce' ), 'AL-11' => __( 'Tirana', 'woocommerce' ),
'AL-12' => __( 'Vlorë', 'woocommerce' ), 'AL-12' => __( 'Vlorë', 'woocommerce' ),
), ),
'AO' => array( // Angola states. 'AO' => array( // Angolan states.
'BGO' => __( 'Bengo', 'woocommerce' ), 'BGO' => __( 'Bengo', 'woocommerce' ),
'BLU' => __( 'Benguela', 'woocommerce' ), 'BLU' => __( 'Benguela', 'woocommerce' ),
'BIE' => __( 'Bié', 'woocommerce' ), 'BIE' => __( 'Bié', 'woocommerce' ),
@ -87,7 +87,7 @@ return array(
'WA' => __( 'Western Australia', 'woocommerce' ), 'WA' => __( 'Western Australia', 'woocommerce' ),
), ),
'AX' => array(), 'AX' => array(),
'BD' => array( // Bangladeshi states (districts). 'BD' => array( // Bangladeshi districts.
'BD-05' => __( 'Bagerhat', 'woocommerce' ), 'BD-05' => __( 'Bagerhat', 'woocommerce' ),
'BD-01' => __( 'Bandarban', 'woocommerce' ), 'BD-01' => __( 'Bandarban', 'woocommerce' ),
'BD-02' => __( 'Barguna', 'woocommerce' ), 'BD-02' => __( 'Barguna', 'woocommerce' ),
@ -186,7 +186,7 @@ return array(
), ),
'BH' => array(), 'BH' => array(),
'BI' => array(), 'BI' => array(),
'BJ' => array( // Benin states. 'BJ' => array( // Beninese states.
'AL' => __( 'Alibori', 'woocommerce' ), 'AL' => __( 'Alibori', 'woocommerce' ),
'AK' => __( 'Atakora', 'woocommerce' ), 'AK' => __( 'Atakora', 'woocommerce' ),
'AQ' => __( 'Atlantique', 'woocommerce' ), 'AQ' => __( 'Atlantique', 'woocommerce' ),
@ -211,7 +211,7 @@ return array(
'BO-S' => __( 'Santa Cruz', 'woocommerce' ), 'BO-S' => __( 'Santa Cruz', 'woocommerce' ),
'BO-T' => __( 'Tarija', 'woocommerce' ), 'BO-T' => __( 'Tarija', 'woocommerce' ),
), ),
'BR' => array( // Brazillian states. 'BR' => array( // Brazilian states.
'AC' => __( 'Acre', 'woocommerce' ), 'AC' => __( 'Acre', 'woocommerce' ),
'AL' => __( 'Alagoas', 'woocommerce' ), 'AL' => __( 'Alagoas', 'woocommerce' ),
'AP' => __( 'Amapá', 'woocommerce' ), 'AP' => __( 'Amapá', 'woocommerce' ),
@ -255,7 +255,7 @@ return array(
'SK' => __( 'Saskatchewan', 'woocommerce' ), 'SK' => __( 'Saskatchewan', 'woocommerce' ),
'YT' => __( 'Yukon Territory', 'woocommerce' ), 'YT' => __( 'Yukon Territory', 'woocommerce' ),
), ),
'CH' => array( // Cantons of Switzerland. 'CH' => array( // Swiss cantons.
'AG' => __( 'Aargau', 'woocommerce' ), 'AG' => __( 'Aargau', 'woocommerce' ),
'AR' => __( 'Appenzell Ausserrhoden', 'woocommerce' ), 'AR' => __( 'Appenzell Ausserrhoden', 'woocommerce' ),
'AI' => __( 'Appenzell Innerrhoden', 'woocommerce' ), 'AI' => __( 'Appenzell Innerrhoden', 'woocommerce' ),
@ -283,7 +283,7 @@ return array(
'ZG' => __( 'Zug', 'woocommerce' ), 'ZG' => __( 'Zug', 'woocommerce' ),
'ZH' => __( 'Zürich', 'woocommerce' ), 'ZH' => __( 'Zürich', 'woocommerce' ),
), ),
'CL' => array( // Chile states. 'CL' => array( // Chilean states.
'CL-AI' => __( 'Aisén del General Carlos Ibañez del Campo', 'woocommerce' ), 'CL-AI' => __( 'Aisén del General Carlos Ibañez del Campo', 'woocommerce' ),
'CL-AN' => __( 'Antofagasta', 'woocommerce' ), 'CL-AN' => __( 'Antofagasta', 'woocommerce' ),
'CL-AP' => __( 'Arica y Parinacota', 'woocommerce' ), 'CL-AP' => __( 'Arica y Parinacota', 'woocommerce' ),
@ -335,7 +335,7 @@ return array(
'CN31' => __( 'Tibet / 西藏', 'woocommerce' ), 'CN31' => __( 'Tibet / 西藏', 'woocommerce' ),
'CN32' => __( 'Xinjiang / 新疆', 'woocommerce' ), 'CN32' => __( 'Xinjiang / 新疆', 'woocommerce' ),
), ),
'CO' => array( // Colombia States. 'CO' => array( // Colombian states.
'CO-AMA' => __( 'Amazonas', 'woocommerce' ), 'CO-AMA' => __( 'Amazonas', 'woocommerce' ),
'CO-ANT' => __( 'Antioquia', 'woocommerce' ), 'CO-ANT' => __( 'Antioquia', 'woocommerce' ),
'CO-ARA' => __( 'Arauca', 'woocommerce' ), 'CO-ARA' => __( 'Arauca', 'woocommerce' ),
@ -370,7 +370,7 @@ return array(
'CO-VAU' => __( 'Vaupés', 'woocommerce' ), 'CO-VAU' => __( 'Vaupés', 'woocommerce' ),
'CO-VID' => __( 'Vichada', 'woocommerce' ), 'CO-VID' => __( 'Vichada', 'woocommerce' ),
), ),
'CR' => array( // Costa Rica states. 'CR' => array( // Costa Rican states.
'CR-A' => __( 'Alajuela', 'woocommerce' ), 'CR-A' => __( 'Alajuela', 'woocommerce' ),
'CR-C' => __( 'Cartago', 'woocommerce' ), 'CR-C' => __( 'Cartago', 'woocommerce' ),
'CR-G' => __( 'Guanacaste', 'woocommerce' ), 'CR-G' => __( 'Guanacaste', 'woocommerce' ),
@ -380,9 +380,26 @@ return array(
'CR-SJ' => __( 'San José', 'woocommerce' ), 'CR-SJ' => __( 'San José', 'woocommerce' ),
), ),
'CZ' => array(), 'CZ' => array(),
'DE' => array(), 'DE' => array( // German states.
'DE-BW' => __( 'Baden-Württemberg', 'woocommerce' ),
'DE-BY' => __( 'Bavaria', 'woocommerce' ),
'DE-BE' => __( 'Berlin', 'woocommerce' ),
'DE-BB' => __( 'Brandenburg', 'woocommerce' ),
'DE-HB' => __( 'Bremen', 'woocommerce' ),
'DE-HH' => __( 'Hamburg', 'woocommerce' ),
'DE-HE' => __( 'Hesse', 'woocommerce' ),
'DE-MV' => __( 'Mecklenburg-Vorpommern', 'woocommerce' ),
'DE-NI' => __( 'Lower Saxony', 'woocommerce' ),
'DE-NW' => __( 'North Rhine-Westphalia', 'woocommerce' ),
'DE-RP' => __( 'Rhineland-Palatinate', 'woocommerce' ),
'DE-SL' => __( 'Saarland', 'woocommerce' ),
'DE-SN' => __( 'Saxony', 'woocommerce' ),
'DE-ST' => __( 'Saxony-Anhalt', 'woocommerce' ),
'DE-SH' => __( 'Schleswig-Holstein', 'woocommerce' ),
'DE-TH' => __( 'Thuringia', 'woocommerce' ),
),
'DK' => array(), 'DK' => array(),
'DO' => array( // Dominican Republic. 'DO' => array( // Dominican states.
'DO-01' => __( 'Distrito Nacional', 'woocommerce' ), 'DO-01' => __( 'Distrito Nacional', 'woocommerce' ),
'DO-02' => __( 'Azua', 'woocommerce' ), 'DO-02' => __( 'Azua', 'woocommerce' ),
'DO-03' => __( 'Baoruco', 'woocommerce' ), 'DO-03' => __( 'Baoruco', 'woocommerce' ),
@ -426,7 +443,7 @@ return array(
'DO-27' => __( 'Valverde', 'woocommerce' ), 'DO-27' => __( 'Valverde', 'woocommerce' ),
'DO-42' => __( 'Yuma', 'woocommerce' ), 'DO-42' => __( 'Yuma', 'woocommerce' ),
), ),
'DZ' => array( 'DZ' => array( // Algerian states.
'DZ-01' => __( 'Adrar', 'woocommerce' ), 'DZ-01' => __( 'Adrar', 'woocommerce' ),
'DZ-02' => __( 'Chlef', 'woocommerce' ), 'DZ-02' => __( 'Chlef', 'woocommerce' ),
'DZ-03' => __( 'Laghouat', 'woocommerce' ), 'DZ-03' => __( 'Laghouat', 'woocommerce' ),
@ -477,7 +494,7 @@ return array(
'DZ-48' => __( 'Relizane', 'woocommerce' ), 'DZ-48' => __( 'Relizane', 'woocommerce' ),
), ),
'EE' => array(), 'EE' => array(),
'EC' => array( // Ecuador states. 'EC' => array( // Ecuadorian states.
'EC-A' => __( 'Azuay', 'woocommerce' ), 'EC-A' => __( 'Azuay', 'woocommerce' ),
'EC-B' => __( 'Bolívar', 'woocommerce' ), 'EC-B' => __( 'Bolívar', 'woocommerce' ),
'EC-F' => __( 'Cañar', 'woocommerce' ), 'EC-F' => __( 'Cañar', 'woocommerce' ),
@ -503,7 +520,7 @@ return array(
'EC-T' => __( 'Tungurahua', 'woocommerce' ), 'EC-T' => __( 'Tungurahua', 'woocommerce' ),
'EC-Z' => __( 'Zamora-Chinchipe', 'woocommerce' ), 'EC-Z' => __( 'Zamora-Chinchipe', 'woocommerce' ),
), ),
'EG' => array( // Egypt states. 'EG' => array( // Egyptian states.
'EGALX' => __( 'Alexandria', 'woocommerce' ), 'EGALX' => __( 'Alexandria', 'woocommerce' ),
'EGASN' => __( 'Aswan', 'woocommerce' ), 'EGASN' => __( 'Aswan', 'woocommerce' ),
'EGAST' => __( 'Asyut', 'woocommerce' ), 'EGAST' => __( 'Asyut', 'woocommerce' ),
@ -589,7 +606,7 @@ return array(
'FI' => array(), 'FI' => array(),
'FR' => array(), 'FR' => array(),
'GF' => array(), 'GF' => array(),
'GH' => array( // Ghanaian Regions. 'GH' => array( // Ghanaian regions.
'AF' => __( 'Ahafo', 'woocommerce' ), 'AF' => __( 'Ahafo', 'woocommerce' ),
'AH' => __( 'Ashanti', 'woocommerce' ), 'AH' => __( 'Ashanti', 'woocommerce' ),
'BA' => __( 'Brong-Ahafo', 'woocommerce' ), 'BA' => __( 'Brong-Ahafo', 'woocommerce' ),
@ -609,7 +626,7 @@ return array(
'WN' => __( 'Western North', 'woocommerce' ), 'WN' => __( 'Western North', 'woocommerce' ),
), ),
'GP' => array(), 'GP' => array(),
'GR' => array( // Greek Regions. 'GR' => array( // Greek regions.
'I' => __( 'Attica', 'woocommerce' ), 'I' => __( 'Attica', 'woocommerce' ),
'A' => __( 'East Macedonia and Thrace', 'woocommerce' ), 'A' => __( 'East Macedonia and Thrace', 'woocommerce' ),
'B' => __( 'Central Macedonia', 'woocommerce' ), 'B' => __( 'Central Macedonia', 'woocommerce' ),
@ -653,7 +670,7 @@ return array(
'KOWLOON' => __( 'Kowloon', 'woocommerce' ), 'KOWLOON' => __( 'Kowloon', 'woocommerce' ),
'NEW TERRITORIES' => __( 'New Territories', 'woocommerce' ), 'NEW TERRITORIES' => __( 'New Territories', 'woocommerce' ),
), ),
'HN' => array( // Honduras states. 'HN' => array( // Honduran states.
'HN-AT' => __( 'Atlántida', 'woocommerce' ), 'HN-AT' => __( 'Atlántida', 'woocommerce' ),
'HN-IB' => __( 'Bay Islands', 'woocommerce' ), 'HN-IB' => __( 'Bay Islands', 'woocommerce' ),
'HN-CH' => __( 'Choluteca', 'woocommerce' ), 'HN-CH' => __( 'Choluteca', 'woocommerce' ),
@ -673,7 +690,7 @@ return array(
'HN-VA' => __( 'Valle', 'woocommerce' ), 'HN-VA' => __( 'Valle', 'woocommerce' ),
'HN-YO' => __( 'Yoro', 'woocommerce' ), 'HN-YO' => __( 'Yoro', 'woocommerce' ),
), ),
'HU' => array( // Hungary states. 'HU' => array( // Hungarian states.
'BK' => __( 'Bács-Kiskun', 'woocommerce' ), 'BK' => __( 'Bács-Kiskun', 'woocommerce' ),
'BE' => __( 'Békés', 'woocommerce' ), 'BE' => __( 'Békés', 'woocommerce' ),
'BA' => __( 'Baranya', 'woocommerce' ), 'BA' => __( 'Baranya', 'woocommerce' ),
@ -695,7 +712,7 @@ return array(
'VE' => __( 'Veszprém', 'woocommerce' ), 'VE' => __( 'Veszprém', 'woocommerce' ),
'ZA' => __( 'Zala', 'woocommerce' ), 'ZA' => __( 'Zala', 'woocommerce' ),
), ),
'ID' => array( // Indonesia Provinces. 'ID' => array( // Indonesian provinces.
'AC' => __( 'Daerah Istimewa Aceh', 'woocommerce' ), 'AC' => __( 'Daerah Istimewa Aceh', 'woocommerce' ),
'SU' => __( 'Sumatera Utara', 'woocommerce' ), 'SU' => __( 'Sumatera Utara', 'woocommerce' ),
'SB' => __( 'Sumatera Barat', 'woocommerce' ), 'SB' => __( 'Sumatera Barat', 'woocommerce' ),
@ -731,7 +748,7 @@ return array(
'PA' => __( 'Papua', 'woocommerce' ), 'PA' => __( 'Papua', 'woocommerce' ),
'PB' => __( 'Papua Barat', 'woocommerce' ), 'PB' => __( 'Papua Barat', 'woocommerce' ),
), ),
'IE' => array( // Republic of Ireland. 'IE' => array( // Irish states.
'CW' => __( 'Carlow', 'woocommerce' ), 'CW' => __( 'Carlow', 'woocommerce' ),
'CN' => __( 'Cavan', 'woocommerce' ), 'CN' => __( 'Cavan', 'woocommerce' ),
'CE' => __( 'Clare', 'woocommerce' ), 'CE' => __( 'Clare', 'woocommerce' ),
@ -798,7 +815,7 @@ return array(
'LD' => __( 'Lakshadeep', 'woocommerce' ), 'LD' => __( 'Lakshadeep', 'woocommerce' ),
'PY' => __( 'Pondicherry (Puducherry)', 'woocommerce' ), 'PY' => __( 'Pondicherry (Puducherry)', 'woocommerce' ),
), ),
'IR' => array( // Iran States. 'IR' => array( // Irania states.
'KHZ' => __( 'Khuzestan (خوزستان)', 'woocommerce' ), 'KHZ' => __( 'Khuzestan (خوزستان)', 'woocommerce' ),
'THR' => __( 'Tehran (تهران)', 'woocommerce' ), 'THR' => __( 'Tehran (تهران)', 'woocommerce' ),
'ILM' => __( 'Ilaam (ایلام)', 'woocommerce' ), 'ILM' => __( 'Ilaam (ایلام)', 'woocommerce' ),
@ -832,7 +849,7 @@ return array(
'SBN' => __( 'Sistan and Baluchestan (سیستان و بلوچستان)', 'woocommerce' ), 'SBN' => __( 'Sistan and Baluchestan (سیستان و بلوچستان)', 'woocommerce' ),
), ),
'IS' => array(), 'IS' => array(),
'IT' => array( // Italy Provinces. 'IT' => array( // Italian provinces.
'AG' => __( 'Agrigento', 'woocommerce' ), 'AG' => __( 'Agrigento', 'woocommerce' ),
'AL' => __( 'Alessandria', 'woocommerce' ), 'AL' => __( 'Alessandria', 'woocommerce' ),
'AN' => __( 'Ancona', 'woocommerce' ), 'AN' => __( 'Ancona', 'woocommerce' ),
@ -943,7 +960,7 @@ return array(
), ),
'IL' => array(), 'IL' => array(),
'IM' => array(), 'IM' => array(),
'JM' => array( // Jamaica's Parishes. Ref: https://en.wikipedia.org/wiki/ISO_3166-2:JM. 'JM' => array( // Jamaican parishes.
'JM-01' => __( 'Kingston', 'woocommerce' ), 'JM-01' => __( 'Kingston', 'woocommerce' ),
'JM-02' => __( 'Saint Andrew', 'woocommerce' ), 'JM-02' => __( 'Saint Andrew', 'woocommerce' ),
'JM-03' => __( 'Saint Thomas', 'woocommerce' ), 'JM-03' => __( 'Saint Thomas', 'woocommerce' ),
@ -961,7 +978,7 @@ return array(
), ),
/** /**
* Japan States. * Japanese states.
* *
* English notation of prefectures conform to the notation of Japan Post. * English notation of prefectures conform to the notation of Japan Post.
* The suffix corresponds with the Japanese translation file. * The suffix corresponds with the Japanese translation file.
@ -1015,7 +1032,7 @@ return array(
'JP46' => __( 'Kagoshima', 'woocommerce' ), 'JP46' => __( 'Kagoshima', 'woocommerce' ),
'JP47' => __( 'Okinawa', 'woocommerce' ), 'JP47' => __( 'Okinawa', 'woocommerce' ),
), ),
'KE' => array( // Kenya counties. 'KE' => array( // Kenyan counties.
'KE01' => __( 'Baringo', 'woocommerce' ), 'KE01' => __( 'Baringo', 'woocommerce' ),
'KE02' => __( 'Bomet', 'woocommerce' ), 'KE02' => __( 'Bomet', 'woocommerce' ),
'KE03' => __( 'Bungoma', 'woocommerce' ), 'KE03' => __( 'Bungoma', 'woocommerce' ),
@ -1066,7 +1083,7 @@ return array(
), ),
'KR' => array(), 'KR' => array(),
'KW' => array(), 'KW' => array(),
'LA' => array( 'LA' => array( // Laotian provinces.
'AT' => __( 'Attapeu', 'woocommerce' ), 'AT' => __( 'Attapeu', 'woocommerce' ),
'BK' => __( 'Bokeo', 'woocommerce' ), 'BK' => __( 'Bokeo', 'woocommerce' ),
'BL' => __( 'Bolikhamsai', 'woocommerce' ), 'BL' => __( 'Bolikhamsai', 'woocommerce' ),
@ -1087,7 +1104,7 @@ return array(
'XS' => __( 'Xaisomboun', 'woocommerce' ), 'XS' => __( 'Xaisomboun', 'woocommerce' ),
), ),
'LB' => array(), 'LB' => array(),
'LR' => array( // Liberia provinces. 'LR' => array( // Liberian provinces.
'BM' => __( 'Bomi', 'woocommerce' ), 'BM' => __( 'Bomi', 'woocommerce' ),
'BN' => __( 'Bong', 'woocommerce' ), 'BN' => __( 'Bong', 'woocommerce' ),
'GA' => __( 'Gbarpolu', 'woocommerce' ), 'GA' => __( 'Gbarpolu', 'woocommerce' ),
@ -1105,7 +1122,7 @@ return array(
'SN' => __( 'Sinoe', 'woocommerce' ), 'SN' => __( 'Sinoe', 'woocommerce' ),
), ),
'LU' => array(), 'LU' => array(),
'MD' => array( // Moldova states. 'MD' => array( // Moldovan states.
'C' => __( 'Chișinău', 'woocommerce' ), 'C' => __( 'Chișinău', 'woocommerce' ),
'BL' => __( 'Bălți', 'woocommerce' ), 'BL' => __( 'Bălți', 'woocommerce' ),
'AN' => __( 'Anenii Noi', 'woocommerce' ), 'AN' => __( 'Anenii Noi', 'woocommerce' ),
@ -1144,7 +1161,7 @@ return array(
), ),
'MQ' => array(), 'MQ' => array(),
'MT' => array(), 'MT' => array(),
'MX' => array( // Mexico States. 'MX' => array( // Mexican states.
'DF' => __( 'Ciudad de México', 'woocommerce' ), 'DF' => __( 'Ciudad de México', 'woocommerce' ),
'JA' => __( 'Jalisco', 'woocommerce' ), 'JA' => __( 'Jalisco', 'woocommerce' ),
'NL' => __( 'Nuevo León', 'woocommerce' ), 'NL' => __( 'Nuevo León', 'woocommerce' ),
@ -1196,7 +1213,7 @@ return array(
'PJY' => __( 'Putrajaya', 'woocommerce' ), 'PJY' => __( 'Putrajaya', 'woocommerce' ),
'KUL' => __( 'Kuala Lumpur', 'woocommerce' ), 'KUL' => __( 'Kuala Lumpur', 'woocommerce' ),
), ),
'MZ' => array( // Mozambique provinces. 'MZ' => array( // Mozambican provinces.
'MZP' => __( 'Cabo Delgado', 'woocommerce' ), 'MZP' => __( 'Cabo Delgado', 'woocommerce' ),
'MZG' => __( 'Gaza', 'woocommerce' ), 'MZG' => __( 'Gaza', 'woocommerce' ),
'MZI' => __( 'Inhambane', 'woocommerce' ), 'MZI' => __( 'Inhambane', 'woocommerce' ),
@ -1209,7 +1226,7 @@ return array(
'MZT' => __( 'Tete', 'woocommerce' ), 'MZT' => __( 'Tete', 'woocommerce' ),
'MZQ' => __( 'Zambézia', 'woocommerce' ), 'MZQ' => __( 'Zambézia', 'woocommerce' ),
), ),
'NA' => array( // Namibia regions. 'NA' => array( // Namibian regions.
'ER' => __( 'Erongo', 'woocommerce' ), 'ER' => __( 'Erongo', 'woocommerce' ),
'HA' => __( 'Hardap', 'woocommerce' ), 'HA' => __( 'Hardap', 'woocommerce' ),
'KA' => __( 'Karas', 'woocommerce' ), 'KA' => __( 'Karas', 'woocommerce' ),
@ -1266,7 +1283,7 @@ return array(
), ),
'NL' => array(), 'NL' => array(),
'NO' => array(), 'NO' => array(),
'NP' => array( // Nepal states (Zones). 'NP' => array( // Nepalese zones.
'BAG' => __( 'Bagmati', 'woocommerce' ), 'BAG' => __( 'Bagmati', 'woocommerce' ),
'BHE' => __( 'Bheri', 'woocommerce' ), 'BHE' => __( 'Bheri', 'woocommerce' ),
'DHA' => __( 'Dhaulagiri', 'woocommerce' ), 'DHA' => __( 'Dhaulagiri', 'woocommerce' ),
@ -1282,7 +1299,7 @@ return array(
'SAG' => __( 'Sagarmatha', 'woocommerce' ), 'SAG' => __( 'Sagarmatha', 'woocommerce' ),
'SET' => __( 'Seti', 'woocommerce' ), 'SET' => __( 'Seti', 'woocommerce' ),
), ),
'NI' => array( // Nicaragua states 'NI' => array( // Nicaraguan states.
'NI-AN' => __( 'Atlántico Norte', 'woocommerce' ), 'NI-AN' => __( 'Atlántico Norte', 'woocommerce' ),
'NI-AS' => __( 'Atlántico Sur', 'woocommerce' ), 'NI-AS' => __( 'Atlántico Sur', 'woocommerce' ),
'NI-BO' => __( 'Boaco', 'woocommerce' ), 'NI-BO' => __( 'Boaco', 'woocommerce' ),
@ -1301,7 +1318,7 @@ return array(
'NI-RI' => __( 'Rivas', 'woocommerce' ), 'NI-RI' => __( 'Rivas', 'woocommerce' ),
'NI-SJ' => __( 'Río San Juan', 'woocommerce' ), 'NI-SJ' => __( 'Río San Juan', 'woocommerce' ),
), ),
'NZ' => array( // New Zealand States. 'NZ' => array( // New Zealand states.
'NL' => __( 'Northland', 'woocommerce' ), 'NL' => __( 'Northland', 'woocommerce' ),
'AK' => __( 'Auckland', 'woocommerce' ), 'AK' => __( 'Auckland', 'woocommerce' ),
'WA' => __( 'Waikato', 'woocommerce' ), 'WA' => __( 'Waikato', 'woocommerce' ),
@ -1319,7 +1336,7 @@ return array(
'OT' => __( 'Otago', 'woocommerce' ), 'OT' => __( 'Otago', 'woocommerce' ),
'SL' => __( 'Southland', 'woocommerce' ), 'SL' => __( 'Southland', 'woocommerce' ),
), ),
'PA' => array( // Panama states. 'PA' => array( // Panamanian states.
'PA-1' => __( 'Bocas del Toro', 'woocommerce' ), 'PA-1' => __( 'Bocas del Toro', 'woocommerce' ),
'PA-2' => __( 'Coclé', 'woocommerce' ), 'PA-2' => __( 'Coclé', 'woocommerce' ),
'PA-3' => __( 'Colón', 'woocommerce' ), 'PA-3' => __( 'Colón', 'woocommerce' ),
@ -1334,7 +1351,7 @@ return array(
'PA-KY' => __( 'Guna Yala', 'woocommerce' ), 'PA-KY' => __( 'Guna Yala', 'woocommerce' ),
'PA-NB' => __( 'Ngöbe-Buglé', 'woocommerce' ), 'PA-NB' => __( 'Ngöbe-Buglé', 'woocommerce' ),
), ),
'PE' => array( // Peru states. 'PE' => array( // Peruvian states.
'CAL' => __( 'El Callao', 'woocommerce' ), 'CAL' => __( 'El Callao', 'woocommerce' ),
'LMA' => __( 'Municipalidad Metropolitana de Lima', 'woocommerce' ), 'LMA' => __( 'Municipalidad Metropolitana de Lima', 'woocommerce' ),
'AMA' => __( 'Amazonas', 'woocommerce' ), 'AMA' => __( 'Amazonas', 'woocommerce' ),
@ -1362,11 +1379,7 @@ return array(
'TUM' => __( 'Tumbes', 'woocommerce' ), 'TUM' => __( 'Tumbes', 'woocommerce' ),
'UCA' => __( 'Ucayali', 'woocommerce' ), 'UCA' => __( 'Ucayali', 'woocommerce' ),
), ),
'PH' => array( // Philippine provinces.
/**
* Philippine Provinces.
*/
'PH' => array(
'ABR' => __( 'Abra', 'woocommerce' ), 'ABR' => __( 'Abra', 'woocommerce' ),
'AGN' => __( 'Agusan del Norte', 'woocommerce' ), 'AGN' => __( 'Agusan del Norte', 'woocommerce' ),
'AGS' => __( 'Agusan del Sur', 'woocommerce' ), 'AGS' => __( 'Agusan del Sur', 'woocommerce' ),
@ -1450,7 +1463,7 @@ return array(
'ZSI' => __( 'Zamboanga Sibugay', 'woocommerce' ), 'ZSI' => __( 'Zamboanga Sibugay', 'woocommerce' ),
'00' => __( 'Metro Manila', 'woocommerce' ), '00' => __( 'Metro Manila', 'woocommerce' ),
), ),
'PK' => array( // Pakistan's states. 'PK' => array( // Pakistani states.
'JK' => __( 'Azad Kashmir', 'woocommerce' ), 'JK' => __( 'Azad Kashmir', 'woocommerce' ),
'BA' => __( 'Balochistan', 'woocommerce' ), 'BA' => __( 'Balochistan', 'woocommerce' ),
'TA' => __( 'FATA', 'woocommerce' ), 'TA' => __( 'FATA', 'woocommerce' ),
@ -1463,7 +1476,7 @@ return array(
'PL' => array(), 'PL' => array(),
'PR' => array(), 'PR' => array(),
'PT' => array(), 'PT' => array(),
'PY' => array( // Paraguay states. 'PY' => array( // Paraguayan states.
'PY-ASU' => __( 'Asunción', 'woocommerce' ), 'PY-ASU' => __( 'Asunción', 'woocommerce' ),
'PY-1' => __( 'Concepción', 'woocommerce' ), 'PY-1' => __( 'Concepción', 'woocommerce' ),
'PY-2' => __( 'San Pedro', 'woocommerce' ), 'PY-2' => __( 'San Pedro', 'woocommerce' ),
@ -1484,7 +1497,7 @@ return array(
'PY-17' => __( 'Boquerón', 'woocommerce' ), 'PY-17' => __( 'Boquerón', 'woocommerce' ),
), ),
'RE' => array(), 'RE' => array(),
'RO' => array( // Romania states. 'RO' => array( // Romanian states.
'AB' => __( 'Alba', 'woocommerce' ), 'AB' => __( 'Alba', 'woocommerce' ),
'AR' => __( 'Arad', 'woocommerce' ), 'AR' => __( 'Arad', 'woocommerce' ),
'AG' => __( 'Argeș', 'woocommerce' ), 'AG' => __( 'Argeș', 'woocommerce' ),
@ -1531,7 +1544,7 @@ return array(
'SG' => array(), 'SG' => array(),
'SK' => array(), 'SK' => array(),
'SI' => array(), 'SI' => array(),
'SV' => array( // El Salvador states. 'SV' => array( // Salvadoran states.
'SV-AH' => __( 'Ahuachapán', 'woocommerce' ), 'SV-AH' => __( 'Ahuachapán', 'woocommerce' ),
'SV-CA' => __( 'Cabañas', 'woocommerce' ), 'SV-CA' => __( 'Cabañas', 'woocommerce' ),
'SV-CH' => __( 'Chalatenango', 'woocommerce' ), 'SV-CH' => __( 'Chalatenango', 'woocommerce' ),
@ -1547,7 +1560,7 @@ return array(
'SV-UN' => __( 'La Unión', 'woocommerce' ), 'SV-UN' => __( 'La Unión', 'woocommerce' ),
'SV-US' => __( 'Usulután', 'woocommerce' ), 'SV-US' => __( 'Usulután', 'woocommerce' ),
), ),
'TH' => array( // Thailand states. 'TH' => array( // Thai states.
'TH-37' => __( 'Amnat Charoen', 'woocommerce' ), 'TH-37' => __( 'Amnat Charoen', 'woocommerce' ),
'TH-15' => __( 'Ang Thong', 'woocommerce' ), 'TH-15' => __( 'Ang Thong', 'woocommerce' ),
'TH-14' => __( 'Ayutthaya', 'woocommerce' ), 'TH-14' => __( 'Ayutthaya', 'woocommerce' ),
@ -1626,7 +1639,7 @@ return array(
'TH-95' => __( 'Yala', 'woocommerce' ), 'TH-95' => __( 'Yala', 'woocommerce' ),
'TH-35' => __( 'Yasothon', 'woocommerce' ), 'TH-35' => __( 'Yasothon', 'woocommerce' ),
), ),
'TR' => array( // Turkey States. 'TR' => array( // Turkish states.
'TR01' => __( 'Adana', 'woocommerce' ), 'TR01' => __( 'Adana', 'woocommerce' ),
'TR02' => __( 'Adıyaman', 'woocommerce' ), 'TR02' => __( 'Adıyaman', 'woocommerce' ),
'TR03' => __( 'Afyon', 'woocommerce' ), 'TR03' => __( 'Afyon', 'woocommerce' ),
@ -1709,7 +1722,7 @@ return array(
'TR80' => __( 'Osmaniye', 'woocommerce' ), 'TR80' => __( 'Osmaniye', 'woocommerce' ),
'TR81' => __( 'Düzce', 'woocommerce' ), 'TR81' => __( 'Düzce', 'woocommerce' ),
), ),
'TZ' => array( // Tanzania States. 'TZ' => array( // Tanzanian states.
'TZ01' => __( 'Arusha', 'woocommerce' ), 'TZ01' => __( 'Arusha', 'woocommerce' ),
'TZ02' => __( 'Dar es Salaam', 'woocommerce' ), 'TZ02' => __( 'Dar es Salaam', 'woocommerce' ),
'TZ03' => __( 'Dodoma', 'woocommerce' ), 'TZ03' => __( 'Dodoma', 'woocommerce' ),
@ -1742,7 +1755,7 @@ return array(
'TZ30' => __( 'Simiyu', 'woocommerce' ), 'TZ30' => __( 'Simiyu', 'woocommerce' ),
), ),
'LK' => array(), 'LK' => array(),
'RS' => array( // Serbia districts. Ref: https://github.com/unicode-org/cldr/blob/release-37/common/subdivisions/en.xml#L4251-L4283. 'RS' => array( // Serbian districts.
'RS00' => _x( 'Belgrade', 'district', 'woocommerce' ), 'RS00' => _x( 'Belgrade', 'district', 'woocommerce' ),
'RS14' => _x( 'Bor', 'district', 'woocommerce' ), 'RS14' => _x( 'Bor', 'district', 'woocommerce' ),
'RS11' => _x( 'Braničevo', 'district', 'woocommerce' ), 'RS11' => _x( 'Braničevo', 'district', 'woocommerce' ),
@ -1777,7 +1790,7 @@ return array(
'RSVO' => _x( 'Vojvodina', 'district', 'woocommerce' ), 'RSVO' => _x( 'Vojvodina', 'district', 'woocommerce' ),
), ),
'SE' => array(), 'SE' => array(),
'UA' => array( // Ukraine. Ref: https://en.wikipedia.org/wiki/Oblasts_of_Ukraine. 'UA' => array( // Ukrainian oblasts.
'VN' => __( 'Vinnytsia Oblast', 'woocommerce' ), 'VN' => __( 'Vinnytsia Oblast', 'woocommerce' ),
'VL' => __( 'Volyn Oblast', 'woocommerce' ), 'VL' => __( 'Volyn Oblast', 'woocommerce' ),
'DP' => __( 'Dnipropetrovsk Oblast', 'woocommerce' ), 'DP' => __( 'Dnipropetrovsk Oblast', 'woocommerce' ),
@ -1803,7 +1816,7 @@ return array(
'CH' => __( 'Chernihiv Oblast', 'woocommerce' ), 'CH' => __( 'Chernihiv Oblast', 'woocommerce' ),
'CV' => __( 'Chernivtsi Oblast', 'woocommerce' ), 'CV' => __( 'Chernivtsi Oblast', 'woocommerce' ),
), ),
'UG' => array( // Uganda districts. Ref: https://en.wikipedia.org/wiki/ISO_3166-2:UG. 'UG' => array( // Ugandan districts.
'UG314' => __( 'Abim', 'woocommerce' ), 'UG314' => __( 'Abim', 'woocommerce' ),
'UG301' => __( 'Adjumani', 'woocommerce' ), 'UG301' => __( 'Adjumani', 'woocommerce' ),
'UG322' => __( 'Agago', 'woocommerce' ), 'UG322' => __( 'Agago', 'woocommerce' ),
@ -1944,7 +1957,7 @@ return array(
'95' => __( 'Palmyra Atoll', 'woocommerce' ), '95' => __( 'Palmyra Atoll', 'woocommerce' ),
'79' => __( 'Wake Island', 'woocommerce' ), '79' => __( 'Wake Island', 'woocommerce' ),
), ),
'US' => array( // United States. 'US' => array( // U.S. states.
'AL' => __( 'Alabama', 'woocommerce' ), 'AL' => __( 'Alabama', 'woocommerce' ),
'AK' => __( 'Alaska', 'woocommerce' ), 'AK' => __( 'Alaska', 'woocommerce' ),
'AZ' => __( 'Arizona', 'woocommerce' ), 'AZ' => __( 'Arizona', 'woocommerce' ),
@ -2000,7 +2013,7 @@ return array(
'AE' => __( 'Armed Forces (AE)', 'woocommerce' ), 'AE' => __( 'Armed Forces (AE)', 'woocommerce' ),
'AP' => __( 'Armed Forces (AP)', 'woocommerce' ), 'AP' => __( 'Armed Forces (AP)', 'woocommerce' ),
), ),
'UY' => array( // Uruguay States. 'UY' => array( // Uruguayan states.
'UY-AR' => __( 'Artigas', 'woocommerce' ), 'UY-AR' => __( 'Artigas', 'woocommerce' ),
'UY-CA' => __( 'Canelones', 'woocommerce' ), 'UY-CA' => __( 'Canelones', 'woocommerce' ),
'UY-CL' => __( 'Cerro Largo', 'woocommerce' ), 'UY-CL' => __( 'Cerro Largo', 'woocommerce' ),
@ -2021,7 +2034,7 @@ return array(
'UY-TA' => __( 'Tacuarembó', 'woocommerce' ), 'UY-TA' => __( 'Tacuarembó', 'woocommerce' ),
'UY-TT' => __( 'Treinta y Tres', 'woocommerce' ), 'UY-TT' => __( 'Treinta y Tres', 'woocommerce' ),
), ),
'VE' => array( // Venezuela States. 'VE' => array( // Venezuelan states.
'VE-A' => __( 'Capital', 'woocommerce' ), 'VE-A' => __( 'Capital', 'woocommerce' ),
'VE-B' => __( 'Anzoátegui', 'woocommerce' ), 'VE-B' => __( 'Anzoátegui', 'woocommerce' ),
'VE-C' => __( 'Apure', 'woocommerce' ), 'VE-C' => __( 'Apure', 'woocommerce' ),
@ -2061,7 +2074,7 @@ return array(
'NW' => __( 'North West', 'woocommerce' ), 'NW' => __( 'North West', 'woocommerce' ),
'WC' => __( 'Western Cape', 'woocommerce' ), 'WC' => __( 'Western Cape', 'woocommerce' ),
), ),
'ZM' => array( // Zambia's Provinces. Ref: https://en.wikipedia.org/wiki/ISO_3166-2:ZM. 'ZM' => array( // Zambian provinces.
'ZM-01' => __( 'Western', 'woocommerce' ), 'ZM-01' => __( 'Western', 'woocommerce' ),
'ZM-02' => __( 'Central', 'woocommerce' ), 'ZM-02' => __( 'Central', 'woocommerce' ),
'ZM-03' => __( 'Eastern', 'woocommerce' ), 'ZM-03' => __( 'Eastern', 'woocommerce' ),

View File

@ -151,6 +151,9 @@ class WC_Tracker {
// Payment gateway info. // Payment gateway info.
$data['gateways'] = self::get_active_payment_gateways(); $data['gateways'] = self::get_active_payment_gateways();
// WcPay settings info.
$data['wcpay_settings'] = self::get_wcpay_settings();
// Shipping method info. // Shipping method info.
$data['shipping_methods'] = self::get_active_shipping_methods(); $data['shipping_methods'] = self::get_active_shipping_methods();
@ -303,6 +306,15 @@ class WC_Tracker {
); );
} }
/**
* Get the settings of WooCommerce Payments plugin
*
* @return array
*/
private static function get_wcpay_settings() {
return get_option( 'woocommerce_woocommerce_payments_settings' );
}
/** /**
* Check to see if the helper is connected to woocommerce.com * Check to see if the helper is connected to woocommerce.com
* *
@ -589,6 +601,7 @@ class WC_Tracker {
return $active_gateways; return $active_gateways;
} }
/** /**
* Get a list of all active shipping methods. * Get a list of all active shipping methods.
* *

View File

@ -1085,10 +1085,10 @@ function wc_get_price_excluding_tax( $product, $args = array() ) {
if ( $product->is_taxable() && wc_prices_include_tax() ) { if ( $product->is_taxable() && wc_prices_include_tax() ) {
$order = ArrayUtil::get_value_or_default( $args, 'order' ); $order = ArrayUtil::get_value_or_default( $args, 'order' );
$customer_id = $order ? $order->get_customer_id() : 0; $customer_id = $order ? $order->get_customer_id() : 0;
if ( apply_filters( 'woocommerce_adjust_non_base_location_prices', true ) || ! $customer_id ) { if ( apply_filters( 'woocommerce_adjust_non_base_location_prices', true ) ) {
$tax_rates = WC_Tax::get_base_tax_rates( $product->get_tax_class( 'unfiltered' ) ); $tax_rates = WC_Tax::get_base_tax_rates( $product->get_tax_class( 'unfiltered' ) );
} else { } else {
$customer = wc_get_container()->get( LegacyProxy::class )->get_instance_of( WC_Customer::class, $customer_id ); $customer = $customer_id ? wc_get_container()->get( LegacyProxy::class )->get_instance_of( WC_Customer::class, $customer_id ) : null;
$tax_rates = WC_Tax::get_rates( $product->get_tax_class(), $customer ); $tax_rates = WC_Tax::get_rates( $product->get_tax_class(), $customer );
} }
$remove_taxes = WC_Tax::calc_tax( $line_price, $tax_rates, true ); $remove_taxes = WC_Tax::calc_tax( $line_price, $tax_rates, true );

View File

@ -2345,13 +2345,15 @@ function wc_update_600_db_version() {
* @return false Always false, since the LookupDataStore class handles all the data filling process. * @return false Always false, since the LookupDataStore class handles all the data filling process.
*/ */
function wc_update_630_create_product_attributes_lookup_table() { function wc_update_630_create_product_attributes_lookup_table() {
$data_store = wc_get_container()->get( LookupDataStore::class ); $data_store = wc_get_container()->get( LookupDataStore::class );
$data_regenerator = wc_get_container()->get( DataRegenerator::class );
if ( $data_store->check_lookup_table_exists() ) { if ( $data_store->check_lookup_table_exists() ) {
return false; $data_regenerator->maybe_create_table_indices();
} else {
$data_regenerator->initiate_regeneration();
} }
$data_regenerator = wc_get_container()->get( DataRegenerator::class );
$data_regenerator->initiate_regeneration();
return false; return false;
} }

View File

@ -141,6 +141,8 @@ CREATE TABLE ' . $this->lookup_table_name . '(
); );
// phpcs:enable WordPress.DB.PreparedSQL.NotPrepared // phpcs:enable WordPress.DB.PreparedSQL.NotPrepared
$this->maybe_create_table_indices();
$last_existing_product_id = $last_existing_product_id =
WC()->call_function( WC()->call_function(
'wc_get_products', 'wc_get_products',
@ -165,6 +167,49 @@ CREATE TABLE ' . $this->lookup_table_name . '(
return true; return true;
} }
/**
* Create the indices for the lookup table unless they exist already.
*/
public function maybe_create_table_indices() {
global $wpdb;
// phpcs:disable WordPress.DB.PreparedSQL.NotPrepared
$wpdb->query( 'DROP PROCEDURE IF EXISTS __create_wc_product_attributes_lookup_indices;' );
$wpdb->query(
"
CREATE PROCEDURE __create_wc_product_attributes_lookup_indices()
BEGIN
IF (SELECT COUNT(1)
FROM INFORMATION_SCHEMA.STATISTICS
WHERE table_schema='" . $wpdb->dbname . "'
AND table_name='" . $this->lookup_table_name . "'
AND index_name='product_or_parent_id_term_id')=0
THEN
ALTER TABLE " . $this->lookup_table_name . "
ADD INDEX product_or_parent_id_term_id (product_or_parent_id, term_id);
END IF;
IF (SELECT COUNT(1)
FROM INFORMATION_SCHEMA.STATISTICS
WHERE table_schema='" . $wpdb->dbname . "'
AND table_name='" . $this->lookup_table_name . "'
AND index_name='is_variation_attribute_term_id')=0
THEN
ALTER TABLE " . $this->lookup_table_name . '
ADD INDEX is_variation_attribute_term_id (is_variation_attribute, term_id);
END IF;
END;
'
);
$wpdb->query( 'CALL __create_wc_product_attributes_lookup_indices();' );
$wpdb->query( 'DROP PROCEDURE IF EXISTS __create_wc_product_attributes_lookup_indices;' );
// phpcs:enable WordPress.DB.PreparedSQL.NotPrepared
}
/** /**
* Action scheduler callback, performs one regeneration step and then * Action scheduler callback, performs one regeneration step and then
* schedules the next step if necessary. * schedules the next step if necessary.
@ -247,7 +292,6 @@ CREATE TABLE ' . $this->lookup_table_name . '(
* Cleanup/final option setup after the regeneration has been completed. * Cleanup/final option setup after the regeneration has been completed.
* *
* @param bool $enable_usage Whether the table usage should be enabled or not. * @param bool $enable_usage Whether the table usage should be enabled or not.
*
*/ */
private function finalize_regeneration( bool $enable_usage ) { private function finalize_regeneration( bool $enable_usage ) {
delete_option( 'woocommerce_attribute_lookup_last_product_id_to_process' ); delete_option( 'woocommerce_attribute_lookup_last_product_id_to_process' );

View File

@ -105,6 +105,10 @@ class WC_Product_Functions_Tests extends \WC_Unit_Test_Case {
$this->assertEquals( $order->get_customer_id(), $customer_id_passed_to_wc_customer_constructor ); $this->assertEquals( $order->get_customer_id(), $customer_id_passed_to_wc_customer_constructor );
$this->assertFalse( $get_base_rates_invoked ); $this->assertFalse( $get_base_rates_invoked );
$this->assertSame( $customer, $customer_passed_to_get_rates ); $this->assertSame( $customer, $customer_passed_to_get_rates );
} elseif ( ! $customer_id && $set_filter ) {
$this->assertFalse( $customer_id_passed_to_wc_customer_constructor );
$this->assertNull( $customer_passed_to_get_rates );
$this->assertFalse( $get_base_rates_invoked );
} else { } else {
$this->assertFalse( $customer_id_passed_to_wc_customer_constructor ); $this->assertFalse( $customer_id_passed_to_wc_customer_constructor );
$this->assertFalse( $customer_passed_to_get_rates ); $this->assertFalse( $customer_passed_to_get_rates );
@ -114,8 +118,8 @@ class WC_Product_Functions_Tests extends \WC_Unit_Test_Case {
wc_get_price_excluding_tax( $product ); wc_get_price_excluding_tax( $product );
$this->assertFalse( $customer_id_passed_to_wc_customer_constructor ); $this->assertFalse( $customer_id_passed_to_wc_customer_constructor );
$this->assertFalse( $customer_passed_to_get_rates ); $this->assertEquals( $set_filter ? null : false, $customer_passed_to_get_rates );
$this->assertTrue( $get_base_rates_invoked ); $this->assertEquals( ! $set_filter, $get_base_rates_invoked );
} }
// phpcs:enable Squiz.Commenting // phpcs:enable Squiz.Commenting

View File

@ -163,6 +163,7 @@ importers:
jest-puppeteer: ^4.4.0 jest-puppeteer: ^4.4.0
ndb: ^1.1.5 ndb: ^1.1.5
node-stream-zip: ^1.13.6 node-stream-zip: ^1.13.6
puppeteer: 2.1.1
readline-sync: ^1.4.10 readline-sync: ^1.4.10
request: ^2.88.2 request: ^2.88.2
semver: ^7.3.2 semver: ^7.3.2
@ -172,7 +173,7 @@ importers:
'@jest/test-sequencer': 25.5.4 '@jest/test-sequencer': 25.5.4
'@slack/web-api': 6.5.1 '@slack/web-api': 6.5.1
'@woocommerce/api': link:../api '@woocommerce/api': link:../api
'@wordpress/e2e-test-utils': 4.16.1_jest@25.5.4 '@wordpress/e2e-test-utils': 4.16.1_jest@25.5.4+puppeteer@2.1.1
'@wordpress/jest-preset-default': 7.1.3_@babel+core@7.12.9+jest@25.5.4 '@wordpress/jest-preset-default': 7.1.3_@babel+core@7.12.9+jest@25.5.4
app-root-path: 3.0.0 app-root-path: 3.0.0
commander: 4.1.1 commander: 4.1.1
@ -180,8 +181,9 @@ importers:
jest: 25.5.4 jest: 25.5.4
jest-circus: 25.1.0 jest-circus: 25.1.0
jest-each: 25.5.0 jest-each: 25.5.0
jest-puppeteer: 4.4.0 jest-puppeteer: 4.4.0_puppeteer@2.1.1
node-stream-zip: 1.15.0 node-stream-zip: 1.15.0
puppeteer: 2.1.1
readline-sync: 1.4.10 readline-sync: 1.4.10
request: 2.88.2 request: 2.88.2
sprintf-js: 1.1.2 sprintf-js: 1.1.2
@ -5346,7 +5348,7 @@ packages:
- react-native - react-native
dev: false dev: false
/@wordpress/e2e-test-utils/4.16.1_jest@25.5.4: /@wordpress/e2e-test-utils/4.16.1_jest@25.5.4+puppeteer@2.1.1:
resolution: {integrity: sha512-Dpsq5m0VSvjIhro2MjACSzkOkOf1jGEryzgEMW1ikbT6YI+motspHfGtisKXgYhZJOnjV4PwuEg+9lPVnd971g==} resolution: {integrity: sha512-Dpsq5m0VSvjIhro2MjACSzkOkOf1jGEryzgEMW1ikbT6YI+motspHfGtisKXgYhZJOnjV4PwuEg+9lPVnd971g==}
engines: {node: '>=8'} engines: {node: '>=8'}
peerDependencies: peerDependencies:
@ -5359,6 +5361,7 @@ packages:
jest: 25.5.4 jest: 25.5.4
lodash: 4.17.21 lodash: 4.17.21
node-fetch: 2.6.5 node-fetch: 2.6.5
puppeteer: 2.1.1
transitivePeerDependencies: transitivePeerDependencies:
- react-native - react-native
dev: false dev: false
@ -13271,13 +13274,14 @@ packages:
jest-resolve: 27.3.1 jest-resolve: 27.3.1
dev: true dev: true
/jest-puppeteer/4.4.0: /jest-puppeteer/4.4.0_puppeteer@2.1.1:
resolution: {integrity: sha512-ZaiCTlPZ07B9HW0erAWNX6cyzBqbXMM7d2ugai4epBDKpKvRDpItlRQC6XjERoJELKZsPziFGS0OhhUvTvQAXA==} resolution: {integrity: sha512-ZaiCTlPZ07B9HW0erAWNX6cyzBqbXMM7d2ugai4epBDKpKvRDpItlRQC6XjERoJELKZsPziFGS0OhhUvTvQAXA==}
peerDependencies: peerDependencies:
puppeteer: '>= 1.5.0 < 3' puppeteer: '>= 1.5.0 < 3'
dependencies: dependencies:
expect-puppeteer: 4.4.0 expect-puppeteer: 4.4.0
jest-environment-puppeteer: 4.4.0 jest-environment-puppeteer: 4.4.0
puppeteer: 2.1.1
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
dev: false dev: false