Merge branch 'trunk' into e2e/api/poc-delete-products

This commit is contained in:
Ron Rennick 2021-03-15 14:14:31 -03:00
commit 6031cd922e
263 changed files with 8763 additions and 1874 deletions

View File

@ -1,5 +1,6 @@
/** @format */
const { useE2EEsLintConfig } = require( '@woocommerce/e2e-environment' );
const { useE2EEsLintConfig } = require( './tests/e2e/env/config/use-config' );
module.exports = useE2EEsLintConfig( {
root: true,

View File

@ -26,7 +26,7 @@ If you have questions about the process to contribute code or want to discuss de
- [Minification of SCSS and JS](https://github.com/woocommerce/woocommerce/wiki/Minification-of-SCSS-and-JS)
- [Naming conventions](https://github.com/woocommerce/woocommerce/wiki/Naming-conventions)
- [String localisation guidelines](https://github.com/woocommerce/woocommerce/wiki/String-localisation-guidelines)
- [Running unit tests](https://github.com/woocommerce/woocommerce/blob/master/tests/README.md)
- [Running unit tests](https://github.com/woocommerce/woocommerce/blob/trunk/tests/README.md)
- [Running e2e tests](https://github.com/woocommerce/woocommerce/wiki/End-to-end-Testing)
## Coding Guidelines and Development 🛠
@ -37,12 +37,13 @@ If you have questions about the process to contribute code or want to discuss de
- Ensure you use LF line endings in your code editor. Use [EditorConfig](http://editorconfig.org/) if your editor supports it so that indentation, line endings and other settings are auto configured.
- When committing, reference your issue number (#1234) and include a note about the fix.
- Ensure that your code supports the minimum supported versions of PHP and WordPress; this is shown at the top of the `readme.txt` file.
- Push the changes to your fork and submit a pull request on the master branch of the WooCommerce repository.
- Push the changes to your fork and submit a pull request on the trunk branch of the WooCommerce repository.
- Make sure to write good and detailed commit messages (see [this post](https://chris.beams.io/posts/git-commit/) for more on this) and follow all the applicable sections of the pull request template.
- Please avoid modifying the changelog directly or updating the .pot files. These will be updated by the WooCommerce team.
If you are contributing code to the REST API or editor blocks, these are developed in external packages.
- [WooCommerce REST API package](https://github.com/woocommerce/woocommerce-rest-api)
If you are contributing code to the (Javascript-driven) WooCommerce Admin project or to Gutenberg blocks, note that these are developed in external packages.
- [WooCommerce Admin](https://github.com/woocommerce/woocommerce-admin)
- [Blocks](https://github.com/woocommerce/woocommerce-gutenberg-products-block)
## Feature Requests 🚀

View File

@ -1,6 +1,6 @@
### All Submissions:
* [ ] Have you followed the [WooCommerce Contributing guideline](https://github.com/woocommerce/woocommerce/blob/master/.github/CONTRIBUTING.md)?
* [ ] Have you followed the [WooCommerce Contributing guideline](https://github.com/woocommerce/woocommerce/blob/trunk/.github/CONTRIBUTING.md)?
* [ ] Does your code follow the [WordPress' coding standards](https://make.wordpress.org/core/handbook/best-practices/coding-standards/)?
* [ ] Have you checked to ensure there aren't other open [Pull Requests](../../pulls) for the same update/change?

View File

@ -8,7 +8,7 @@ jobs:
strategy:
fail-fast: false
matrix:
build: [master]
build: [trunk]
runs-on: ubuntu-latest
steps:
- name: Checkout code

View File

@ -0,0 +1,74 @@
name: Build zip for PR
on:
pull_request
jobs:
build:
name: Build zip for PR
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build
id: build
uses: woocommerce/action-build@v2
- name: Upload PR zip
uses: actions/upload-artifact@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: woocommerce
path: ${{ steps.build.outputs.zip_path }}
retention-days: 7
e2e-tests-run:
name: Runs E2E tests.
runs-on: ubuntu-18.04
needs: [ build ]
steps:
- name: Create dirs.
run: |
mkdir -p code/woocommerce
mkdir -p package/woocommerce
mkdir -p tmp/woocommerce
mkdir -p node_modules
- name: Checkout code.
uses: actions/checkout@v2
with:
path: package/woocommerce
- name: Run npm install.
working-directory: package/woocommerce
run: npm install
- name: Load docker images and start containers.
working-directory: package/woocommerce
env:
WP_VERSION: 5.6.2
run: npx wc-e2e docker:up
- name: Move current directory to code. We will install zip file in this dir later.
run: mv ./package/woocommerce/* ./code/woocommerce
- name: Download WooCommerce ZIP.
uses: actions/download-artifact@v2
with:
name: woocommerce
path: tmp
- name: Extract and replace WooCommerce zip.
working-directory: tmp
run: |
unzip woocommerce.zip -d woocommerce
mv woocommerce/woocommerce/* ../package/woocommerce/
- name: Run tests command.
working-directory: code/woocommerce
env:
WC_E2E_SCREENSHOTS: 1
E2E_SLACK_TOKEN: ${{ secrets.E2E_SLACK_TOKEN }}
E2E_SLACK_CHANNEL: ${{ secrets.E2E_SLACK_CHANNEL }}
run: npx wc-e2e test:e2e

View File

@ -1,21 +0,0 @@
name: Build zip for PR
on:
pull_request
jobs:
build:
name: Build zip for PR
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build
id: build
uses: woocommerce/action-build@v2
- name: Upload PR zip
uses: actions/upload-artifact@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: woocommerce.zip
path: ${{ steps.build.outputs.zip_path }}
retention-days: 7

51
.github/workflows/pr-code-coverage.yml vendored Normal file
View File

@ -0,0 +1,51 @@
name: Run code coverage on PR
on:
pull_request
jobs:
test:
name: Code coverage (PHP 7.4, WP Latest)
timeout-minutes: 15
runs-on: ubuntu-latest
services:
database:
image: mysql:5.6
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
tools: composer
extensions: mysql
coverage: none
- name: Tool versions
run: |
php --version
composer --version
- name: Get cached composer directories
uses: actions/cache@v2
with:
path: |
./packages
./vendor
key: ${{ runner.os }}-${{ hashFiles('./composer.lock') }}
- name: Setup and install composer
run: composer install
- name: Init DB and WP
run: ./tests/bin/install.sh woo_test root root 127.0.0.1 latest
- name: Run unit tests with code coverage. Allow to fail.
run: |
RUN_CODE_COVERAGE=1 bash ./tests/bin/phpunit.sh
exit 0

49
.github/workflows/pr-code-sniff.yml vendored Normal file
View File

@ -0,0 +1,49 @@
name: Run code sniff on PR
on:
pull_request
jobs:
test:
name: Code sniff (PHP 7.4, WP Latest)
timeout-minutes: 15
runs-on: ubuntu-latest
services:
database:
image: mysql:5.6
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
tools: composer
extensions: mysql
coverage: none
- name: Tool versions
run: |
php --version
composer --version
- name: Get cached composer directories
uses: actions/cache@v2
with:
path: |
./packages
./vendor
key: ${{ runner.os }}-${{ hashFiles('./composer.lock') }}
- name: Setup and install composer
run: composer install
- name: Init DB and WP
run: ./tests/bin/install.sh woo_test root root 127.0.0.1 latest
- name: Run code sniff
run: RUN_PHPCS=1 bash ./tests/bin/phpcs.sh

View File

@ -7,6 +7,7 @@ jobs:
timeout-minutes: 15
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [ '7.0', '7.1', '7.2', '7.3', '7.4', '8.0' ]
wp: [ "latest" ]

1
.gitignore vendored
View File

@ -50,6 +50,7 @@ tests/cli/vendor
/tests/e2e/env/docker/wp-cli/initialize.sh
/tests/e2e/env/build/
/tests/e2e/env/build-module/
/tests/e2e/screenshots
/tests/e2e/utils/build/
/tests/e2e/utils/build-module/

View File

@ -1,9 +1,9 @@
version: ~> 1.0
# Specifies that Travis should create builds for master and release branches and also tags.
# Specifies that Travis should create builds for trunk and release branches and also tags.
branches:
only:
- master
- trunk
- /^\d+\.\d+(\.\d+)?(-\S*)?$/
- /^release\//

View File

@ -5,8 +5,8 @@
<a href="https://packagist.org/packages/woocommerce/woocommerce"><img src="https://poser.pugx.org/woocommerce/woocommerce/v/stable" alt="Latest Stable Version"></a>
<img src="https://img.shields.io/wordpress/plugin/dt/woocommerce.svg" alt="WordPress.org downloads">
<img src="https://img.shields.io/wordpress/plugin/r/woocommerce.svg" alt="WordPress.org rating">
<a href="https://travis-ci.com/woocommerce/woocommerce"><img src="https://travis-ci.com/woocommerce/woocommerce.svg?branch=master" alt="Build Status"></a>
<a href="https://codecov.io/gh/woocommerce/woocommerce"><img src="https://codecov.io/gh/woocommerce/woocommerce/branch/master/graph/badge.svg" alt="codecov"></a>
<a href="https://travis-ci.com/woocommerce/woocommerce"><img src="https://travis-ci.com/woocommerce/woocommerce.svg?branch=trunk" alt="Build Status"></a>
<a href="https://codecov.io/gh/woocommerce/woocommerce"><img src="https://codecov.io/gh/woocommerce/woocommerce/branch/trunk/graph/badge.svg" alt="codecov"></a>
</p>
Welcome to the WooCommerce repository on GitHub. Here you can browse the source, look at open issues and keep track of development. We recommend all developers to follow the [WooCommerce development blog](https://woocommerce.wordpress.com/) to stay up to date about everything happening in the project. You can also [follow @DevelopWC](https://twitter.com/DevelopWC) on Twitter for the latest development updates.
@ -34,4 +34,4 @@ This repository is not suitable for support. Please don't use our issue tracker
Support requests in issues on this repository will be closed on sight.
## Contributing to WooCommerce
If you have a patch or have stumbled upon an issue with WooCommerce core, you can contribute this back to the code. Please read our [contributor guidelines](https://github.com/woocommerce/woocommerce/blob/master/.github/CONTRIBUTING.md) for more information how you can do this.
If you have a patch or have stumbled upon an issue with WooCommerce core, you can contribute this back to the code. Please read our [contributor guidelines](https://github.com/woocommerce/woocommerce/blob/trunk/.github/CONTRIBUTING.md) for more information how you can do this.

View File

@ -22,17 +22,17 @@ $subtext: #767676 !default; // small,
// export vars as CSS vars
:root {
--woocommerce: $woocommerce;
--wc-green: $green;
--wc-red: $red;
--wc-orange: $orange;
--wc-blue: $blue;
--wc-primary: $primary;
--wc-primary-text: $primarytext;
--wc-secondary: $secondary;
--wc-secondary-text: $secondarytext;
--wc-highlight: $highlight;
--wc-highligh-text: $highlightext;
--wc-content-bg: $contentbg;
--wc-subtext: $subtext;
--woocommerce: #{$woocommerce};
--wc-green: #{$green};
--wc-red: #{$red};
--wc-orange: #{$orange};
--wc-blue: #{$blue};
--wc-primary: #{$primary};
--wc-primary-text: #{$primarytext};
--wc-secondary: #{$secondary};
--wc-secondary-text: #{$secondarytext};
--wc-highlight: #{$highlight};
--wc-highligh-text: #{$highlightext};
--wc-content-bg: #{$contentbg};
--wc-subtext: #{$subtext};
}

View File

@ -0,0 +1,52 @@
/**
* dashboard-setup.scss
* Styles for WooCommerce dashboard finish setup widgets
* only loaded on the dashboard itself.
*/
/**
* Styling begins
*/
.dashboard-widget-finish-setup {
.progress-wrapper {
border: 1px solid #757575;
border-radius: 16px;
font-size: 0.9em;
padding: 2px 8px 2px 8px;
display: inline-block;
box-sizing: border-box;
}
.progress-wrapper span {
position: relative;
top: -3px;
color: #757575;
}
.description div {
margin-top: 11px;
float: left;
width: 70%;
}
.description img {
float: right;
width: 30%;
}
.circle-progress {
margin-top: 1px;
margin-left: -3px;
circle {
stroke: #f0f0f0;
stroke-width: 1px;
}
.bar {
stroke: #949494;
}
}
}

View File

@ -7,60 +7,49 @@
/**
* Imports
*/
@import 'mixins';
@import 'variables';
@import 'fonts';
@import "mixins";
@import "variables";
@import "fonts";
/**
* Styling begins
*/
#adminmenu #toplevel_page_woocommerce .menu-icon-generic div.wp-menu-image::before {
font-family: 'WooCommerce' !important;
content: '\e03d';
}
#adminmenu #menu-posts-product .menu-icon-post div.wp-menu-image::before,
#adminmenu #menu-posts-product .menu-icon-product div.wp-menu-image::before {
font-family: 'WooCommerce' !important;
content: '\e006';
}
#adminmenu #toplevel_page_wc-reports .menu-icon-generic div.wp-menu-image::before {
font-family: 'WooCommerce' !important;
content: '\e023';
font-size: 1.3em !important;
}
span.mce_woocommerce_shortcodes_button {
background-image: none !important;
@include ir();
&::before {
@include icon( '\e01d' );
@include icon("\e01d");
font-size: 0.9em;
line-height: 1.2;
}
}
#woocommerce-update {
.updating-message {
.wc_plugin_upgrade_notice {
display: none;
}
}
.dummy {
display: none;
}
.wc_plugin_upgrade_notice {
font-weight: normal;
background: #FFF8E5 !important;
border-left: 4px solid #FFB900;
border-top: 1px solid #FFB900;
background: #fff8e5 !important;
border-left: 4px solid #ffb900;
border-top: 1px solid #ffb900;
padding: 9px 0 9px 12px !important;
margin: 0 -12px 0 -16px !important;
&::before {
content: '\f348';
content: "\f348";
display: inline-block;
font: 400 18px/1 dashicons;
speak: never;
@ -71,9 +60,11 @@ span.mce_woocommerce_shortcodes_button {
&.minor,
&.major {
padding: 20px 0 !important;
&::before {
display: none;
}
p {
padding: 0 20px;
margin: 0;
@ -81,24 +72,29 @@ span.mce_woocommerce_shortcodes_button {
line-height: 1.5em;
&::before {
content: '';
content: "";
display: none;
}
}
table.plugin-details-table {
margin: .75em 0 0;
margin: 0.75em 0 0;
tr {
background: transparent none !important;
border: 0 !important;
}
th, td {
th,
td {
background: transparent none !important;
margin: 0;
padding: .75em 20px 0;
padding: 0.75em 20px 0;
border: 0 !important;
font-size: 1em;
box-shadow: none;
}
th {
font-weight: bold;
}
@ -136,14 +132,15 @@ span.mce_woocommerce_shortcodes_button {
}
.wc_untested_extensions_modal--content {
h1 {
margin: 2px 2px 0.5em;
padding: .75em 1em;
padding: 0.75em 1em;
line-height: 1.5em;
font-size: 2em;
border-bottom: 1px solid #eee;
color: #fff;
background: #96578A;
background: #96578a;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
text-shadow: none;
@ -160,14 +157,17 @@ span.mce_woocommerce_shortcodes_button {
table.plugin-details-table {
margin: 20px 0;
th, td {
th,
td {
background: transparent none !important;
margin: 0;
padding: .75em 20px 0;
padding: 0.75em 20px 0;
border: 0 !important;
font-size: 1em;
box-shadow: none;
}
th {
font-weight: bold;
margin-top: 0;
@ -190,12 +190,20 @@ span.mce_woocommerce_shortcodes_button {
border-color: #a36597;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
color: #fff;
text-shadow: 0 -1px 1px #a36597, 1px 0 1px #a36597, 0 1px 1px #a36597, -1px 0 1px #a36597;
text-shadow:
0 -1px 1px #a36597,
1px 0 1px #a36597,
0 1px 1px #a36597,
-1px 0 1px #a36597;
&:hover, &:focus, &:active {
&:hover,
&:focus,
&:active {
background: #a36597;
border-color: #a36597;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 0 #a36597;
box-shadow:
inset 0 1px 0 rgba(255, 255, 255, 0.25),
0 1px 0 #a36597;
}
}
}

View File

@ -1481,6 +1481,10 @@ a.reset_variations {
border: 1px solid #ddd;
}
}
table.cart img.woocommerce-placeholder {
height: auto !important;
}
}
/**

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 9.9 KiB

View File

@ -1 +1 @@
<svg viewBox="0 0 998 810" xmlns="http://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M160.7 331.2h199.1c12.6 0 22.8 10.2 22.8 22.8v76c0 12.6-10.2 22.8-22.8 22.8h-71.4l9.8 24-43.1-24h-94.3c-12.6 0-22.8-10.2-22.8-22.8v-76c-.1-12.5 10.1-22.8 22.7-22.8z" fill="#9b5c8f" fill-rule="evenodd"/><path d="M150.2 351.9c1.4-1.9 3.5-2.9 6.3-3.1 5.1-.4 8 2 8.7 7.2 3.1 20.9 6.5 38.6 10.1 53.1l21.9-41.7c2-3.8 4.5-5.8 7.5-6 4.4-.3 7.1 2.5 8.2 8.4 2.5 13.3 5.7 24.6 9.5 34.2 2.6-25.4 7-43.7 13.2-55 1.5-2.8 3.7-4.2 6.6-4.4 2.3-.2 4.4.5 6.3 2s2.9 3.4 3.1 5.7c.1 1.8-.2 3.3-1 4.8-3.9 7.2-7.1 19.3-9.7 36.1-2.5 16.3-3.4 29-2.8 38.1.2 2.5-.2 4.7-1.2 6.6-1.2 2.2-3 3.4-5.3 3.6-2.6.2-5.3-1-7.9-3.7-9.3-9.5-16.7-23.7-22.1-42.6-6.5 12.8-11.3 22.4-14.4 28.8-5.9 11.3-10.9 17.1-15.1 17.4-2.7.2-5-2.1-7-6.9-5.1-13.1-10.6-38.4-16.5-75.9-.3-2.6.2-4.9 1.6-6.7zm215 15.7c-3.6-6.3-8.9-10.1-16-11.6-1.9-.4-3.7-.6-5.4-.6-9.6 0-17.4 5-23.5 15-5.2 8.5-7.8 17.9-7.8 28.2 0 7.7 1.6 14.3 4.8 19.8 3.6 6.3 8.9 10.1 16 11.6 1.9.4 3.7.6 5.4.6 9.7 0 17.5-5 23.5-15 5.2-8.6 7.8-18 7.8-28.3 0-7.8-1.6-14.3-4.8-19.7zm-12.6 27.7c-1.4 6.6-3.9 11.5-7.6 14.8-2.9 2.6-5.6 3.7-8.1 3.2-2.4-.5-4.4-2.6-5.9-6.5-1.2-3.1-1.8-6.2-1.8-9.1 0-2.5.2-5 .7-7.3.9-4.1 2.6-8.1 5.3-11.9 3.3-4.9 6.8-6.9 10.4-6.2 2.4.5 4.4 2.6 5.9 6.5 1.2 3.1 1.8 6.2 1.8 9.1 0 2.6-.3 5.1-.7 7.4zm-50.1-27.7c-3.6-6.3-9-10.1-16-11.6-1.9-.4-3.7-.6-5.4-.6-9.6 0-17.4 5-23.5 15-5.2 8.5-7.8 17.9-7.8 28.2 0 7.7 1.6 14.3 4.8 19.8 3.6 6.3 8.9 10.1 16 11.6 1.9.4 3.7.6 5.4.6 9.7 0 17.5-5 23.5-15 5.2-8.6 7.8-18 7.8-28.3 0-7.8-1.6-14.3-4.8-19.7zm-12.6 27.7c-1.4 6.6-3.9 11.5-7.6 14.8-2.9 2.6-5.6 3.7-8.1 3.2-2.4-.5-4.4-2.6-5.9-6.5-1.2-3.1-1.8-6.2-1.8-9.1 0-2.5.2-5 .7-7.3.9-4.1 2.6-8.1 5.3-11.9 3.3-4.9 6.8-6.9 10.4-6.2 2.4.5 4.4 2.6 5.9 6.5 1.2 3.1 1.8 6.2 1.8 9.1 0 2.6-.2 5.1-.7 7.4z" fill="#fff"/><path d="M407.9 366.7c-6.7 6.6-10 15-10 25.2 0 10.9 3.3 19.8 9.9 26.5s15.2 10.1 25.9 10.1c3.1 0 6.6-.5 10.4-1.6v-16.2c-3.5 1-6.5 1.5-9.1 1.5-5.3 0-9.5-1.8-12.7-5.3-3.2-3.6-4.8-8.4-4.8-14.5 0-5.7 1.6-10.4 4.7-14 3.2-3.7 7.1-5.5 11.9-5.5 3.1 0 6.4.5 10 1.5v-16.2c-3.3-.9-7-1.3-10.9-1.3-10.2-.1-18.6 3.2-25.3 9.8zm69.4-9.9c-9.2 0-16.4 3.1-21.6 9.2s-7.7 14.7-7.7 25.7c0 11.9 2.6 21 7.7 27.3s12.6 9.5 22.4 9.5c9.5 0 16.8-3.2 21.9-9.5s7.7-15.2 7.7-26.6-2.6-20.2-7.8-26.4c-5.3-6.1-12.8-9.2-22.6-9.2zm7.9 52c-1.8 2.8-4.5 4.2-7.9 4.2-3.2 0-5.6-1.4-7.3-4.2s-2.5-8.4-2.5-16.9c0-13.1 3.3-19.6 10-19.6 7 0 10.6 6.6 10.6 19.9-.1 8.2-1.1 13.8-2.9 16.6zm71.9-50.1l-3.6 15.3c-.9 3.9-1.8 7.9-2.6 12l-2 10.6c-1.9-10.6-4.5-23.2-7.8-37.9h-23.2l-8.7 68.1h17.4l4.7-46.9 11.9 46.9h12.4L567 380l4.9 46.8h18.2l-9.2-68.1zm83.3 0l-3.6 15.3c-.9 3.9-1.8 7.9-2.6 12l-2 10.6c-1.9-10.6-4.5-23.2-7.8-37.9h-23.2l-8.7 68.1h17.4l4.7-46.9 11.9 46.9h12.4l11.3-46.8 4.9 46.8h18.2l-9.2-68.1zm56.6 41.2h16.3v-14.1H697v-12.5h18.8v-14.5h-37.2v68.1h37.3v-14.5H697zm70.7-10.8c1.9-3.1 2.9-6.3 2.9-9.6 0-6.4-2.5-11.5-7.5-15.2s-11.9-5.6-20.5-5.6h-21.4v68.1h18.4v-31h.3l14.9 31h19.4l-14.7-30.7c3.5-1.6 6.3-3.9 8.2-7zm-28.2-1.1v-16.2c4.4.1 7.5.8 9.4 2.2s2.8 3.6 2.8 6.8c0 4.7-4.1 7.1-12.2 7.2zm41.9-21.3c-6.7 6.6-10 15-10 25.2 0 10.9 3.3 19.8 9.9 26.5s15.2 10.1 25.9 10.1c3.1 0 6.6-.5 10.4-1.6v-16.2c-3.5 1-6.5 1.5-9.1 1.5-5.3 0-9.5-1.8-12.7-5.3-3.2-3.6-4.8-8.4-4.8-14.5 0-5.7 1.6-10.4 4.7-14 3.2-3.7 7.1-5.5 11.9-5.5 3.1 0 6.4.5 10 1.5v-16.2c-3.3-.9-7-1.3-10.9-1.3-10.1-.1-18.6 3.2-25.3 9.8zm59.7 45.5v-12.4h16.3v-14.1h-16.3v-12.5H860v-14.5h-37.2v68.1h37.3v-14.5h-19z"/></svg>
<svg viewBox="0 0 998 810" xmlns="http://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M160.7 331.2h199.1c12.6 0 22.8 10.2 22.8 22.8v76c0 12.6-10.2 22.8-22.8 22.8h-71.4l9.8 24-43.1-24h-94.3c-12.6 0-22.8-10.2-22.8-22.8v-76c-.1-12.5 10.1-22.8 22.7-22.8z" fill="#7f54b3" fill-rule="evenodd"/><path d="M150.2 351.9c1.4-1.9 3.5-2.9 6.3-3.1 5.1-.4 8 2 8.7 7.2 3.1 20.9 6.5 38.6 10.1 53.1l21.9-41.7c2-3.8 4.5-5.8 7.5-6 4.4-.3 7.1 2.5 8.2 8.4 2.5 13.3 5.7 24.6 9.5 34.2 2.6-25.4 7-43.7 13.2-55 1.5-2.8 3.7-4.2 6.6-4.4 2.3-.2 4.4.5 6.3 2s2.9 3.4 3.1 5.7c.1 1.8-.2 3.3-1 4.8-3.9 7.2-7.1 19.3-9.7 36.1-2.5 16.3-3.4 29-2.8 38.1.2 2.5-.2 4.7-1.2 6.6-1.2 2.2-3 3.4-5.3 3.6-2.6.2-5.3-1-7.9-3.7-9.3-9.5-16.7-23.7-22.1-42.6-6.5 12.8-11.3 22.4-14.4 28.8-5.9 11.3-10.9 17.1-15.1 17.4-2.7.2-5-2.1-7-6.9-5.1-13.1-10.6-38.4-16.5-75.9-.3-2.6.2-4.9 1.6-6.7zm215 15.7c-3.6-6.3-8.9-10.1-16-11.6-1.9-.4-3.7-.6-5.4-.6-9.6 0-17.4 5-23.5 15-5.2 8.5-7.8 17.9-7.8 28.2 0 7.7 1.6 14.3 4.8 19.8 3.6 6.3 8.9 10.1 16 11.6 1.9.4 3.7.6 5.4.6 9.7 0 17.5-5 23.5-15 5.2-8.6 7.8-18 7.8-28.3 0-7.8-1.6-14.3-4.8-19.7zm-12.6 27.7c-1.4 6.6-3.9 11.5-7.6 14.8-2.9 2.6-5.6 3.7-8.1 3.2-2.4-.5-4.4-2.6-5.9-6.5-1.2-3.1-1.8-6.2-1.8-9.1 0-2.5.2-5 .7-7.3.9-4.1 2.6-8.1 5.3-11.9 3.3-4.9 6.8-6.9 10.4-6.2 2.4.5 4.4 2.6 5.9 6.5 1.2 3.1 1.8 6.2 1.8 9.1 0 2.6-.3 5.1-.7 7.4zm-50.1-27.7c-3.6-6.3-9-10.1-16-11.6-1.9-.4-3.7-.6-5.4-.6-9.6 0-17.4 5-23.5 15-5.2 8.5-7.8 17.9-7.8 28.2 0 7.7 1.6 14.3 4.8 19.8 3.6 6.3 8.9 10.1 16 11.6 1.9.4 3.7.6 5.4.6 9.7 0 17.5-5 23.5-15 5.2-8.6 7.8-18 7.8-28.3 0-7.8-1.6-14.3-4.8-19.7zm-12.6 27.7c-1.4 6.6-3.9 11.5-7.6 14.8-2.9 2.6-5.6 3.7-8.1 3.2-2.4-.5-4.4-2.6-5.9-6.5-1.2-3.1-1.8-6.2-1.8-9.1 0-2.5.2-5 .7-7.3.9-4.1 2.6-8.1 5.3-11.9 3.3-4.9 6.8-6.9 10.4-6.2 2.4.5 4.4 2.6 5.9 6.5 1.2 3.1 1.8 6.2 1.8 9.1 0 2.6-.2 5.1-.7 7.4z" fill="#fff"/><path d="M407.9 366.7c-6.7 6.6-10 15-10 25.2 0 10.9 3.3 19.8 9.9 26.5s15.2 10.1 25.9 10.1c3.1 0 6.6-.5 10.4-1.6v-16.2c-3.5 1-6.5 1.5-9.1 1.5-5.3 0-9.5-1.8-12.7-5.3-3.2-3.6-4.8-8.4-4.8-14.5 0-5.7 1.6-10.4 4.7-14 3.2-3.7 7.1-5.5 11.9-5.5 3.1 0 6.4.5 10 1.5v-16.2c-3.3-.9-7-1.3-10.9-1.3-10.2-.1-18.6 3.2-25.3 9.8zm69.4-9.9c-9.2 0-16.4 3.1-21.6 9.2s-7.7 14.7-7.7 25.7c0 11.9 2.6 21 7.7 27.3s12.6 9.5 22.4 9.5c9.5 0 16.8-3.2 21.9-9.5s7.7-15.2 7.7-26.6-2.6-20.2-7.8-26.4c-5.3-6.1-12.8-9.2-22.6-9.2zm7.9 52c-1.8 2.8-4.5 4.2-7.9 4.2-3.2 0-5.6-1.4-7.3-4.2s-2.5-8.4-2.5-16.9c0-13.1 3.3-19.6 10-19.6 7 0 10.6 6.6 10.6 19.9-.1 8.2-1.1 13.8-2.9 16.6zm71.9-50.1l-3.6 15.3c-.9 3.9-1.8 7.9-2.6 12l-2 10.6c-1.9-10.6-4.5-23.2-7.8-37.9h-23.2l-8.7 68.1h17.4l4.7-46.9 11.9 46.9h12.4L567 380l4.9 46.8h18.2l-9.2-68.1zm83.3 0l-3.6 15.3c-.9 3.9-1.8 7.9-2.6 12l-2 10.6c-1.9-10.6-4.5-23.2-7.8-37.9h-23.2l-8.7 68.1h17.4l4.7-46.9 11.9 46.9h12.4l11.3-46.8 4.9 46.8h18.2l-9.2-68.1zm56.6 41.2h16.3v-14.1H697v-12.5h18.8v-14.5h-37.2v68.1h37.3v-14.5H697zm70.7-10.8c1.9-3.1 2.9-6.3 2.9-9.6 0-6.4-2.5-11.5-7.5-15.2s-11.9-5.6-20.5-5.6h-21.4v68.1h18.4v-31h.3l14.9 31h19.4l-14.7-30.7c3.5-1.6 6.3-3.9 8.2-7zm-28.2-1.1v-16.2c4.4.1 7.5.8 9.4 2.2s2.8 3.6 2.8 6.8c0 4.7-4.1 7.1-12.2 7.2zm41.9-21.3c-6.7 6.6-10 15-10 25.2 0 10.9 3.3 19.8 9.9 26.5s15.2 10.1 25.9 10.1c3.1 0 6.6-.5 10.4-1.6v-16.2c-3.5 1-6.5 1.5-9.1 1.5-5.3 0-9.5-1.8-12.7-5.3-3.2-3.6-4.8-8.4-4.8-14.5 0-5.7 1.6-10.4 4.7-14 3.2-3.7 7.1-5.5 11.9-5.5 3.1 0 6.4.5 10 1.5v-16.2c-3.3-.9-7-1.3-10.9-1.3-10.1-.1-18.6 3.2-25.3 9.8zm59.7 45.5v-12.4h16.3v-14.1h-16.3v-12.5H860v-14.5h-37.2v68.1h37.3v-14.5h-19z"/></svg>

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@ -58,7 +58,7 @@
} else {
$( '#copy-error' ).text( '' );
wcClearClipboard();
wcSetClipboard( $.trim( $( this ).prev( 'input' ).val() ), $( css_class ) );
wcSetClipboard( $( this ).prev( 'input' ).val().trim(), $( css_class ) );
}
} )
.on( 'aftercopy', css_class, function() {

View File

@ -12,7 +12,7 @@ jQuery(function( $ ) {
init: function() {
$( 'select#discount_type' )
.on( 'change', this.type_options )
.change();
.trigger( 'change' );
this.insert_generate_coupon_code_button();
$( '.button.generate-coupon-code' ).on( 'click', this.generate_coupon_code );

View File

@ -90,7 +90,7 @@ jQuery( function ( $ ) {
$state.replaceWith( $newstate );
$newstate.show().selectWoo().hide().change();
$newstate.show().selectWoo().hide().trigger( 'change' );
} else {
$newstate = $( '<input type="text" />' )
.prop( 'id', input_id )
@ -143,8 +143,8 @@ jQuery( function ( $ ) {
$this.parent().find( 'a' ).toggle();
if ( ! $country_input.val() ) {
$country_input.val( woocommerce_admin_meta_boxes_order.default_country ).change();
$state_input.val( woocommerce_admin_meta_boxes_order.default_state ).change();
$country_input.val( woocommerce_admin_meta_boxes_order.default_country ).trigger( 'change' );
$state_input.val( woocommerce_admin_meta_boxes_order.default_state ).trigger( 'change' );
}
$edit_address.show();
@ -158,7 +158,7 @@ jQuery( function ( $ ) {
change_customer_user: function() {
if ( ! $( '#_billing_country' ).val() ) {
$( 'a.edit_address' ).click();
$( 'a.edit_address' ).trigger( 'click' );
wc_meta_boxes_order.load_billing( true );
wc_meta_boxes_order.load_shipping( true );
}
@ -196,7 +196,7 @@ jQuery( function ( $ ) {
success: function( response ) {
if ( response && response.billing ) {
$.each( response.billing, function( key, data ) {
$( ':input#_billing_' + key ).val( data ).change();
$( ':input#_billing_' + key ).val( data ).trigger( 'change' );
});
}
$( 'div.edit_address' ).unblock();
@ -238,7 +238,7 @@ jQuery( function ( $ ) {
success: function( response ) {
if ( response && response.billing ) {
$.each( response.shipping, function( key, data ) {
$( ':input#_shipping_' + key ).val( data ).change();
$( ':input#_shipping_' + key ).val( data ).trigger( 'change' );
});
}
$( 'div.edit_address' ).unblock();
@ -253,7 +253,7 @@ jQuery( function ( $ ) {
$('.order_data_column :input[name^="_billing_"]').each( function() {
var input_name = $(this).attr('name');
input_name = input_name.replace( '_billing_', '_shipping_' );
$( ':input#' + input_name ).val( $(this).val() ).change();
$( ':input#' + input_name ).val( $(this).val() ).trigger( 'change' );
});
}
return false;
@ -643,7 +643,7 @@ jQuery( function ( $ ) {
$( this ).closest( 'tr' ).find( '.view' ).hide();
$( this ).closest( 'tr' ).find( '.edit' ).show();
$( this ).hide();
$( 'button.add-line-item' ).click();
$( 'button.add-line-item' ).trigger( 'click' );
$( 'button.cancel-action' ).attr( 'data-reload', true );
window.wcTracks.recordEvent( 'order_edit_edit_item_click', {
order_id: woocommerce_admin_meta_boxes.post_id,
@ -1002,7 +1002,7 @@ jQuery( function ( $ ) {
'',
woocommerce_admin.mon_decimal_point
) )
.change();
.trigger( 'change' );
},
amount_changed: function() {
@ -1032,7 +1032,7 @@ jQuery( function ( $ ) {
parseFloat( accounting.formatNumber( unit_total * refund_qty, woocommerce_admin_meta_boxes.rounding_precision, '' ) )
.toString()
.replace( '.', woocommerce_admin.mon_decimal_point )
).change();
).trigger( 'change' );
// Taxes
$( '.refund_line_tax', $row ).each( function() {
@ -1054,9 +1054,9 @@ jQuery( function ( $ ) {
parseFloat( accounting.formatNumber( unit_total_tax * refund_qty, precision, '' ) )
.toString()
.replace( '.', woocommerce_admin.mon_decimal_point )
).change();
).trigger( 'change' );
} else {
$refund_line_total_tax.val( 0 ).change();
$refund_line_total_tax.val( 0 ).trigger( 'change' );
}
});
@ -1401,7 +1401,7 @@ jQuery( function ( $ ) {
}
$( document.body ).trigger( 'wc-init-datepickers' );
$( '#grant_access_id' ).val( '' ).change();
$( '#grant_access_id' ).val( '' ).trigger( 'change' );
$( '.order_download_permissions' ).unblock();
});

View File

@ -19,7 +19,7 @@ jQuery( function( $ ) {
.on( 'click', 'h3 .sort', this.set_menu_order )
.on( 'reload', this.reload );
$( 'input.variable_is_downloadable, input.variable_is_virtual, input.variable_manage_stock' ).change();
$( 'input.variable_is_downloadable, input.variable_is_virtual, input.variable_manage_stock' ).trigger( 'change' );
$( '#woocommerce-product-data' ).on( 'woocommerce_variations_loaded', this.variations_loaded );
$( document.body ).on( 'woocommerce_variations_added', this.variation_added );
},
@ -95,7 +95,7 @@ jQuery( function( $ ) {
if ( ! needsUpdate ) {
// Show/hide downloadable, virtual and stock fields
$( 'input.variable_is_downloadable, input.variable_is_virtual, input.variable_manage_stock', wrapper ).change();
$( 'input.variable_is_downloadable, input.variable_is_virtual, input.variable_manage_stock', wrapper ).trigger( 'change' );
// Open sale schedule fields when have some sale price date
$( '.woocommerce_variation', wrapper ).each( function( index, el ) {
@ -104,7 +104,7 @@ jQuery( function( $ ) {
date_to = $( '.sale_price_dates_to', $el ).val();
if ( '' !== date_from || '' !== date_to ) {
$( 'a.sale_schedule', $el ).click();
$( 'a.sale_schedule', $el ).trigger( 'click' );
}
});
@ -138,7 +138,7 @@ jQuery( function( $ ) {
date = $( this ).datepicker( 'getDate' );
dates.not( this ).datepicker( 'option', option, date );
$( this ).change();
$( this ).trigger( 'change' );
}
});
@ -182,7 +182,7 @@ jQuery( function( $ ) {
if ( value != null ) {
// Set value, save changes and reload view
$menu_order.val( parseInt( value, 10 ) ).change();
$menu_order.val( parseInt( value, 10 ) ).trigger( 'change' );
wc_meta_boxes_product_variations_ajax.save_variations();
}
},
@ -199,7 +199,7 @@ jQuery( function( $ ) {
$( '.variation_menu_order', el )
.val( parseInt( $( el )
.index( '.woocommerce_variations .woocommerce_variation' ), 10 ) + 1 + offset )
.change();
.trigger( 'change' );
});
}
};
@ -262,7 +262,7 @@ jQuery( function( $ ) {
if ( $button.is( '.remove' ) ) {
$( '.upload_image_id', wc_meta_boxes_product_variations_media.setting_variation_image ).val( '' ).change();
$( '.upload_image_id', wc_meta_boxes_product_variations_media.setting_variation_image ).val( '' ).trigger( 'change' );
wc_meta_boxes_product_variations_media.setting_variation_image.find( 'img' ).eq( 0 )
.attr( 'src', woocommerce_admin_meta_boxes_variations.woocommerce_placeholder_img_src );
wc_meta_boxes_product_variations_media.setting_variation_image.find( '.upload_image_button' ).removeClass( 'remove' );
@ -301,7 +301,8 @@ jQuery( function( $ ) {
.get( 'selection' ).first().toJSON(),
url = attachment.sizes && attachment.sizes.thumbnail ? attachment.sizes.thumbnail.url : attachment.url;
$( '.upload_image_id', wc_meta_boxes_product_variations_media.setting_variation_image ).val( attachment.id ).change();
$( '.upload_image_id', wc_meta_boxes_product_variations_media.setting_variation_image ).val( attachment.id )
.trigger( 'change' );
wc_meta_boxes_product_variations_media.setting_variation_image.find( '.upload_image_button' ).addClass( 'remove' );
wc_meta_boxes_product_variations_media.setting_variation_image.find( 'img' ).eq( 0 ).attr( 'src', url );
@ -346,7 +347,7 @@ jQuery( function( $ ) {
postForm.on( 'submit', this.save_on_submit );
$( 'input:submit', postForm ).bind( 'click keypress', function() {
$( 'input:submit', postForm ).on( 'click keypress', function() {
postForm.data( 'callerid', this.id );
});
@ -547,9 +548,9 @@ jQuery( function( $ ) {
callerid = postForm.data( 'callerid' );
if ( 'publish' === callerid ) {
postForm.append('<input type="hidden" name="publish" value="1" />').submit();
postForm.append('<input type="hidden" name="publish" value="1" />').trigger( 'submit' );
} else {
postForm.append('<input type="hidden" name="save-post" value="1" />').submit();
postForm.append('<input type="hidden" name="save-post" value="1" />').trigger( 'submit' );
}
},
@ -977,7 +978,7 @@ jQuery( function( $ ) {
* Set page
*/
set_page: function( page ) {
$( '.variations-pagenav .page-selector' ).val( page ).first().change();
$( '.variations-pagenav .page-selector' ).val( page ).first().trigger( 'change' );
},
/**

View File

@ -20,7 +20,7 @@ jQuery( function( $ ) {
});
// Prevent enter submitting post form.
$( '#upsell_product_data' ).bind( 'keypress', function( e ) {
$( '#upsell_product_data' ).on( 'keypress', function( e ) {
if ( e.keyCode === 13 ) {
return false;
}
@ -100,7 +100,7 @@ jQuery( function( $ ) {
var select_val = $( this ).val();
if ( 'variable' === select_val ) {
$( 'input#_manage_stock' ).change();
$( 'input#_manage_stock' ).trigger( 'change' );
$( 'input#_downloadable' ).prop( 'checked', false );
$( 'input#_virtual' ).removeAttr( 'checked' );
} else if ( 'grouped' === select_val ) {
@ -113,11 +113,11 @@ jQuery( function( $ ) {
show_and_hide_panels();
$( 'ul.wc-tabs li:visible' ).eq( 0 ).find( 'a' ).click();
$( 'ul.wc-tabs li:visible' ).eq( 0 ).find( 'a' ).trigger( 'click' );
$( document.body ).trigger( 'woocommerce-product-type-change', select_val, $( this ) );
}).change();
}).trigger( 'change' );
$( 'input#_downloadable, input#_virtual' ).change( function() {
show_and_hide_panels();
@ -165,7 +165,7 @@ jQuery( function( $ ) {
$( '.hide_if_' + product_type ).hide();
$( 'input#_manage_stock' ).change();
$( 'input#_manage_stock' ).trigger( 'change' );
// Hide empty panels/tabs after display.
$( '.woocommerce_options_panel' ).each( function() {
@ -250,8 +250,8 @@ jQuery( function( $ ) {
$( 'p.stock_status_field:not( .hide_if_' + product_type + ' )' ).show();
}
$( 'input.variable_manage_stock' ).change();
}).change();
$( 'input.variable_manage_stock' ).trigger( 'change' );
}).trigger( 'change' );
// Date picker fields.
function date_picker_select( datepicker ) {
@ -260,7 +260,7 @@ jQuery( function( $ ) {
date = $( datepicker ).datepicker( 'getDate' );
$( otherDateField ).datepicker( 'option', option, date );
$( datepicker ).change();
$( datepicker ).trigger( 'change' );
}
$( '.sale_price_dates_fields' ).each( function() {
@ -335,7 +335,7 @@ jQuery( function( $ ) {
attribute_row_indexes();
$attributes.find( '.woocommerce_attribute' ).last().find( 'h3' ).click();
$attributes.find( '.woocommerce_attribute' ).last().find( 'h3' ).trigger( 'click' );
$wrapper.unblock();
@ -356,13 +356,13 @@ jQuery( function( $ ) {
$( '.product_attributes' ).on( 'click', 'button.select_all_attributes', function() {
$( this ).closest( 'td' ).find( 'select option' ).prop( 'selected', 'selected' );
$( this ).closest( 'td' ).find( 'select' ).change();
$( this ).closest( 'td' ).find( 'select' ).trigger( 'change' );
return false;
});
$( '.product_attributes' ).on( 'click', 'button.select_no_attributes', function() {
$( this ).closest( 'td' ).find( 'select option' ).removeAttr( 'selected' );
$( this ).closest( 'td' ).find( 'select' ).change();
$( this ).closest( 'td' ).find( 'select' ).trigger( 'change' );
return false;
});
@ -436,7 +436,7 @@ jQuery( function( $ ) {
// Success.
$wrapper.find( 'select.attribute_values' )
.append( '<option value="' + response.term_id + '" selected="selected">' + response.name + '</option>' );
$wrapper.find( 'select.attribute_values' ).change();
$wrapper.find( 'select.attribute_values' ).trigger( 'change' );
}
$( '.product_attributes' ).unblock();
@ -556,7 +556,7 @@ jQuery( function( $ ) {
}
});
file_path_field.val( file_path ).change();
file_path_field.val( file_path ).trigger( 'change' );
});
// Set post to 0 and set our custom type.

View File

@ -32,7 +32,7 @@ jQuery( function ( $ ) {
$( $( this ).attr( 'href' ) ).show();
});
$( 'div.panel-wrap' ).each( function() {
$( this ).find( 'ul.wc-tabs li' ).eq( 0 ).find( 'a' ).click();
$( this ).find( 'ul.wc-tabs li' ).eq( 0 ).find( 'a' ).trigger( 'click' );
});
}).trigger( 'wc-init-tabbed-panels' );

View File

@ -44,8 +44,9 @@ jQuery(
$( 'input[name="_width"]', '.inline-edit-row' ).val( width );
$( 'input[name="_height"]', '.inline-edit-row' ).val( height );
$( 'select[name="_shipping_class"] option:selected', '.inline-edit-row' ).attr( 'selected', false ).change();
$( 'select[name="_shipping_class"] option[value="' + shipping_class + '"]' ).attr( 'selected', 'selected' ).change();
$( 'select[name="_shipping_class"] option:selected', '.inline-edit-row' ).attr( 'selected', false ).trigger( 'change' );
$( 'select[name="_shipping_class"] option[value="' + shipping_class + '"]' ).attr( 'selected', 'selected' )
.trigger( 'change' );
$( 'input[name="_stock"]', '.inline-edit-row' ).val( stock );
$( 'input[name="menu_order"]', '.inline-edit-row' ).val( menu_order );

View File

@ -10,7 +10,7 @@ jQuery(function( $ ) {
var prev_data_index = null;
var prev_series_index = null;
$( '.chart-placeholder' ).bind( 'plothover', function ( event, pos, item ) {
$( '.chart-placeholder' ).on( 'plothover', function ( event, pos, item ) {
if ( item ) {
if ( prev_data_index !== item.dataIndex || prev_series_index !== item.seriesIndex ) {
prev_data_index = item.dataIndex;

View File

@ -13,7 +13,7 @@
$( this ).closest('tr').next( 'tr' ).hide();
$( this ).closest('tr').next().next( 'tr' ).hide();
}
}).change();
}).trigger( 'change' );
// Ship Countries
$( 'select#woocommerce_ship_to_countries' ).change( function() {
@ -22,7 +22,7 @@
} else {
$( this ).closest('tr').next( 'tr' ).hide();
}
}).change();
}).trigger( 'change' );
// Stock management
$( 'input#woocommerce_manage_stock' ).change( function() {
@ -31,7 +31,7 @@
} else {
$( this ).closest('tbody').find( '.manage_stock_field' ).closest( 'tr' ).hide();
}
}).change();
}).trigger( 'change' );
// Color picker
$( '.colorpick' )
@ -56,9 +56,9 @@
var original_value = $( this ).data( 'original-value' );
if ( original_value.match( /^\#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/ ) ) {
$( this ).val( $( this ).data( 'original-value' ) ).change();
$( this ).val( $( this ).data( 'original-value' ) ).trigger( 'change' );
} else {
$( this ).val( '' ).change();
$( this ).val( '' ).trigger( 'change' );
}
}
});

View File

@ -34,11 +34,11 @@ jQuery( function ( $ ) {
$( '.wc_status_table thead, .wc_status_table tbody' ).each( function() {
if ( $( this ).is( 'thead' ) ) {
var label = $( this ).find( 'th:eq(0)' ).data( 'export-label' ) || $( this ).text();
report = report + '\n### ' + $.trim( label ) + ' ###\n\n';
report = report + '\n### ' + label.trim() + ' ###\n\n';
} else {
$( 'tr', $( this ) ).each( function() {
var label = $( this ).find( 'td:eq(0)' ).data( 'export-label' ) || $( this ).find( 'td:eq(0)' ).text();
var the_name = $.trim( label ).replace( /(<([^>]+)>)/ig, '' ); // Remove HTML.
var the_name = label.trim().replace( /(<([^>]+)>)/ig, '' ); // Remove HTML.
// Find value
var $value_html = $( this ).find( 'td:eq(2)' ).clone();
@ -47,7 +47,7 @@ jQuery( function ( $ ) {
$value_html.find( '.dashicons-no-alt, .dashicons-warning' ).replaceWith( '&#10060;' );
// Format value
var the_value = $.trim( $value_html.text() );
var the_value = $value_html.text().trim();
var value_array = the_value.split( ', ' );
if ( value_array.length > 1 ) {

View File

@ -71,7 +71,7 @@ jQuery( function ( $ ) {
$state.replaceWith( $newstate );
$newstate.show().selectWoo().hide().change();
$newstate.show().selectWoo().hide().trigger( 'change' );
} else {
$newstate = $( '<input type="text" />' )
.prop( 'id', input_id )

View File

@ -93,7 +93,7 @@
if ( -1 !== $.inArray( 'variation', $( this ).val() ) ) {
exportCategory.closest( 'tr' ).hide();
exportCategory.val( '' ).change(); // Reset WooSelect selected value.
exportCategory.val( '' ).trigger( 'change' ); // Reset WooSelect selected value.
} else {
exportCategory.closest( 'tr' ).show();
}

View File

@ -37,7 +37,7 @@ jQuery( function( $ ) {
} );
$( document.body ).on( 'wc_backbone_modal_response', function() {
form.unbind( 'submit' ).submit();
form.unbind( 'submit' ).trigger( 'submit' );
} );
$( '#wc_tracker_checkbox_dialog' ).on( 'change', function( e ) {
@ -46,7 +46,7 @@ jQuery( function( $ ) {
} );
$( '#wc_tracker_submit' ).on( 'click', function () {
form.unbind( 'submit' ).submit();
form.unbind( 'submit' ).trigger( 'submit' );
} );
return true;
@ -72,13 +72,13 @@ jQuery( function( $ ) {
} );
$( '.store-state-container' ).show();
$state_select.selectWoo().val( wc_base_state ).change().prop( 'required', true );
$state_select.selectWoo().val( wc_base_state ).trigger( 'change' ).prop( 'required', true );
} else {
$( '.store-state-container' ).hide();
$state_select.empty().val( '' ).change().prop( 'required', false );
$state_select.empty().val( '' ).trigger( 'change' ).prop( 'required', false );
}
$( '#currency_code' ).val( wc_setup_currencies[ country ] ).change();
$( '#currency_code' ).val( wc_setup_currencies[ country ] ).trigger( 'change' );
} );
/* Setup postcode field and validations */
@ -100,7 +100,7 @@ jQuery( function( $ ) {
}
} );
$( '#store_country' ).change();
$( '#store_country' ).trigger( 'change' );
$( '.wc-wizard-services' ).on( 'change', '.wc-wizard-service-enable input', function() {
if ( $( this ).is( ':checked' ) ) {
@ -121,7 +121,7 @@ jQuery( function( $ ) {
$focused = $( document.activeElement );
if ( $focused.is( '.wc-wizard-service-toggle, .wc-wizard-service-enable' ) && ( 13 === code || 32 === code ) ) {
$focused.find( ':input' ).click();
$focused.find( ':input' ).trigger( 'click' );
}
} );
@ -135,7 +135,7 @@ jQuery( function( $ ) {
var $checkbox = $( this ).find( 'input[type="checkbox"]' );
$checkbox.prop( 'checked', ! $checkbox.prop( 'checked' ) ).change();
$checkbox.prop( 'checked', ! $checkbox.prop( 'checked' ) ).trigger( 'change' );
} );
$( '.wc-wizard-services-list-toggle' ).on( 'click', function() {
@ -165,7 +165,7 @@ jQuery( function( $ ) {
.removeClass( 'hide' )
.find( '.shipping-method-required-field' )
.prop( 'required', $checkbox.prop( 'checked' ) );
} ).find( '.wc-wizard-shipping-method-select .method' ).change();
} ).find( '.wc-wizard-shipping-method-select .method' ).trigger( 'change' );
$( '.wc-wizard-services' ).on( 'change', '.wc-wizard-shipping-method-enable', function() {
var checked = $( this ).is( ':checked' );
@ -182,7 +182,7 @@ jQuery( function( $ ) {
} );
function submitActivateForm() {
$( 'form.activate-jetpack' ).submit();
$( 'form.activate-jetpack' ).trigger( 'submit' );
}
function waitForJetpackInstall() {
@ -239,7 +239,7 @@ jQuery( function( $ ) {
.prop( 'disabled', true )
.prop( 'required', false );
}
} ).find( 'input#stripe_create_account, input#ppec_paypal_reroute_requests' ).change();
} ).find( 'input#stripe_create_account, input#ppec_paypal_reroute_requests' ).trigger( 'change' );
function addPlugins( bySlug, $el, hover ) {
var plugins = $el.data( 'plugins' );

View File

@ -354,7 +354,7 @@
}
});
$( '.wc-shipping-zone-method-selector select' ).change();
$( '.wc-shipping-zone-method-selector select' ).trigger( 'change' );
},
onAddShippingMethodSubmitted: function( event, target, posted_data ) {
if ( 'wc-modal-add-shipping-method' === target ) {

View File

@ -0,0 +1,32 @@
/*global jQuery */
(function( $ ) {
var recordEvent = function( link ) {
window.wcTracks.recordEvent( 'status_widget_click', {
link: link
} );
};
$( '.sales-this-month a' ).on( 'click', function() {
recordEvent( 'net-sales' );
});
$( '.best-seller-this-month a' ).on( 'click', function() {
recordEvent( 'best-seller-this-month' );
});
$( '.processing-orders a' ).on( 'click', function() {
recordEvent( 'orders-processing' );
});
$( '.on-hold-orders a' ).on( 'click', function() {
recordEvent( 'orders-on-hold' );
});
$( '.low-in-stock a' ).on( 'click', function() {
recordEvent( 'low-stock' );
});
$( '.out-of-stock a' ).on( 'click', function() {
recordEvent( 'out-of-stock' );
});
})( jQuery );

View File

@ -250,7 +250,7 @@
var shifted = false;
var hasFocus = false;
$( document.body ).bind( 'keyup keydown', function( e ) {
$( document.body ).on( 'keyup keydown', function( e ) {
shifted = e.shiftKey;
controlled = e.ctrlKey || e.metaKey;
});
@ -315,7 +315,7 @@
} else {
$( this ).closest( 'tr' ).next( 'tr' ).show();
}
}).change();
}).trigger( 'change' );
// Hidden options
$( '.hide_options_if_checked' ).each( function() {
@ -331,7 +331,7 @@
.nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' )
.show();
}
}).change();
}).trigger( 'change' );
});
$( '.show_options_if_checked' ).each( function() {
@ -347,7 +347,7 @@
.nextUntil( '.hide_options_if_checked, .show_options_if_checked', '.hidden_option' )
.hide();
}
}).change();
}).trigger( 'change' );
});
// Reviews.
@ -357,7 +357,7 @@
} else {
$( '#woocommerce_enable_review_rating' ).closest( 'tr' ).hide();
}
}).change();
}).trigger( 'change' );
// Attribute term table
$( 'table.attributes-table tbody tr:nth-child(odd)' ).addClass( 'alternate' );

View File

@ -24,7 +24,7 @@ jQuery( function( $ ) {
})
// Trigger initial click
.find( 'input[name=payment_method]:checked' ).click();
.find( 'input[name=payment_method]:checked' ).trigger( 'click' );
$( '#add_payment_method' ).submit( function() {
$( '#add_payment_method' ).block({ message: null, overlayCSS: { background: '#fff', opacity: 0.6 } });

View File

@ -53,7 +53,7 @@
*/
VariationForm.prototype.onReset = function( event ) {
event.preventDefault();
event.data.variationForm.$attributeFields.val( '' ).change();
event.data.variationForm.$attributeFields.val( '' ).trigger( 'change' );
event.data.variationForm.$form.trigger( 'reset_data' );
};
@ -286,11 +286,11 @@
$template_html = $template_html.replace( '/*]]>*/', '' );
form.$singleVariation.html( $template_html );
form.$form.find( 'input[name="variation_id"], input.variation_id' ).val( variation.variation_id ).change();
form.$form.find( 'input[name="variation_id"], input.variation_id' ).val( variation.variation_id ).trigger( 'change' );
// Hide or show qty input
if ( variation.is_sold_individually === 'yes' ) {
$qty.find( 'input.qty' ).val( '1' ).attr( 'min', '1' ).attr( 'max', '' ).change();
$qty.find( 'input.qty' ).val( '1' ).attr( 'min', '1' ).attr( 'max', '' ).trigger( 'change' );
$qty.hide();
} else {
@ -304,7 +304,7 @@
qty_val = qty_val < parseFloat( variation.min_qty ) ? variation.min_qty : qty_val;
}
$qty_input.attr( 'min', variation.min_qty ).attr( 'max', variation.max_qty ).val( qty_val ).change();
$qty_input.attr( 'min', variation.min_qty ).attr( 'max', variation.max_qty ).val( qty_val ).trigger( 'change' );
$qty.show();
}
@ -314,7 +314,7 @@
}
// Reveal
if ( $.trim( form.$singleVariation.text() ) ) {
if ( form.$singleVariation.text().trim() ) {
form.$singleVariation.slideDown( 200 ).trigger( 'show_variation', [ variation, purchasable ] );
} else {
form.$singleVariation.show().trigger( 'show_variation', [ variation, purchasable ] );
@ -327,7 +327,7 @@
VariationForm.prototype.onChange = function( event ) {
var form = event.data.variationForm;
form.$form.find( 'input[name="variation_id"], input.variation_id' ).val( '' ).change();
form.$form.find( 'input[name="variation_id"], input.variation_id' ).val( '' ).trigger( 'change' );
form.$form.find( '.wc-no-matching-variations' ).remove();
if ( form.useAjax ) {
@ -379,7 +379,7 @@
if ( ! current_attr_select.data( 'attribute_html' ) ) {
var refSelect = current_attr_select.clone();
refSelect.find( 'option' ).removeAttr( 'disabled attached' ).removeAttr( 'selected' );
refSelect.find( 'option' ).prop( 'disabled attached', false ).prop( 'selected', false );
// Legacy data attribute.
current_attr_select.data(
@ -484,7 +484,7 @@
if ( selected_attr_val_valid ) {
current_attr_select.val( selected_attr_val );
} else {
current_attr_select.val( '' ).change();
current_attr_select.val( '' ).trigger( 'change' );
}
} else {
current_attr_select.val( '' ); // No change event to prevent infinite loop.

View File

@ -32,7 +32,7 @@ jQuery( function( $ ) {
// Handle locale
$( document.body )
.bind( 'country_to_state_changing', function( event, country, wrapper ) {
.on( 'country_to_state_changing', function( event, country, wrapper ) {
var thisform = wrapper, thislocale;
if ( typeof locale[ country ] !== 'undefined' ) {

View File

@ -180,6 +180,7 @@ jQuery( function( $ ) {
*/
toggle_shipping: function() {
$( '.shipping-calculator-form' ).slideToggle( 'slow' );
$( 'select.country_to_state, input.country_to_state' ).trigger( 'change' );
$( document.body ).trigger( 'country_to_state_changed' ); // Trigger select2 to load.
return false;
},

View File

@ -16,8 +16,8 @@ jQuery( function( $ ) {
$order_review: $( '#order_review' ),
$checkout_form: $( 'form.checkout' ),
init: function() {
$( document.body ).bind( 'update_checkout', this.update_checkout );
$( document.body ).bind( 'init_checkout', this.init_checkout );
$( document.body ).on( 'update_checkout', this.update_checkout );
$( document.body ).on( 'init_checkout', this.init_checkout );
// Payment methods
this.$checkout_form.on( 'click', 'input[name="payment_method"]', this.payment_method_selected );
@ -50,7 +50,7 @@ jQuery( function( $ ) {
this.$checkout_form.on( 'change', '#ship-to-different-address input', this.ship_to_different_address );
// Trigger events
this.$checkout_form.find( '#ship-to-different-address input' ).change();
this.$checkout_form.find( '#ship-to-different-address input' ).trigger( 'change' );
this.init_payment_methods();
// Update on page load
@ -58,7 +58,7 @@ jQuery( function( $ ) {
$( document.body ).trigger( 'init_checkout' );
}
if ( wc_checkout_params.option_guest_checkout === 'yes' ) {
$( 'input#createaccount' ).change( this.toggle_create_account ).change();
$( 'input#createaccount' ).change( this.toggle_create_account ).trigger( 'change' );
}
},
init_payment_methods: function() {
@ -130,7 +130,7 @@ jQuery( function( $ ) {
if ( $( this ).is( ':checked' ) ) {
// Ensure password is not pre-populated.
$( '#account_password' ).val( '' ).change();
$( '#account_password' ).val( '' ).trigger( 'change' );
$( 'div.create-account' ).slideDown();
}
},
@ -204,10 +204,12 @@ jQuery( function( $ ) {
validated = true,
validate_required = $parent.is( '.validate-required' ),
validate_email = $parent.is( '.validate-email' ),
validate_phone = $parent.is( '.validate-phone' ),
pattern = '',
event_type = e.type;
if ( 'input' === event_type ) {
$parent.removeClass( 'woocommerce-invalid woocommerce-invalid-required-field woocommerce-invalid-email woocommerce-validated' ); // eslint-disable-line max-len
$parent.removeClass( 'woocommerce-invalid woocommerce-invalid-required-field woocommerce-invalid-email woocommerce-invalid-phone woocommerce-validated' ); // eslint-disable-line max-len
}
if ( 'validate' === event_type || 'change' === event_type ) {
@ -225,17 +227,26 @@ jQuery( function( $ ) {
if ( validate_email ) {
if ( $this.val() ) {
/* https://stackoverflow.com/questions/2855865/jquery-validate-e-mail-address-regex */
var pattern = new RegExp(/^([a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+(\.[a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)*|"((([ \t]*\r\n)?[ \t]+)?([\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*(([ \t]*\r\n)?[ \t]+)?")@(([a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.)+([a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[0-9a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.?$/i); // eslint-disable-line max-len
pattern = new RegExp( /^([a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+(\.[a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)*|"((([ \t]*\r\n)?[ \t]+)?([\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*(([ \t]*\r\n)?[ \t]+)?")@(([a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.)+([a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[0-9a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.?$/i ); // eslint-disable-line max-len
if ( ! pattern.test( $this.val() ) ) {
$parent.removeClass( 'woocommerce-validated' ).addClass( 'woocommerce-invalid woocommerce-invalid-email' );
$parent.removeClass( 'woocommerce-validated' ).addClass( 'woocommerce-invalid woocommerce-invalid-email woocommerce-invalid-phone' ); // eslint-disable-line max-len
validated = false;
}
}
}
if ( validate_phone ) {
pattern = new RegExp( /[\s\#0-9_\-\+\/\(\)\.]/g );
if ( 0 < $this.val().replace( pattern, '' ).length ) {
$parent.removeClass( 'woocommerce-validated' ).addClass( 'woocommerce-invalid woocommerce-invalid-phone' );
validated = false;
}
}
if ( validated ) {
$parent.removeClass( 'woocommerce-invalid woocommerce-invalid-required-field woocommerce-invalid-email' ).addClass( 'woocommerce-validated' ); // eslint-disable-line max-len
$parent.removeClass( 'woocommerce-invalid woocommerce-invalid-required-field woocommerce-invalid-email woocommerce-invalid-phone' ).addClass( 'woocommerce-validated' ); // eslint-disable-line max-len
}
}
},
@ -380,11 +391,11 @@ jQuery( function( $ ) {
var ID = $( this ).attr( 'id' );
if ( ID ) {
if ( $.inArray( $( this ).attr( 'type' ), [ 'checkbox', 'radio' ] ) !== -1 ) {
$( this ).prop( 'checked', paymentDetails[ ID ] ).change();
$( this ).prop( 'checked', paymentDetails[ ID ] ).trigger( 'change' );
} else if ( $.inArray( $( this ).attr( 'type' ), [ 'select' ] ) !== -1 ) {
$( this ).val( paymentDetails[ ID ] ).change();
$( this ).val( paymentDetails[ ID ] ).trigger( 'change' );
} else if ( null !== $( this ).val() && 0 === $( this ).val().length ) {
$( this ).val( paymentDetails[ ID ] ).change();
$( this ).val( paymentDetails[ ID ] ).trigger( 'change' );
}
}
});
@ -406,7 +417,7 @@ jQuery( function( $ ) {
}
// Lose focus for all fields
$form.find( '.input-text, select, input:checkbox' ).trigger( 'validate' ).blur();
$form.find( '.input-text, select, input:checkbox' ).trigger( 'validate' ).trigger( 'blur' );
wc_checkout_form.scroll_to_notices();
}
@ -560,7 +571,7 @@ jQuery( function( $ ) {
$( '.woocommerce-NoticeGroup-checkout, .woocommerce-error, .woocommerce-message' ).remove();
wc_checkout_form.$checkout_form.prepend( '<div class="woocommerce-NoticeGroup woocommerce-NoticeGroup-checkout">' + error_message + '</div>' ); // eslint-disable-line max-len
wc_checkout_form.$checkout_form.removeClass( 'processing' ).unblock();
wc_checkout_form.$checkout_form.find( '.input-text, select, input:checkbox' ).trigger( 'validate' ).blur();
wc_checkout_form.$checkout_form.find( '.input-text, select, input:checkbox' ).trigger( 'validate' ).trigger( 'blur' );
wc_checkout_form.scroll_to_notices();
$( document.body ).trigger( 'checkout_error' , [ error_message ] );
},

View File

@ -70,7 +70,7 @@ jQuery( function( $ ) {
wc_country_select_select2();
$( document.body ).bind( 'country_to_state_changed', function() {
$( document.body ).on( 'country_to_state_changed', function() {
wc_country_select_select2();
});
}
@ -142,7 +142,7 @@ jQuery( function( $ ) {
$statebox.append( $option );
} );
$statebox.val( value ).change();
$statebox.val( value ).trigger( 'change' );
$( document.body ).trigger( 'country_to_state_changed', [country, $wrapper ] );
}

View File

@ -1,10 +1,47 @@
/*global wc_geolocation_params */
jQuery( function( $ ) {
/**
* Contains the current geo hash (or false if the hash
* is not set/cannot be determined).
*
* @type {boolean|string}
*/
var geo_hash = false;
var this_page = window.location.toString();
/**
* Obtains the current geo hash from the `woocommerce_geo_hash` cookie, if set.
*
* @returns {boolean}
*/
function get_geo_hash() {
var geo_hash_cookie = Cookies.get( 'woocommerce_geo_hash' );
if ( 'string' === typeof geo_hash_cookie && geo_hash_cookie.length ) {
geo_hash = geo_hash_cookie;
return true;
}
return false;
}
/**
* If we have an active geo hash value but it does not match the `?v=` query var in
* current page URL, that indicates that we need to refresh the page.
*
* @returns {boolean}
*/
function needs_refresh() {
return geo_hash && ( new URLSearchParams( window.location.search ) ).get( 'v' ) !== geo_hash;
}
/**
* Appends (or replaces) the geo hash used for links on the current page.
*/
var $append_hashes = function() {
if ( wc_geolocation_params.hash ) {
if ( ! geo_hash ) {
return;
}
$( 'a[href^="' + wc_geolocation_params.home_url + '"]:not(a[href*="v="]), a[href^="/"]:not(a[href*="v="])' ).each( function() {
var $this = $( this ),
href = $this.attr( 'href' ),
@ -13,9 +50,9 @@ jQuery( function( $ ) {
href = href_parts[0];
if ( href.indexOf( '?' ) > 0 ) {
href = href + '&v=' + wc_geolocation_params.hash;
href = href + '&v=' + geo_hash;
} else {
href = href + '?v=' + wc_geolocation_params.hash;
href = href + '?v=' + geo_hash;
}
if ( typeof href_parts[1] !== 'undefined' && href_parts[1] !== null ) {
@ -24,10 +61,30 @@ jQuery( function( $ ) {
$this.attr( 'href', href );
});
};
var $geolocate_customer = {
url: wc_geolocation_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'get_customer_location' ),
type: 'GET',
success: function( response ) {
if ( response.success && response.data.hash && response.data.hash !== geo_hash ) {
$geolocation_redirect( response.data.hash );
}
}
};
/**
* Once we have a new hash, we redirect so a new version of the current page
* (with correct pricing for the current region, etc) is displayed.
*
* @param {string} hash
*/
var $geolocation_redirect = function( hash ) {
// Updates our (cookie-based) cache of the hash value. Expires in 1 hour.
Cookies.set( 'woocommerce_geo_hash', hash, { expires: 1 / 24 } );
var this_page = window.location.toString();
if ( this_page.indexOf( '?v=' ) > 0 || this_page.indexOf( '&v=' ) > 0 ) {
this_page = this_page.replace( /v=[^&]+/, 'v=' + hash );
} else if ( this_page.indexOf( '?' ) > 0 ) {
@ -39,43 +96,44 @@ jQuery( function( $ ) {
window.location = this_page;
};
var $geolocate_customer = {
url: wc_geolocation_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'get_customer_location' ),
type: 'GET',
success: function( response ) {
if ( response.success && response.data.hash && response.data.hash !== wc_geolocation_params.hash ) {
$geolocation_redirect( response.data.hash );
/**
* Updates any forms on the page so they use the current geo hash.
*/
function update_forms() {
if ( ! geo_hash ) {
return;
}
}
};
if ( '1' === wc_geolocation_params.is_available ) {
$.ajax( $geolocate_customer );
// Support form elements
$( 'form' ).each( function() {
$( 'form' ).each( function () {
var $this = $( this );
var method = $this.attr( 'method' );
var hasField = $this.find('input[name="v"]').length > 0;
var hasField = $this.find( 'input[name="v"]' ).length > 0;
if ( method && 'get' === method.toLowerCase() && !hasField ) {
$this.append( '<input type="hidden" name="v" value="' + wc_geolocation_params.hash + '" />' );
if ( method && 'get' === method.toLowerCase() && ! hasField ) {
$this.append( '<input type="hidden" name="v" value="' + geo_hash + '" />' );
} else {
var href = $this.attr( 'action' );
if ( href ) {
if ( href.indexOf( '?' ) > 0 ) {
$this.attr( 'action', href + '&v=' + wc_geolocation_params.hash );
$this.attr( 'action', href + '&v=' + geo_hash );
} else {
$this.attr( 'action', href + '?v=' + wc_geolocation_params.hash );
$this.attr( 'action', href + '?v=' + geo_hash );
}
}
}
});
// Append hashes on load
$append_hashes();
}
// Get the current geo hash. If it doesn't exist, or if it doesn't match the current
// page URL, perform a geolocation request.
if ( ! get_geo_hash() || needs_refresh() ) {
$.ajax( $geolocate_customer );
}
// Page updates.
update_forms();
$append_hashes();
$( document.body ).on( 'added_to_cart', function() {
$append_hashes();
});
@ -84,5 +142,4 @@ jQuery( function( $ ) {
$( document.body ).on( 'woocommerce_append_geo_hashes', function() {
$append_hashes();
});
});

View File

@ -17,7 +17,7 @@
'form.edit-account #password_1, form.lost_reset_password #password_1',
this.strengthMeter
);
$( 'form.checkout #createaccount' ).change();
$( 'form.checkout #createaccount' ).trigger( 'change' );
},
/**

View File

@ -76,7 +76,7 @@ jQuery( function( $ ) {
wp.customize.widgetsPreview.WidgetPartial
);
if ( hasSelectiveRefresh ) {
wp.customize.selectiveRefresh.on( 'partial-content-rendered', function() {
wp.customize.selectiveRefresh.bind( 'partial-content-rendered', function() {
init_price_filter();
} );
}

View File

@ -16,13 +16,13 @@ jQuery( function( $ ) {
var $tabs = $( this ).find( '.wc-tabs, ul.tabs' ).first();
if ( hash.toLowerCase().indexOf( 'comment-' ) >= 0 || hash === '#reviews' || hash === '#tab-reviews' ) {
$tabs.find( 'li.reviews_tab a' ).click();
$tabs.find( 'li.reviews_tab a' ).trigger( 'click' );
} else if ( url.indexOf( 'comment-page-' ) > 0 || url.indexOf( 'cpage=' ) > 0 ) {
$tabs.find( 'li.reviews_tab a' ).click();
$tabs.find( 'li.reviews_tab a' ).trigger( 'click' );
} else if ( hash === '#tab-additional_information' ) {
$tabs.find( 'li.additional_information_tab a' ).click();
$tabs.find( 'li.additional_information_tab a' ).trigger( 'click' );
} else {
$tabs.find( 'li:first a' ).click();
$tabs.find( 'li:first a' ).trigger( 'click' );
}
} )
.on( 'click', '.wc-tabs li a, ul.tabs li a', function( e ) {
@ -39,7 +39,7 @@ jQuery( function( $ ) {
} )
// Review link
.on( 'click', 'a.woocommerce-review-link', function() {
$( '.reviews_tab a' ).click();
$( '.reviews_tab a' ).trigger( 'click' );
return true;
} )
// Star ratings for comments
@ -101,8 +101,8 @@ jQuery( function( $ ) {
$target.data( 'product_gallery', this );
// Pick functionality to initialize...
this.flexslider_enabled = $.isFunction( $.fn.flexslider ) && wc_single_product_params.flexslider_enabled;
this.zoom_enabled = $.isFunction( $.fn.zoom ) && wc_single_product_params.zoom_enabled;
this.flexslider_enabled = 'function' === typeof $.fn.flexslider && wc_single_product_params.flexslider_enabled;
this.zoom_enabled = 'function' === typeof $.fn.zoom && wc_single_product_params.zoom_enabled;
this.photoswipe_enabled = typeof PhotoSwipe !== 'undefined' && wc_single_product_params.photoswipe_enabled;
// ...also taking args into account.

View File

@ -2,7 +2,7 @@
jQuery( function( $ ) {
// Orderby
$( '.woocommerce-ordering' ).on( 'change', 'select.orderby', function() {
$( this ).closest( 'form' ).submit();
$( this ).closest( 'form' ).trigger( 'submit' );
});
// Target quantity inputs on product pages

View File

@ -10,7 +10,7 @@ rm -rf "$BUILD_PATH"
mkdir -p "$DEST_PATH"
echo "Installing PHP and JS dependencies..."
npm install
npm run install:no-e2e
composer install || exit "$?"
echo "Running JS Build..."
npm run build:core || exit "$?"

View File

@ -4,7 +4,7 @@
},
"config": {
"platform": {
"php": "7.2"
"php": "7.3"
}
}
}

View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "cbcce1648bdb890ae805e1afb7396e3c",
"content-hash": "53c40e5764ce9bbe304e6aee0508ccb7",
"packages": [],
"packages-dev": [
{
@ -13,26 +13,26 @@
"source": {
"type": "git",
"url": "https://github.com/coenjacobs/mozart.git",
"reference": "5d8041fdefc94ff57edcbe83ab468a9988c4fc11"
"reference": "3b1243ca8505fa6436569800dc34269178930f39"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/coenjacobs/mozart/zipball/5d8041fdefc94ff57edcbe83ab468a9988c4fc11",
"reference": "5d8041fdefc94ff57edcbe83ab468a9988c4fc11",
"url": "https://api.github.com/repos/coenjacobs/mozart/zipball/3b1243ca8505fa6436569800dc34269178930f39",
"reference": "3b1243ca8505fa6436569800dc34269178930f39",
"shasum": ""
},
"require": {
"league/flysystem": "^1.0",
"php": "^7.2",
"php": "^7.3|^8.0",
"symfony/console": "^4|^5",
"symfony/finder": "^4|^5"
},
"require-dev": {
"mheap/phpunit-github-actions-printer": "^1.4",
"phpunit/phpunit": "^8.5",
"squizlabs/php_codesniffer": "^3.5"
"squizlabs/php_codesniffer": "^3.5",
"vimeo/psalm": "^4.4"
},
"default-branch": true,
"bin": [
"bin/mozart"
],
@ -53,42 +53,39 @@
}
],
"description": "Composes all dependencies as a package inside a WordPress plugin",
"support": {
"issues": "https://github.com/coenjacobs/mozart/issues",
"source": "https://github.com/coenjacobs/mozart/tree/master"
},
"funding": [
{
"url": "https://github.com/coenjacobs",
"type": "github"
}
],
"time": "2020-11-23T21:03:43+00:00"
"time": "2021-02-04T20:20:50+00:00"
},
{
"name": "league/flysystem",
"version": "1.0.70",
"version": "1.1.3",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/flysystem.git",
"reference": "585824702f534f8d3cf7fab7225e8466cc4b7493"
"reference": "9be3b16c877d477357c015cec057548cf9b2a14a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/585824702f534f8d3cf7fab7225e8466cc4b7493",
"reference": "585824702f534f8d3cf7fab7225e8466cc4b7493",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/9be3b16c877d477357c015cec057548cf9b2a14a",
"reference": "9be3b16c877d477357c015cec057548cf9b2a14a",
"shasum": ""
},
"require": {
"ext-fileinfo": "*",
"php": ">=5.5.9"
"league/mime-type-detection": "^1.3",
"php": "^7.2.5 || ^8.0"
},
"conflict": {
"league/flysystem-sftp": "<1.0.6"
},
"require-dev": {
"phpspec/phpspec": "^3.4 || ^4.0 || ^5.0 || ^6.0",
"phpunit/phpunit": "^5.7.26"
"phpspec/prophecy": "^1.11.1",
"phpunit/phpunit": "^8.5.8"
},
"suggest": {
"ext-fileinfo": "Required for MimeType",
@ -147,41 +144,84 @@
"sftp",
"storage"
],
"support": {
"issues": "https://github.com/thephpleague/flysystem/issues",
"source": "https://github.com/thephpleague/flysystem/tree/1.0.70"
},
"funding": [
{
"url": "https://offset.earth/frankdejonge",
"type": "other"
}
],
"time": "2020-07-26T07:20:36+00:00"
"time": "2020-08-23T07:39:11+00:00"
},
{
"name": "psr/container",
"version": "1.0.0",
"name": "league/mime-type-detection",
"version": "1.7.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/container.git",
"reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f"
"url": "https://github.com/thephpleague/mime-type-detection.git",
"reference": "3b9dff8aaf7323590c1d2e443db701eb1f9aa0d3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
"reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
"url": "https://api.github.com/repos/thephpleague/mime-type-detection/zipball/3b9dff8aaf7323590c1d2e443db701eb1f9aa0d3",
"reference": "3b9dff8aaf7323590c1d2e443db701eb1f9aa0d3",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
"ext-fileinfo": "*",
"php": "^7.2 || ^8.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.18",
"phpstan/phpstan": "^0.12.68",
"phpunit/phpunit": "^8.5.8 || ^9.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
"autoload": {
"psr-4": {
"League\\MimeTypeDetection\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Frank de Jonge",
"email": "info@frankdejonge.nl"
}
],
"description": "Mime-type detection for Flysystem",
"funding": [
{
"url": "https://github.com/frankdejonge",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/league/flysystem",
"type": "tidelift"
}
],
"time": "2021-01-18T20:58:21+00:00"
},
{
"name": "psr/container",
"version": "1.1.1",
"source": {
"type": "git",
"url": "https://github.com/php-fig/container.git",
"reference": "8622567409010282b7aeebe4bb841fe98b58dcaf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/container/zipball/8622567409010282b7aeebe4bb841fe98b58dcaf",
"reference": "8622567409010282b7aeebe4bb841fe98b58dcaf",
"shasum": ""
},
"require": {
"php": ">=7.2.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Psr\\Container\\": "src/"
@ -194,7 +234,7 @@
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common Container Interface (PHP FIG PSR-11)",
@ -206,50 +246,48 @@
"container-interop",
"psr"
],
"support": {
"issues": "https://github.com/php-fig/container/issues",
"source": "https://github.com/php-fig/container/tree/master"
},
"time": "2017-02-14T16:28:37+00:00"
"time": "2021-03-05T17:36:06+00:00"
},
{
"name": "symfony/console",
"version": "v4.4.18",
"version": "v5.2.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "12e071278e396cc3e1c149857337e9e192deca0b"
"reference": "d6d0cc30d8c0fda4e7b213c20509b0159a8f4556"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/12e071278e396cc3e1c149857337e9e192deca0b",
"reference": "12e071278e396cc3e1c149857337e9e192deca0b",
"url": "https://api.github.com/repos/symfony/console/zipball/d6d0cc30d8c0fda4e7b213c20509b0159a8f4556",
"reference": "d6d0cc30d8c0fda4e7b213c20509b0159a8f4556",
"shasum": ""
},
"require": {
"php": ">=7.1.3",
"php": ">=7.2.5",
"symfony/polyfill-mbstring": "~1.0",
"symfony/polyfill-php73": "^1.8",
"symfony/polyfill-php80": "^1.15",
"symfony/service-contracts": "^1.1|^2"
"symfony/service-contracts": "^1.1|^2",
"symfony/string": "^5.1"
},
"conflict": {
"symfony/dependency-injection": "<3.4",
"symfony/event-dispatcher": "<4.3|>=5",
"symfony/dependency-injection": "<4.4",
"symfony/dotenv": "<5.1",
"symfony/event-dispatcher": "<4.4",
"symfony/lock": "<4.4",
"symfony/process": "<3.3"
"symfony/process": "<4.4"
},
"provide": {
"psr/log-implementation": "1.0"
},
"require-dev": {
"psr/log": "~1.0",
"symfony/config": "^3.4|^4.0|^5.0",
"symfony/dependency-injection": "^3.4|^4.0|^5.0",
"symfony/event-dispatcher": "^4.3",
"symfony/config": "^4.4|^5.0",
"symfony/dependency-injection": "^4.4|^5.0",
"symfony/event-dispatcher": "^4.4|^5.0",
"symfony/lock": "^4.4|^5.0",
"symfony/process": "^3.4|^4.0|^5.0",
"symfony/var-dumper": "^4.3|^5.0"
"symfony/process": "^4.4|^5.0",
"symfony/var-dumper": "^4.4|^5.0"
},
"suggest": {
"psr/log": "For using the console logger",
@ -280,11 +318,14 @@
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Console Component",
"description": "Eases the creation of beautiful and testable command line interfaces",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/console/tree/v4.4.18"
},
"keywords": [
"cli",
"command line",
"console",
"terminal"
],
"funding": [
{
"url": "https://symfony.com/sponsor",
@ -299,24 +340,24 @@
"type": "tidelift"
}
],
"time": "2020-12-18T07:41:31+00:00"
"time": "2021-02-23T10:08:49+00:00"
},
{
"name": "symfony/finder",
"version": "v4.4.18",
"version": "v5.2.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "ebd0965f2dc2d4e0f11487c16fbb041e50b5c09b"
"reference": "0d639a0943822626290d169965804f79400e6a04"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/ebd0965f2dc2d4e0f11487c16fbb041e50b5c09b",
"reference": "ebd0965f2dc2d4e0f11487c16fbb041e50b5c09b",
"url": "https://api.github.com/repos/symfony/finder/zipball/0d639a0943822626290d169965804f79400e6a04",
"reference": "0d639a0943822626290d169965804f79400e6a04",
"shasum": ""
},
"require": {
"php": ">=7.1.3"
"php": ">=7.2.5"
},
"type": "library",
"autoload": {
@ -341,11 +382,8 @@
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Finder Component",
"description": "Finds files and directories via an intuitive fluent interface",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/finder/tree/v4.4.18"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
@ -360,20 +398,255 @@
"type": "tidelift"
}
],
"time": "2020-12-08T16:59:59+00:00"
"time": "2021-02-15T18:55:04+00:00"
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.20.0",
"name": "symfony/polyfill-ctype",
"version": "v1.22.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "39d483bdf39be819deabf04ec872eb0b2410b531"
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "c6c942b1ac76c82448322025e084cadc56048b4e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/39d483bdf39be819deabf04ec872eb0b2410b531",
"reference": "39d483bdf39be819deabf04ec872eb0b2410b531",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/c6c942b1ac76c82448322025e084cadc56048b4e",
"reference": "c6c942b1ac76c82448322025e084cadc56048b4e",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"suggest": {
"ext-ctype": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.22-dev"
},
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Ctype\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Gert de Pagter",
"email": "BackEndTea@gmail.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for ctype functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"ctype",
"polyfill",
"portable"
],
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2021-01-07T16:49:33+00:00"
},
{
"name": "symfony/polyfill-intl-grapheme",
"version": "v1.22.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-grapheme.git",
"reference": "5601e09b69f26c1828b13b6bb87cb07cddba3170"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/5601e09b69f26c1828b13b6bb87cb07cddba3170",
"reference": "5601e09b69f26c1828b13b6bb87cb07cddba3170",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"suggest": {
"ext-intl": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.22-dev"
},
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Intl\\Grapheme\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for intl's grapheme_* functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"grapheme",
"intl",
"polyfill",
"portable",
"shim"
],
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2021-01-22T09:19:47+00:00"
},
{
"name": "symfony/polyfill-intl-normalizer",
"version": "v1.22.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-normalizer.git",
"reference": "43a0283138253ed1d48d352ab6d0bdb3f809f248"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/43a0283138253ed1d48d352ab6d0bdb3f809f248",
"reference": "43a0283138253ed1d48d352ab6d0bdb3f809f248",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"suggest": {
"ext-intl": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.22-dev"
},
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Intl\\Normalizer\\": ""
},
"files": [
"bootstrap.php"
],
"classmap": [
"Resources/stubs"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for intl's Normalizer class and related functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"intl",
"normalizer",
"polyfill",
"portable",
"shim"
],
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2021-01-22T09:19:47+00:00"
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.22.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "5232de97ee3b75b0360528dae24e73db49566ab1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/5232de97ee3b75b0360528dae24e73db49566ab1",
"reference": "5232de97ee3b75b0360528dae24e73db49566ab1",
"shasum": ""
},
"require": {
@ -385,7 +658,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.20-dev"
"dev-main": "1.22-dev"
},
"thanks": {
"name": "symfony/polyfill",
@ -423,9 +696,6 @@
"portable",
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.20.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
@ -440,20 +710,20 @@
"type": "tidelift"
}
],
"time": "2020-10-23T14:02:19+00:00"
"time": "2021-01-22T09:19:47+00:00"
},
{
"name": "symfony/polyfill-php73",
"version": "v1.20.0",
"version": "v1.22.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php73.git",
"reference": "8ff431c517be11c78c48a39a66d37431e26a6bed"
"reference": "a678b42e92f86eca04b7fa4c0f6f19d097fb69e2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/8ff431c517be11c78c48a39a66d37431e26a6bed",
"reference": "8ff431c517be11c78c48a39a66d37431e26a6bed",
"url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/a678b42e92f86eca04b7fa4c0f6f19d097fb69e2",
"reference": "a678b42e92f86eca04b7fa4c0f6f19d097fb69e2",
"shasum": ""
},
"require": {
@ -462,7 +732,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.20-dev"
"dev-main": "1.22-dev"
},
"thanks": {
"name": "symfony/polyfill",
@ -502,9 +772,6 @@
"portable",
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-php73/tree/v1.20.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
@ -519,20 +786,20 @@
"type": "tidelift"
}
],
"time": "2020-10-23T14:02:19+00:00"
"time": "2021-01-07T16:49:33+00:00"
},
{
"name": "symfony/polyfill-php80",
"version": "v1.20.0",
"version": "v1.22.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php80.git",
"reference": "e70aa8b064c5b72d3df2abd5ab1e90464ad009de"
"reference": "dc3063ba22c2a1fd2f45ed856374d79114998f91"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/e70aa8b064c5b72d3df2abd5ab1e90464ad009de",
"reference": "e70aa8b064c5b72d3df2abd5ab1e90464ad009de",
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/dc3063ba22c2a1fd2f45ed856374d79114998f91",
"reference": "dc3063ba22c2a1fd2f45ed856374d79114998f91",
"shasum": ""
},
"require": {
@ -541,7 +808,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.20-dev"
"dev-main": "1.22-dev"
},
"thanks": {
"name": "symfony/polyfill",
@ -585,9 +852,6 @@
"portable",
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-php80/tree/v1.20.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
@ -602,24 +866,24 @@
"type": "tidelift"
}
],
"time": "2020-10-23T14:02:19+00:00"
"time": "2021-01-07T16:49:33+00:00"
},
{
"name": "symfony/service-contracts",
"version": "v1.1.9",
"version": "v2.2.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/service-contracts.git",
"reference": "b776d18b303a39f56c63747bcb977ad4b27aca26"
"reference": "d15da7ba4957ffb8f1747218be9e1a121fd298a1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/service-contracts/zipball/b776d18b303a39f56c63747bcb977ad4b27aca26",
"reference": "b776d18b303a39f56c63747bcb977ad4b27aca26",
"url": "https://api.github.com/repos/symfony/service-contracts/zipball/d15da7ba4957ffb8f1747218be9e1a121fd298a1",
"reference": "d15da7ba4957ffb8f1747218be9e1a121fd298a1",
"shasum": ""
},
"require": {
"php": ">=7.1.3",
"php": ">=7.2.5",
"psr/container": "^1.0"
},
"suggest": {
@ -628,7 +892,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.1-dev"
"dev-master": "2.2-dev"
},
"thanks": {
"name": "symfony/contracts",
@ -664,9 +928,6 @@
"interoperability",
"standards"
],
"support": {
"source": "https://github.com/symfony/service-contracts/tree/v1.1.9"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
@ -681,7 +942,87 @@
"type": "tidelift"
}
],
"time": "2020-07-06T13:19:58+00:00"
"time": "2020-09-07T11:33:47+00:00"
},
{
"name": "symfony/string",
"version": "v5.2.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/string.git",
"reference": "4e78d7d47061fa183639927ec40d607973699609"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/string/zipball/4e78d7d47061fa183639927ec40d607973699609",
"reference": "4e78d7d47061fa183639927ec40d607973699609",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
"symfony/polyfill-ctype": "~1.8",
"symfony/polyfill-intl-grapheme": "~1.0",
"symfony/polyfill-intl-normalizer": "~1.0",
"symfony/polyfill-mbstring": "~1.0",
"symfony/polyfill-php80": "~1.15"
},
"require-dev": {
"symfony/error-handler": "^4.4|^5.0",
"symfony/http-client": "^4.4|^5.0",
"symfony/translation-contracts": "^1.1|^2",
"symfony/var-exporter": "^4.4|^5.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Symfony\\Component\\String\\": ""
},
"files": [
"Resources/functions.php"
],
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way",
"homepage": "https://symfony.com",
"keywords": [
"grapheme",
"i18n",
"string",
"unicode",
"utf-8",
"utf8"
],
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2021-02-16T10:20:28+00:00"
}
],
"aliases": [],
@ -694,7 +1035,7 @@
"platform": [],
"platform-dev": [],
"platform-overrides": {
"php": "7.2"
"php": "7.3"
},
"plugin-api-version": "2.0.0"
"plugin-api-version": "1.1.0"
}

View File

@ -133,28 +133,28 @@
},
{
"name": "phpcompatibility/phpcompatibility-paragonie",
"version": "1.3.0",
"version": "1.3.1",
"source": {
"type": "git",
"url": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie.git",
"reference": "b862bc32f7e860d0b164b199bd995e690b4b191c"
"reference": "ddabec839cc003651f2ce695c938686d1086cf43"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityParagonie/zipball/b862bc32f7e860d0b164b199bd995e690b4b191c",
"reference": "b862bc32f7e860d0b164b199bd995e690b4b191c",
"url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityParagonie/zipball/ddabec839cc003651f2ce695c938686d1086cf43",
"reference": "ddabec839cc003651f2ce695c938686d1086cf43",
"shasum": ""
},
"require": {
"phpcompatibility/php-compatibility": "^9.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.5",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7",
"paragonie/random_compat": "dev-master",
"paragonie/sodium_compat": "dev-master"
},
"suggest": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.",
"roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues."
},
"type": "phpcodesniffer-standard",
@ -181,7 +181,7 @@
"polyfill",
"standards"
],
"time": "2019-11-04T15:17:54+00:00"
"time": "2021-02-15T10:24:51+00:00"
},
{
"name": "phpcompatibility/phpcompatibility-wp",
@ -282,11 +282,6 @@
"phpcs",
"standards"
],
"support": {
"issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues",
"source": "https://github.com/squizlabs/PHP_CodeSniffer",
"wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki"
},
"time": "2020-10-23T02:01:07+00:00"
},
{

View File

@ -59,10 +59,6 @@
"constructor",
"instantiate"
],
"support": {
"issues": "https://github.com/doctrine/instantiator/issues",
"source": "https://github.com/doctrine/instantiator/tree/master"
},
"time": "2015-06-14T21:17:01+00:00"
},
{
@ -108,10 +104,6 @@
"object",
"object graph"
],
"support": {
"issues": "https://github.com/myclabs/DeepCopy/issues",
"source": "https://github.com/myclabs/DeepCopy/tree/1.x"
},
"time": "2017-10-19T19:58:43+00:00"
},
{
@ -167,10 +159,6 @@
}
],
"description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)",
"support": {
"issues": "https://github.com/phar-io/manifest/issues",
"source": "https://github.com/phar-io/manifest/tree/master"
},
"time": "2017-03-05T18:14:27+00:00"
},
{
@ -218,10 +206,6 @@
}
],
"description": "Library for handling version information and constraints",
"support": {
"issues": "https://github.com/phar-io/version/issues",
"source": "https://github.com/phar-io/version/tree/master"
},
"time": "2017-03-05T17:38:23+00:00"
},
{
@ -276,10 +260,6 @@
"reflection",
"static analysis"
],
"support": {
"issues": "https://github.com/phpDocumentor/ReflectionCommon/issues",
"source": "https://github.com/phpDocumentor/ReflectionCommon/tree/master"
},
"time": "2017-09-11T18:02:19+00:00"
},
{
@ -377,10 +357,6 @@
"email": "me@mikevanriel.com"
}
],
"support": {
"issues": "https://github.com/phpDocumentor/TypeResolver/issues",
"source": "https://github.com/phpDocumentor/TypeResolver/tree/master"
},
"time": "2017-12-30T13:23:38+00:00"
},
{
@ -507,10 +483,6 @@
"testing",
"xunit"
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/5.3"
},
"time": "2018-04-06T15:36:58+00:00"
},
{
@ -558,11 +530,6 @@
"filesystem",
"iterator"
],
"support": {
"irc": "irc://irc.freenode.net/phpunit",
"issues": "https://github.com/sebastianbergmann/php-file-iterator/issues",
"source": "https://github.com/sebastianbergmann/php-file-iterator/tree/1.4.5"
},
"time": "2017-11-27T13:52:08+00:00"
},
{
@ -653,10 +620,6 @@
"keywords": [
"timer"
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-timer/issues",
"source": "https://github.com/sebastianbergmann/php-timer/tree/master"
},
"time": "2017-02-26T11:10:40+00:00"
},
{
@ -706,10 +669,6 @@
"keywords": [
"tokenizer"
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-token-stream/issues",
"source": "https://github.com/sebastianbergmann/php-token-stream/tree/master"
},
"abandoned": true,
"time": "2017-11-27T05:48:46+00:00"
},
@ -795,10 +754,6 @@
"testing",
"xunit"
],
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"source": "https://github.com/sebastianbergmann/phpunit/tree/6.5.14"
},
"time": "2019-02-01T05:22:47+00:00"
},
{
@ -858,10 +813,6 @@
"mock",
"xunit"
],
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit-mock-objects/issues",
"source": "https://github.com/sebastianbergmann/phpunit-mock-objects/tree/5.0.10"
},
"abandoned": true,
"time": "2018-08-09T05:50:03+00:00"
},
@ -908,10 +859,6 @@
],
"description": "Looks up which function or method a line of code belongs to",
"homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/",
"support": {
"issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues",
"source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/1.0.2"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
@ -982,10 +929,6 @@
"compare",
"equality"
],
"support": {
"issues": "https://github.com/sebastianbergmann/comparator/issues",
"source": "https://github.com/sebastianbergmann/comparator/tree/master"
},
"time": "2018-02-01T13:46:46+00:00"
},
{
@ -1038,10 +981,6 @@
"keywords": [
"diff"
],
"support": {
"issues": "https://github.com/sebastianbergmann/diff/issues",
"source": "https://github.com/sebastianbergmann/diff/tree/master"
},
"time": "2017-08-03T08:09:46+00:00"
},
{
@ -1092,10 +1031,6 @@
"environment",
"hhvm"
],
"support": {
"issues": "https://github.com/sebastianbergmann/environment/issues",
"source": "https://github.com/sebastianbergmann/environment/tree/master"
},
"time": "2017-07-01T08:51:00+00:00"
},
{
@ -1163,10 +1098,6 @@
"export",
"exporter"
],
"support": {
"issues": "https://github.com/sebastianbergmann/exporter/issues",
"source": "https://github.com/sebastianbergmann/exporter/tree/3.1.3"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
@ -1271,10 +1202,6 @@
],
"description": "Traverses array structures and object graphs to enumerate all referenced objects",
"homepage": "https://github.com/sebastianbergmann/object-enumerator/",
"support": {
"issues": "https://github.com/sebastianbergmann/object-enumerator/issues",
"source": "https://github.com/sebastianbergmann/object-enumerator/tree/3.0.4"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
@ -1326,10 +1253,6 @@
],
"description": "Allows reflection of object attributes, including inherited and non-public ones",
"homepage": "https://github.com/sebastianbergmann/object-reflector/",
"support": {
"issues": "https://github.com/sebastianbergmann/object-reflector/issues",
"source": "https://github.com/sebastianbergmann/object-reflector/tree/1.1.2"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
@ -1389,10 +1312,6 @@
],
"description": "Provides functionality to recursively process PHP variables",
"homepage": "http://www.github.com/sebastianbergmann/recursion-context",
"support": {
"issues": "https://github.com/sebastianbergmann/recursion-context/issues",
"source": "https://github.com/sebastianbergmann/recursion-context/tree/3.0.1"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
@ -1441,10 +1360,6 @@
],
"description": "Provides a list of PHP built-in functions that operate on resources",
"homepage": "https://www.github.com/sebastianbergmann/resource-operations",
"support": {
"issues": "https://github.com/sebastianbergmann/resource-operations/issues",
"source": "https://github.com/sebastianbergmann/resource-operations/tree/master"
},
"time": "2015-07-28T20:34:47+00:00"
},
{
@ -1550,9 +1465,6 @@
"polyfill",
"portable"
],
"support": {
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.19.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
@ -1614,12 +1526,12 @@
"version": "1.9.1",
"source": {
"type": "git",
"url": "https://github.com/webmozart/assert.git",
"url": "https://github.com/webmozarts/assert.git",
"reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/webmozart/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389",
"url": "https://api.github.com/repos/webmozarts/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389",
"reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389",
"shasum": ""
},

View File

@ -67,11 +67,6 @@
"po",
"translation"
],
"support": {
"email": "oom@oscarotero.com",
"issues": "https://github.com/oscarotero/Gettext/issues",
"source": "https://github.com/php-gettext/Gettext/tree/v4.8.3"
},
"time": "2020-11-18T22:35:49+00:00"
},
{
@ -322,9 +317,6 @@
],
"description": "Symfony Finder Component",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/finder/tree/3.3"
},
"time": "2017-06-01T21:01:25+00:00"
},
{
@ -434,16 +426,16 @@
},
{
"name": "wp-cli/php-cli-tools",
"version": "v0.11.11",
"version": "v0.11.12",
"source": {
"type": "git",
"url": "https://github.com/wp-cli/php-cli-tools.git",
"reference": "fe9c7c44a9e1bf2196ec51dc38da0593dbf2993f"
"reference": "e472e08489f7504d9e8c5c5a057e1419cd1b2b3e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/wp-cli/php-cli-tools/zipball/fe9c7c44a9e1bf2196ec51dc38da0593dbf2993f",
"reference": "fe9c7c44a9e1bf2196ec51dc38da0593dbf2993f",
"url": "https://api.github.com/repos/wp-cli/php-cli-tools/zipball/e472e08489f7504d9e8c5c5a057e1419cd1b2b3e",
"reference": "e472e08489f7504d9e8c5c5a057e1419cd1b2b3e",
"shasum": ""
},
"require": {
@ -463,15 +455,15 @@
"MIT"
],
"authors": [
{
"name": "James Logsdon",
"email": "jlogsdon@php.net",
"role": "Developer"
},
{
"name": "Daniel Bachhuber",
"email": "daniel@handbuilt.co",
"role": "Maintainer"
},
{
"name": "James Logsdon",
"email": "jlogsdon@php.net",
"role": "Developer"
}
],
"description": "Console utilities for PHP",
@ -480,7 +472,7 @@
"cli",
"console"
],
"time": "2018-09-04T13:28:00+00:00"
"time": "2021-03-03T12:43:49+00:00"
},
{
"name": "wp-cli/wp-cli",

View File

@ -25,17 +25,19 @@ output 3 "Updating autoloader classmaps..."
composer dump-autoload
output 2 "Done"
# Convert textdomains
output 3 "Updating package PHP textdomains..."
if [ -z "$SKIP_UPDATE_TEXTDOMAINS" ]; then
# Convert textdomains
output 3 "Updating package PHP textdomains..."
# Replace text domains within packages with woocommerce
npm run packages:fix:textdomain
output 2 "Done!"
# Replace text domains within packages with woocommerce
npm run packages:fix:textdomain
output 2 "Done!"
output 3 "Updating package JS textdomains..."
find ./packages/woocommerce-blocks -iname '*.js' -exec sed -i.bak -e "s/'woo-gutenberg-products-block'/'woocommerce'/g" -e "s/\"woo-gutenberg-products-block\"/'woocommerce'/g" {} \;
find ./packages/woocommerce-blocks -iname '*.js' -exec sed -i.bak -e "s/'woocommerce-admin'/'woocommerce'/g" -e "s/\"woocommerce-admin\"/'woocommerce'/g" {} \;
find ./packages/woocommerce-admin -iname '*.js' -exec sed -i.bak -e "s/'woocommerce-admin'/'woocommerce'/g" -e "s/\"woocommerce-admin\"/'woocommerce'/g" {} \;
output 3 "Updating package JS textdomains..."
find ./packages/woocommerce-blocks -iname '*.js' -exec sed -i.bak -e "s/'woo-gutenberg-products-block'/'woocommerce'/g" -e "s/\"woo-gutenberg-products-block\"/'woocommerce'/g" {} \;
find ./packages/woocommerce-blocks -iname '*.js' -exec sed -i.bak -e "s/'woocommerce-admin'/'woocommerce'/g" -e "s/\"woocommerce-admin\"/'woocommerce'/g" {} \;
find ./packages/woocommerce-admin -iname '*.js' -exec sed -i.bak -e "s/'woocommerce-admin'/'woocommerce'/g" -e "s/\"woocommerce-admin\"/'woocommerce'/g" {} \;
fi
# Cleanup backup files
find ./packages -name "*.bak" -type f -delete

View File

@ -9,5 +9,5 @@ runOnChange() {
fi
}
runOnChange "package-lock.json" "npm install"
runOnChange "composer.lock" "composer install"
runOnChange "package-lock.json" "npm run install:no-e2e"
runOnChange "composer.lock" "SKIP_UPDATE_TEXTDOMAINS=true composer install"

View File

@ -1,26 +1,26 @@
#!/bin/sh
PROTECTED_BRANCH="master"
PROTECTED_BRANCH="trunk"
REMOTE_REF=$(echo "$HUSKY_GIT_STDIN" | cut -d " " -f 3)
if [ -n "$REMOTE_REF" ]; then
if [ "refs/heads/${PROTECTED_BRANCH}" = "$REMOTE_REF" ]; then
if [ "$TERM" = "dumb" ]; then
>&2 echo "Sorry, you are unable to push to master using a GUI client! Please use git CLI."
>&2 echo "Sorry, you are unable to push to trunk using a GUI client! Please use git CLI."
exit 1
fi
printf "%sYou're about to push to master, is that what you intended? [y/N]: %s" "$(tput setaf 3)" "$(tput sgr0)"
printf "%sYou're about to push to trunk, is that what you intended? [y/N]: %s" "$(tput setaf 3)" "$(tput sgr0)"
read -r PROCEED < /dev/tty
echo
if [ "$(echo "${PROCEED:-n}" | tr "[:upper:]" "[:lower:]")" = "y" ]; then
echo "$(tput setaf 2)Brace yourself! Pushing to the master branch...$(tput sgr0)"
echo "$(tput setaf 2)Brace yourself! Pushing to the trunk branch...$(tput sgr0)"
echo
exit 0
fi
echo "$(tput setaf 2)Push to master cancelled!$(tput sgr0)"
echo "$(tput setaf 2)Push to trunk cancelled!$(tput sgr0)"
echo
exit 1
fi

View File

@ -1,5 +1,180 @@
== Changelog ==
= 5.1.0 2021-03-09 =
**WooCommerce**
* Update - WooCommerce Admin package 2.0.2. #29229
* Update - WooCommerce Blocks package 4.4.3. #29016
* Fix - Error in notice message of reports when WC Admin is disabled via a filter. #29095
* Fix - Error when calculating orders with tax option rounding at subtotal level in PHP 8. #29089
* Fix - price filtering not working properly with variable products whose variations have different prices. #29043
* Fix - Removed extra closing brace from the Zone regions help text. #29036
* Fix - Tax name/label is not being updated in the order when it is changed. #28983
* Fix - Additional protection after wc_get_product to account for invalid ID. #28962
* Fix - orders list from returning false values if orders are missing. #28927
* Fix - Terms and Policy checkbox wording settings not shown in customizer. #28735
* Fix - Admin notices sometimes were persisting even after dismissing. #28500
* Fix - Calculate discount based on order location in the admin view. #26983
* Fix - SASS variables not being compile correctly due to recent SASS version. #29120
* Fix - Placeholder image height in cart. #29139
* Dev - Updated admin bar icons to use SVG and Dashicons instead of custom font. #29094
* Dev - Admin menu modification has been moved from admin_head hooks to admin_menu hooks. #29088
* Dev - status report generation time to the Status Report. #28980
* Dev - Add the 'woocommerce_exporter_product_types' filter to allow third-parties to filter the product types which can be imported and exported. #28950
* Dev - Filter added to allow 'woocommerce_hold_stock_minutes' to be customized. #28933
* Dev - Add optional semicolon to JS code for better compatibility. #28880
* Dev - Added Guatemala states. #28755
* Dev - jQuery 3 deprecated functions update. #28753
* Dev - Add Woo Version as global prop in track events. #28627
* Dev - Added orders count by payment method to Tracker data and replaced direct DB calls with CRUD. #28584
* Dev - WC_Tax::get_tax_rate_classes() is now public. #27671
* Dev - "Store management insights" option now is turned off by default. #29105
* Dev - Update the woo widget stock links to the new analytics page. #29093
* Tweak - Updated WooCommerce logo color. #29054
* Tweak - Correctly aligns content in the checkout with Twenty Twenty-One. #28951
* Tweak - Use assigned variable for $post_thumbnail_id instead of calling function more than once. #28919
* Tweak - Ensure that all tracker values collected for orders are of string type. #28893
* Tweak - Adjust CSS font size and spacing for Twenty Twenty One. #28827
**WooCommerce Admin - 2.0.0 & 2.0.1 & 2.0.2**
* Tweak - Bump minimum supported version of PHP to 7.0. #6046
* Tweak - update the content and timing of the NeedSomeInspiration note. #6076
* Tweak - Adjust the Marketing note not to show until store is at least 5 days. #6083
* Tweak - Refactored extended task list. #6081
* Fix - Add support for a floating-point number as a SummaryNumber's delta. #5926
* Fix - allow for more terms to be shown for product attributes in the Analytics orders report. #5868
* Fix - Fixed the Add First Product email note checks. #6260
* Fix - Onboarding - Fixed "Business Details" error. #6271
* Fix - Show management links when only main task list is hidden. #6291
* Fix - Correct the Klarna slug. #6440
* Add - new inbox message - Getting started in Ecommerce - watch this webinar. #6086
* Add - Remote inbox notifications contains comparison and fix product rule. #6073
* Add - Task list payments - include Mollie as an option. #6257
* Update - store deprecation welcome modal support doc link #6094
* Update - Homescreen layout, moving Inbox panel for better interaction. #6122
* Enhancement - Allowing users to create products by selecting a template. #5892
* Enhancement - Use the new Paypal payments plugin for onboarding. #6261
* Dev - Add wait script for mysql to be ready for phpunit tests in docker. #6185
* Dev - Remove old debug code for connecting to Calypso / Wordpress.com. #6097
* Dev - Allow highlight tooltip to use body tag as parent. #6309
**WooCommerce Blocks - 4.1.0 & 4.2.0 & 4.3.0 & 4.4.0 & 4.4.1 & 4.4.2 & 4.4.3**
* Update - Jetpack Autoloader to 2.9.1.
* Update - Update package for WooCommerce core inclusion.
* Enhancements - Design tweaks to the cart page which move the quantity picker below each cart item and improve usability on mobile. ([3734](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3734))
* Enhancements - Store API - Fix selected rate in cart shipping rates response. ([3680](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3680))
* Enhancements - Create get_item_responses_from_schema abstraction. ([3679](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3679))
* Enhancements - Show itemized fee rows in the cart/checkout blocks. ([3678](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3678))
* Enhancements - Extensibility: Show item data in Cart and Checkout blocks and update the variation data styles. ([3665](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3665))
* Enhancements - Introduce SlotFill for Sidebar. ([3361](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3361))
* Enhancements - Add the ability to directly upload an image in Featured Category and Featured Product blocks. ([3579](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3579))
* Enhancements - Fix coupon code button height not adapting to the font size. ([3575](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3575))
* Enhancements - Fixed Coupon Code panel not expanding/contracting in some themes. ([3569](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3569))
* Enhancements - Fix: Added fallback styling for screen reader text. ([3557](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3557))
* Fix - Ensure empty categories are correctly hidden in the product categories block. ([3765](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3765))
* Fix - Added missing wrapper div within FeaturedCategory and FeatureProduct blocks. ([3746](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3746))
* Fix - Set correct text color in BlockErrorBoundry notices. ([3738](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3738))
* Fix - Hidden cart item meta data will not be rendered in the Cart and Checkout blocks. ([3732](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3732))
* Fix - Improved accessibility of product image links in the products block by using correct aria tags and hiding empty image placeholders. ([3722](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3722))
* Fix - Add missing aria-label for stars image in the review-list-item component. ([3706](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3706))
* Fix - Prevent "X-WC-Store-API-Nonce is invalid" error when going back to a page with the products block using the browser back button. ([3770](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3770))
* Fix - Adds a default "features" array for payment methods which do not define supported features. Fixes conflicts with 3rd Party payment method integrations.
* Fix - Fix an error that was blocking checkout with some user saved payment methods. ([3627](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3627))
* Fix - Fix nonce issues when adding product to cart from All Products. ([3598](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3598))
* Fix - Fix bug inside Product Search in the editor. ([3578](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3578))
* Fix - Fix console warnings in WordPress 5.6. ([3577](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3577))
* Fix - Fixed text visibility in select inputs when using Twenty Twenty-One theme's dark mode. ([3554](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3554))
* Fix - Fix product list images skewed in Widgets editor. ([3553](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3553))
* Add address validation to values posted to the Checkout via StoreApi. ([3552](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3552))
* Fix - Fix Fees not visible in Cart & Checkout blocks when order doesn't need shipping. ([3521](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3521))
* Fix - Fix All Products block edit screen. ([3547](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3547))
* Fix - Checkout block: Prevent `Create an account` from creating up a user account if the order fails coupon validation. ([3423](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3423))
* Fix - Make sure cart is initialized before the CartItems route is used in the Store API. ([3488](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3488))
* Fix - Fix notice close button color in Twenty Twenty One dark mode. ([3472](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3472))
* Fix - Remove held stock for a draft order if an item is removed from the cart. ([3468](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3468))
* Fix - Ensure correct alignment of checkout notice's dismiss button. ([3455](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3455))
* Fix - Fixed a bug in Checkout block (Store API) causing checkout to fail when using an invalid coupon and creating an account.
* Fix - Checkout block: Correctly handle cases where the order fails with an error (e.g. invalid coupon) and a new user account is created. ([3429](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3429))
* Update - Hide the All Products Block from the new Gutenberg Widget Areas until full support is achieved. ([3737](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3737))
* Update - Legacy `star-rating` class name has been removed from Product rating block (inside All Products block). That element is still selectable with the `.wc-block-components-product-rating` class name. ([3717](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3717))
* Update - Update input colors and alignment. ([3597](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3597))
* Update - Removed compatibility with packages in WordPress 5.3. ([3541](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3541))
* Update - Bumped the minimum WP required version to 5.4. ([3537](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3537))
* Dev - Change register_endpoint_data to use an array of params instead of individual params. ([3478](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3478))
* Dev - Expose store/cart via ExtendRestApi to extensions. ([3445](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3445))
* Dev - Added formatting classes to the Store API for extensions to consume.
* Dev - Refactored and reordered Store API checkout processing to handle various edge cases and better support future extensibility. ([3454](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3454))
= 5.0.0 - 2021-02-09 =
**WooCommerce**
* Enhancement - Create additional download permissions for simple downloadable products that are converted to variable products provided that there are variations offering the same files. #28521
* Enhancement - Export SASS variables as CSS variables. #28709
* Tweak - Added "Store management insights" option. #28712
* Tweak - Styling for dismiss link of the store notice for Twenty Twenty and Twenty Twenty One themes. #28790
* Tweak - Notice to deprecate legacy reports in favor of the newer analytics page. #28799
* Tweak - Ability to create new tags for products when creating a product via the REST API. #28723
* Tweak - Disable untested plugin's notice from System Status and Plugin's page. #28840
* Tweak - Use `wp_robots_no_robots()` when available to support WP 5.7. #28993
* Fix - Improves the logic for deleting variations when a product type is changed. #27137
* Fix - Use 'setlocale' in 'wc_ascii_uasort_comparison' for compatibility with PHP 8. #27844
* Fix - Normalize end of lines in log-handler-email tests for compatibility with PHP 8. #27844
* Fix - Invert `if` statement to reduce nesting level in `\WC_Shipping::calculate_shipping_for_package`. #28558
* Fix - Changed value for speak to fix css3 validation issue. #28607
* Fix - Check if Cart and Checkout pages are using block instead of shortcode for the Status check. #28679
* Fix - Attributes on Edit Product page - "Select all" not working after "Select none" used. #28681
* Fix - Ensure the orders and products statuses are reverted correctly when restoring them. #28690
* Fix - Add checks to make sure session is initialised before loading the data store. #28692
* Fix - Update featured extensions API endpoint on WooCommerce/Extensions page. #28719
* Fix - Add Authorization header to the features extensions and search requests made to the marketplace. #28719
* Fix - Duplicate New Order emails being sent when changing order status. #28809
* Fix - Add migration to fix existing product review count. #28814
* Fix - Fixed issues with empty prices in PHP 8. #28900
* Dev - Increased WordPress minimum version to 5.4 according to WooCommerce's L-2 support policy. #28977
* Dev - Use a custom fork of PHPUnit 7 in PHP 8 to workaround compatibility issues. #27844
* Dev - Introduced `woocommerce_activated_plugin` hook. #28698
* Dev - Clean up the `WC_Shipping_Zone_Data_Store::read()` method, documenting the `woocommerce_shipping_zone_loaded` hook. #28801
* Dev - Updated the Jetpack Autoloader to 2.9.1. #29057
* Localization - Adding states for Dominican Republic. #28713
* Localization - Restored list of Serbia districts #28778
* Localization - Update Indian state name from `Orissa` to `Odisha`. #28740
* Localization - Remove post code requirement for Guatemala. #28706
* Localization - Fixed name for state in Guatemala. #28706
**WooCommerce Admin - 1.9.0**
* Fix - Add Customer Type column to the Orders report table. #5820
* Fix - Product exclusion filter on Orders Report.
* Fix - Typo in Variation Stats DataStore context filter value.
* Fix - support custom attributes in Attribute advanced report filter.
* Fix - Don't show Stock and Reviews Homescreen panels too early.
* Tweak - Remove deprecated use of Jetpack in shipping label banner. #5929
* Fix - Undefined `$collate` variable when database does not have collation capability. #5992
* Tweak - Remove `visit_count` from track, and update task count logic. #5996
* Fix - Moved certified owner label for review to title. ##5877
* Fix - Move collapsible config to panels object, to allow for more control. #5855
* Enhancement - Show Help panel tooltip when user visits unfinished task more then once. #5826
* Tweak - Fix inconsistent REST API paramater name for customer type filtering.
* Enhancement - Tasks extensibility in Home Screen. #5794
* Enhancement - Add page parameter to override default wc-admin page in Navigation API. #5821
* Fix - Invalidate product count if the last product was updated in the list. #5790
* Fix - Updating (non wordpress user) customer with order data
* Dev - Add documentation for filter `woocommerce_admin_pages_list` and `wc_admin_register_page` #5844
* Dev - Revert work done in #4857 for automated shipping after OBW is completed #5971
* Add - Welcome modal when coming from Calypso #6004
* Enhancement - Add an a/b experiment for installing free business features #5786
* Dev - Add `onChangeCallback` feature to the wc-admin `<Form>` component #5786
* Fix - Generate JSON translation chunks on plugin activation #6028
* Dev - Add merchant email notifications #5922
* Add - Email note to add first product. #6024
* Add - Note for users coming from Calypso. #6030
* Enhancement - Add an "unread" indicator to inbox messages. #6047
* Add - Manage activity from home screen inbox message. #6072
= 4.9.2 2021-01-25 =
* Tweak - Disable untested plugin's notice from System Status and Plugin's page. #28840
@ -11,6 +186,7 @@
= 4.9.0 2021-01-12 =
**WooCommerce**
* Localization - Add 'Ladakh' to the list of Indian states. #28458
* Localization - Revert change and make city and postcode required again for Serbia. #28415
* Performance - Added cache and filter for wc-customer get operations. #27352
@ -53,6 +229,7 @@
* Dev - Add is_numeric checks on sales reports by date to prevent notices with PHP 7.4. #28403
**WooCommerce - Admin 1.8.0 & 1.8.1**
* Enhancement - Add “filter by variations in reports” inbox note. #5208
* Enhancement - Tasks extensibility in Home Screen. #5794
* Enhancement - Add page parameter to override default wc-admin page in Navigation API. #5821
@ -93,6 +270,7 @@
* Tweak - Remove check for Jetpack and WCS from Stripe onboarding task. #4933
**WooCommerce Blocks 3.9.0 & 4.0.0**
* Enhancements - Expose `discount_type` in Store API coupon endpoints. ([3399](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3399))
* Enhancements - Exclude checkout-draft orders from WC Admin reports and My Account > Orders. ([3379](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3379))
* Fix - Hide spinner on cart block's "Proceed to Checkout" link when page unloads. ([3436](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/3436))

View File

@ -14,15 +14,15 @@
],
"require": {
"php": ">=7.0",
"automattic/jetpack-autoloader": "2.7.1",
"automattic/jetpack-autoloader": "2.9.1",
"automattic/jetpack-constants": "1.5.1",
"composer/installers": "~1.7",
"maxmind-db/reader": "1.6.0",
"pelago/emogrifier": "3.1.0",
"psr/container": "1.0.0",
"woocommerce/action-scheduler": "3.1.6",
"woocommerce/woocommerce-admin": "1.9.0",
"woocommerce/woocommerce-blocks": "4.0.0"
"woocommerce/woocommerce-admin": "2.0.3",
"woocommerce/woocommerce-blocks": "4.4.3"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.4"

51
composer.lock generated
View File

@ -4,20 +4,20 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "5fac5fbdbcff552de109cd95d469e975",
"content-hash": "d60ef90fa87857445878bb83ba4c592c",
"packages": [
{
"name": "automattic/jetpack-autoloader",
"version": "v2.7.1",
"version": "v2.9.1",
"source": {
"type": "git",
"url": "https://github.com/Automattic/jetpack-autoloader.git",
"reference": "5437697a56aefbdf707849b9833e1b36093d7a73"
"reference": "d6ca2cc26ad6963e1be19b3338a9e98f40d9bd88"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Automattic/jetpack-autoloader/zipball/5437697a56aefbdf707849b9833e1b36093d7a73",
"reference": "5437697a56aefbdf707849b9833e1b36093d7a73",
"url": "https://api.github.com/repos/Automattic/jetpack-autoloader/zipball/d6ca2cc26ad6963e1be19b3338a9e98f40d9bd88",
"reference": "d6ca2cc26ad6963e1be19b3338a9e98f40d9bd88",
"shasum": ""
},
"require": {
@ -28,7 +28,8 @@
},
"type": "composer-plugin",
"extra": {
"class": "Automattic\\Jetpack\\Autoloader\\CustomAutoloaderPlugin"
"class": "Automattic\\Jetpack\\Autoloader\\CustomAutoloaderPlugin",
"mirror-repo": "Automattic/jetpack-autoloader"
},
"autoload": {
"classmap": [
@ -43,10 +44,7 @@
"GPL-2.0-or-later"
],
"description": "Creates a custom autoloader for a plugin or theme.",
"support": {
"source": "https://github.com/Automattic/jetpack-autoloader/tree/v2.7.1"
},
"time": "2020-12-18T22:33:59+00:00"
"time": "2021-02-05T19:07:06+00:00"
},
{
"name": "automattic/jetpack-constants",
@ -457,9 +455,6 @@
],
"description": "Symfony CssSelector Component",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/css-selector/tree/master"
},
"time": "2017-05-01T15:01:29+00:00"
},
{
@ -499,22 +494,22 @@
},
{
"name": "woocommerce/woocommerce-admin",
"version": "1.9.0-rc.3",
"version": "2.0.3",
"source": {
"type": "git",
"url": "https://github.com/woocommerce/woocommerce-admin.git",
"reference": "8c5b20cb6347959daf5403ee30e47061f335240b"
"reference": "15f43c9a1e81258c245ff50ba416a36a2cba7e0b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/woocommerce/woocommerce-admin/zipball/8c5b20cb6347959daf5403ee30e47061f335240b",
"reference": "8c5b20cb6347959daf5403ee30e47061f335240b",
"url": "https://api.github.com/repos/woocommerce/woocommerce-admin/zipball/15f43c9a1e81258c245ff50ba416a36a2cba7e0b",
"reference": "15f43c9a1e81258c245ff50ba416a36a2cba7e0b",
"shasum": ""
},
"require": {
"automattic/jetpack-autoloader": "^2.2.0",
"automattic/jetpack-autoloader": "^2.9.1",
"composer/installers": "^1.9.0",
"php": ">=5.6|>=7.0"
"php": ">=7.0"
},
"require-dev": {
"phpunit/phpunit": "7.5.20",
@ -540,24 +535,24 @@
],
"description": "A modern, javascript-driven WooCommerce Admin experience.",
"homepage": "https://github.com/woocommerce/woocommerce-admin",
"time": "2021-01-22T10:23:29+00:00"
"time": "2021-03-10T02:58:43+00:00"
},
{
"name": "woocommerce/woocommerce-blocks",
"version": "v4.0.0",
"version": "v4.4.3",
"source": {
"type": "git",
"url": "https://github.com/woocommerce/woocommerce-gutenberg-products-block.git",
"reference": "f5b2485254f36f0b85fd0f30c28e17bdf44a8d1e"
"reference": "1eade21846e81d5aaf9bf40cdd1be60778849244"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/woocommerce/woocommerce-gutenberg-products-block/zipball/f5b2485254f36f0b85fd0f30c28e17bdf44a8d1e",
"reference": "f5b2485254f36f0b85fd0f30c28e17bdf44a8d1e",
"url": "https://api.github.com/repos/woocommerce/woocommerce-gutenberg-products-block/zipball/1eade21846e81d5aaf9bf40cdd1be60778849244",
"reference": "1eade21846e81d5aaf9bf40cdd1be60778849244",
"shasum": ""
},
"require": {
"automattic/jetpack-autoloader": "^2.0.0",
"automattic/jetpack-autoloader": "^2.9.1",
"composer/installers": "^1.7.0"
},
"require-dev": {
@ -587,11 +582,7 @@
"gutenberg",
"woocommerce"
],
"support": {
"issues": "https://github.com/woocommerce/woocommerce-gutenberg-products-block/issues",
"source": "https://github.com/woocommerce/woocommerce-gutenberg-products-block/tree/v4.0.0"
},
"time": "2020-12-08T13:17:01+00:00"
"time": "2021-02-11T18:07:48+00:00"
}
],
"packages-dev": [

View File

@ -1,11 +1,11 @@
# WooCommerce `includes` files
This directory contains WooCommerce legacy code. Ideally, the code in this folder should only get the minimum required changes for bug fixing, and any new code should go in [the `src` directory](https://github.com/woocommerce/woocommerce/tree/master/src/README.md) instead.
This directory contains WooCommerce legacy code. Ideally, the code in this folder should only get the minimum required changes for bug fixing, and any new code should go in [the `src` directory](https://github.com/woocommerce/woocommerce/tree/trunk/src/README.md) instead.
## Interacting with the `src` folder
Whenever you need to get an instance of a class from the `src` directory, please don't instantiate it directly, but instead use [the container](https://github.com/woocommerce/woocommerce/tree/master/src/README.md#the-container). To get an instance of the container itself you can use the `wc_get_container` function, for example:
Whenever you need to get an instance of a class from the `src` directory, please don't instantiate it directly, but instead use [the container](https://github.com/woocommerce/woocommerce/tree/trunk/src/README.md#the-container). To get an instance of the container itself you can use the `wc_get_container` function, for example:
```php
$container = wc_get_container();
@ -17,18 +17,18 @@ The exception to this rule might be data-only classes that could be created the
## Adding new actions and filters
Please take a look at [the considerations for creation new hooks in `src` code](https://github.com/woocommerce/woocommerce/tree/master/src/README.md#defining-new-actions-and-filters), as they apply for `includes` code as well. The short version is that **new hooks should be introduced only if they provide a valuable extension point for plugins**, and not with the purpose of driving WooCommerce's internal logic.
Please take a look at [the considerations for creation new hooks in `src` code](https://github.com/woocommerce/woocommerce/tree/trunk/src/README.md#defining-new-actions-and-filters), as they apply for `includes` code as well. The short version is that **new hooks should be introduced only if they provide a valuable extension point for plugins**, and not with the purpose of driving WooCommerce's internal logic.
## Writing unit tests
[As it's the case for the `src` folder](https://github.com/woocommerce/woocommerce/tree/master/src/README.md#writing-unit-tests), writing unit tests is generally mandatory if you are a WooCommerce team member or a contributor from another Automattic team, and encouraged if you are an external contributor. Tests should cover any new code (although as mentioned, adding new code in `includes` should be rare) and any modifications to existing code.
[As it's the case for the `src` folder](https://github.com/woocommerce/woocommerce/tree/trunk/src/README.md#writing-unit-tests), writing unit tests is generally mandatory if you are a WooCommerce team member or a contributor from another Automattic team, and encouraged if you are an external contributor. Tests should cover any new code (although as mentioned, adding new code in `includes` should be rare) and any modifications to existing code.
In order to make it easier to write unit tests, there are a couple of mechanisms in place that you can use:
* [The code hacker](https://github.com/woocommerce/woocommerce/blob/master/tests/Tools/CodeHacking/README.md). Pros: you don't need to do any special changes to your code to make it testable. Cons: it's a hack, the tested code is being actually modified while being loaded by the PHP engine, so not an ideal solution.
* [The code hacker](https://github.com/woocommerce/woocommerce/blob/trunk/tests/Tools/CodeHacking/README.md). Pros: you don't need to do any special changes to your code to make it testable. Cons: it's a hack, the tested code is being actually modified while being loaded by the PHP engine, so not an ideal solution.
* [The legacy proxy and the related helper methods in WC_Unit_Test_case](https://github.com/woocommerce/woocommerce/tree/master/src/README.md#interacting-with-legacy-code): although these are intended in principle for writing tests for code in the `src` directory, they can be used for `includes` code as well. Pros: a clean approach, no hacks involved. Cons: you need to modify your code to use the proxy whenever you need to call a function or static method that makes the code difficult to test.
* [The legacy proxy and the related helper methods in WC_Unit_Test_case](https://github.com/woocommerce/woocommerce/tree/trunk/src/README.md#interacting-with-legacy-code): although these are intended in principle for writing tests for code in the `src` directory, they can be used for `includes` code as well. Pros: a clean approach, no hacks involved. Cons: you need to modify your code to use the proxy whenever you need to call a function or static method that makes the code difficult to test.
It's up to you as a contributor to decide which mechanism to use in each case. Choose wisely.

View File

@ -1270,6 +1270,8 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
*/
protected function set_item_discount_amounts( $discounts ) {
$item_discounts = $discounts->get_discounts_by_item();
$tax_location = $this->get_tax_location();
$tax_location = array( $tax_location['country'], $tax_location['state'], $tax_location['postcode'], $tax_location['city'] );
if ( $item_discounts ) {
foreach ( $item_discounts as $item_id => $amount ) {
@ -1277,7 +1279,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
// If the prices include tax, discounts should be taken off the tax inclusive prices like in the cart.
if ( $this->get_prices_include_tax() && wc_tax_enabled() && 'taxable' === $item->get_tax_status() ) {
$taxes = WC_Tax::calc_tax( $amount, WC_Tax::get_rates( $item->get_tax_class() ), true );
$taxes = WC_Tax::calc_tax( $amount, $this->get_tax_rates( $item->get_tax_class(), $tax_location ), true );
// Use unrounded taxes so totals will be re-calculated accurately, like in cart.
$amount = $amount - array_sum( $taxes );
@ -1299,6 +1301,13 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
$coupon_code_to_id = wc_list_pluck( $coupons, 'get_id', 'get_code' );
$all_discounts = $discounts->get_discounts();
$coupon_discounts = $discounts->get_discounts_by_coupon();
$tax_location = $this->get_tax_location();
$tax_location = array(
$tax_location['country'],
$tax_location['state'],
$tax_location['postcode'],
$tax_location['city'],
);
if ( $coupon_discounts ) {
foreach ( $coupon_discounts as $coupon_code => $amount ) {
@ -1321,7 +1330,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
continue;
}
$taxes = array_sum( WC_Tax::calc_tax( $item_discount_amount, WC_Tax::get_rates( $item->get_tax_class() ), $this->get_prices_include_tax() ) );
$taxes = array_sum( WC_Tax::calc_tax( $item_discount_amount, $this->get_tax_rates( $item->get_tax_class(), $tax_location ), $this->get_prices_include_tax() ) );
if ( 'yes' !== get_option( 'woocommerce_tax_round_at_subtotal' ) ) {
$taxes = wc_round_tax_total( $taxes );
}
@ -1514,6 +1523,21 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
return apply_filters( 'woocommerce_order_get_tax_location', $args, $this );
}
/**
* Get tax rates for an order. Use order's shipping or billing address, defaults to base location.
*
* @param string $tax_class Tax class to get rates for.
* @param array $location_args Location to compute rates for. Should be in form: array( country, state, postcode, city).
* @param object $customer Only used to maintain backward compatibility for filter `woocommerce-matched_rates`.
*
* @return mixed|void Tax rates.
*/
protected function get_tax_rates( $tax_class, $location_args = array(), $customer = null ) {
$tax_location = $this->get_tax_location( $location_args );
$tax_location = array( $tax_location['country'], $tax_location['state'], $tax_location['postcode'], $tax_location['city'] );
return WC_Tax::get_rates_from_location( $tax_class, $tax_location, $customer );
}
/**
* Calculate taxes for all line items and shipping, and store the totals and tax rows.
*
@ -1583,9 +1607,9 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
foreach ( $this->get_items( array( 'line_item', 'fee' ) ) as $item_id => $item ) {
$taxes = $item->get_taxes();
foreach ( $taxes['total'] as $tax_rate_id => $tax ) {
$tax_amount = $this->round_line_tax( $tax, false );
$tax_amount = (float) $this->round_line_tax( $tax, false );
$cart_taxes[ $tax_rate_id ] = isset( $cart_taxes[ $tax_rate_id ] ) ? $cart_taxes[ $tax_rate_id ] + $tax_amount : $tax_amount;
$cart_taxes[ $tax_rate_id ] = isset( $cart_taxes[ $tax_rate_id ] ) ? (float) $cart_taxes[ $tax_rate_id ] + $tax_amount : $tax_amount;
}
}
@ -1610,6 +1634,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
}
$saved_rate_ids[] = $tax->get_rate_id();
$tax->set_tax_total( isset( $cart_taxes[ $tax->get_rate_id() ] ) ? $cart_taxes[ $tax->get_rate_id() ] : 0 );
$tax->set_label( WC_Tax::get_rate_label( $tax->get_rate_id() ) );
$tax->set_shipping_tax_total( ! empty( $shipping_taxes[ $tax->get_rate_id() ] ) ? $shipping_taxes[ $tax->get_rate_id() ] : 0 );
$tax->save();
}

View File

@ -2,7 +2,7 @@
/**
* Abstract payment tokens
*
* Generic payment tokens functionality which can be extended by idividual types of payment tokens.
* Generic payment tokens functionality which can be extended by individual types of payment tokens.
*
* @class WC_Payment_Token
* @package WooCommerce\Abstracts

View File

@ -641,7 +641,7 @@ class WC_Admin_Addons {
self::install_woocommerce_services_addon();
break;
case 'woocommerce-payments':
self::install_woocommerce_payments_addon();
self::install_woocommerce_payments_addon( $section );
break;
default:
// Do nothing.
@ -693,9 +693,11 @@ class WC_Admin_Addons {
/**
* Install WooCommerce Payments from the Extensions screens.
*
* @param string $section Optional. Extenstions tab.
*
* @return void
*/
public static function install_woocommerce_payments_addon() {
public static function install_woocommerce_payments_addon( $section = '_featured' ) {
check_admin_referer( 'install-addon_woocommerce-payments' );
$wcpay_plugin_id = 'woocommerce-payments';
@ -704,7 +706,9 @@ class WC_Admin_Addons {
'repo-slug' => 'woocommerce-payments',
);
WC_Install::background_installer( $services_plugin_id, $wcpay_plugin );
WC_Install::background_installer( $wcpay_plugin_id, $wcpay_plugin );
do_action( 'woocommerce_addon_installed', $wcpay_plugin_id, $section );
wp_safe_redirect( remove_query_arg( array( 'install-addon', '_wpnonce' ) ) );
exit;

View File

@ -0,0 +1,211 @@
<?php
/**
* Admin Dashboard - Setup
*
* @package WooCommerce\Admin
* @version 2.1.0
*/
use Automattic\Jetpack\Constants;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! class_exists( 'WC_Admin_Dashboard_Setup', false ) ) :
/**
* WC_Admin_Dashboard_Setup Class.
*/
class WC_Admin_Dashboard_Setup {
/**
* List of tasks.
*
* @var array
*/
private $tasks = array(
'store_details' => array(
'completed' => false,
'button_link' => 'admin.php?page=wc-admin&path=%2Fsetup-wizard',
),
'products' => array(
'completed' => false,
'button_link' => 'admin.php?page=wc-admin&task=products',
),
'woocommerce-payments' => array(
'completed' => false,
'button_link' => 'admin.php?page=wc-admin&path=%2Fpayments%2Fconnect',
),
'payments' => array(
'completed' => false,
'button_link' => 'admin.php?page=wc-admin&task=payments',
),
'tax' => array(
'completed' => false,
'button_link' => 'admin.php?page=wc-admin&task=tax',
),
'shipping' => array(
'completed' => false,
'button_link' => 'admin.php?page=wc-admin&task=shipping',
),
'appearance' => array(
'completed' => false,
'button_link' => 'admin.php?page=wc-admin&task=appearance',
),
);
/**
* # of completed tasks.
*
* @var int
*/
private $completed_tasks_count = 0;
/**
* WC_Admin_Dashboard_Setup constructor.
*/
public function __construct() {
if ( $this->should_display_widget() ) {
$this->populate_general_tasks();
$this->populate_payment_tasks();
$this->completed_tasks_count = $this->get_completed_tasks_count();
add_meta_box(
'wc_admin_dashboard_setup',
__( 'WooCommerce Setup', 'woocommerce' ),
array( $this, 'render' ),
'dashboard',
'normal',
'high'
);
}
}
/**
* Render meta box output.
*/
public function render() {
$version = Constants::get_constant( 'WC_VERSION' );
wp_enqueue_style( 'wc-dashboard-setup', WC()->plugin_url() . '/assets/css/dashboard-setup.css', array(), $version );
$task = $this->get_next_task();
if ( ! $task ) {
return;
}
$button_link = $task['button_link'];
$completed_tasks_count = $this->completed_tasks_count;
$tasks_count = count( $this->tasks );
// Given 'r' (circle element's r attr), dashoffset = ((100-$desired_percentage)/100) * PI * (r*2).
$progress_percentage = ( $completed_tasks_count / $tasks_count ) * 100;
$circle_r = 6.5;
$circle_dashoffset = ( ( 100 - $progress_percentage ) / 100 ) * ( pi() * ( $circle_r * 2 ) );
include __DIR__ . '/views/html-admin-dashboard-setup.php';
}
/**
* Populate tasks from the database.
*/
private function populate_general_tasks() {
$tasks = get_option( 'woocommerce_task_list_tracked_completed_tasks', array() );
foreach ( $tasks as $task ) {
if ( isset( $this->tasks[ $task ] ) ) {
$this->tasks[ $task ]['completed'] = true;
$this->tasks[ $task ]['button_link'] = wc_admin_url( $this->tasks[ $task ]['button_link'] );
}
}
}
/**
* Getter for $tasks
*
* @return array
*/
public function get_tasks() {
return $this->tasks;
}
/**
* Return # of completed tasks
*/
public function get_completed_tasks_count() {
$completed_tasks = array_filter(
$this->tasks,
function( $task ) {
return $task['completed'];
}
);
return count( $completed_tasks );
}
/**
* Get the next task.
*
* @return array|null
*/
private function get_next_task() {
foreach ( $this->get_tasks() as $task ) {
if ( false === $task['completed'] ) {
return $task;
}
}
return null;
}
/**
* Check to see if we should display the widget
*
* @return bool
*/
private function should_display_widget() {
return 'yes' !== get_option( 'woocommerce_task_list_complete' ) && 'yes' !== get_option( 'woocommerce_task_list_hidden' );
}
/**
* Populate payment tasks's visibility and completion
*/
private function populate_payment_tasks() {
$is_woo_payment_installed = is_plugin_active( 'woocommerce-payments/woocommerce-payments.php' );
$country = explode( ':', get_option( 'woocommerce_default_country', '' ) )[0];
// woocommerce-payments requires its plugin activated and country must be US.
if ( ! $is_woo_payment_installed || 'US' !== $country ) {
unset( $this->tasks['woocommerce-payments'] );
}
// payments can't be used when woocommerce-payments exists and country is US.
if ( $is_woo_payment_installed || 'US' === $country ) {
unset( $this->tasks['payments'] );
}
if ( isset( $this->tasks['payments'] ) ) {
$gateways = WC()->payment_gateways->get_available_payment_gateways();
$enabled_gateways = array_filter(
$gateways,
function ( $gateway ) {
return 'yes' === $gateway->enabled;
}
);
$this->tasks['payments']['completed'] = ! empty( $enabled_gateways );
}
if ( isset( $this->tasks['woocommerce-payments'] ) ) {
$wc_pay_is_connected = false;
if ( class_exists( '\WC_Payments' ) ) {
$wc_payments_gateway = \WC_Payments::get_gateway();
$wc_pay_is_connected = method_exists( $wc_payments_gateway, 'is_connected' )
? $wc_payments_gateway->is_connected()
: false;
}
$this->tasks['woocommerce-payments']['completed'] = $wc_pay_is_connected;
}
}
}
endif;
return new WC_Admin_Dashboard_Setup();

View File

@ -24,7 +24,7 @@ if ( ! class_exists( 'WC_Admin_Dashboard', false ) ) :
*/
public function __construct() {
// Only hook in admin parts if the user has admin access.
if ( current_user_can( 'view_woocommerce_reports' ) || current_user_can( 'manage_woocommerce' ) || current_user_can( 'publish_shop_orders' ) ) {
if ( $this->should_display_widget() ) {
// If on network admin, only load the widget that works in that context and skip the rest.
if ( is_multisite() && is_network_admin() ) {
add_action( 'wp_network_dashboard_setup', array( $this, 'register_network_order_widget' ) );
@ -57,6 +57,17 @@ if ( ! class_exists( 'WC_Admin_Dashboard', false ) ) :
wp_add_dashboard_widget( 'woocommerce_network_orders', __( 'WooCommerce Network Orders', 'woocommerce' ), array( $this, 'network_orders' ) );
}
/**
* Check to see if we should display the widget.
*
* @return bool
*/
private function should_display_widget() {
$has_permission = current_user_can( 'view_woocommerce_reports' ) || current_user_can( 'manage_woocommerce' ) || current_user_can( 'publish_shop_orders' );
$task_completed_or_hidden = 'yes' === get_option( 'woocommerce_task_list_complete' ) || 'yes' === get_option( 'woocommerce_task_list_hidden' );
return $task_completed_or_hidden && $has_permission;
}
/**
* Get top seller from DB.
*
@ -105,19 +116,34 @@ if ( ! class_exists( 'WC_Admin_Dashboard', false ) ) :
* Show status widget.
*/
public function status_widget() {
$suffix = Constants::is_true( 'SCRIPT_DEBUG' ) ? '' : '.min';
$version = Constants::get_constant( 'WC_VERSION' );
wp_enqueue_script( 'wc-status-widget', WC()->plugin_url() . '/assets/js/admin/wc-status-widget' . $suffix . '.js', array( 'jquery' ), $version, true );
include_once dirname( __FILE__ ) . '/reports/class-wc-admin-report.php';
$is_wc_admin_disabled = apply_filters( 'woocommerce_admin_disabled', false );
$reports = new WC_Admin_Report();
$net_sales_link = 'admin.php?page=wc-reports&tab=orders&range=month';
$top_seller_link = 'admin.php?page=wc-reports&tab=orders&report=sales_by_product&range=month&product_ids=';
$report_data = $is_wc_admin_disabled ? $this->get_sales_report_data() : $this->get_wc_admin_performance_data();
if ( ! $is_wc_admin_disabled ) {
$net_sales_link = 'admin.php?page=wc-admin&path=%2Fanalytics%2Frevenue&chart=net_revenue&orderby=net_revenue&period=month&compare=previous_period';
$top_seller_link = 'admin.php?page=wc-admin&filter=single_product&path=%2Fanalytics%2Fproducts&products=';
}
echo '<ul class="wc_status_list">';
if ( current_user_can( 'view_woocommerce_reports' ) ) {
$report_data = $this->get_sales_report_data();
if ( $report_data ) {
?>
<li class="sales-this-month">
<a href="<?php echo esc_url( admin_url( 'admin.php?page=wc-reports&tab=orders&range=month' ) ); ?>">
<?php echo $reports->sales_sparkline( '', max( 7, gmdate( 'd', current_time( 'timestamp' ) ) ) ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped ?>
<a href="<?php echo esc_url( admin_url( $net_sales_link ) ); ?>">
<?php echo $this->sales_sparkline( $reports, $is_wc_admin_disabled, '' ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped ?>
<?php
printf(
/* translators: %s: net sales */
@ -134,8 +160,8 @@ if ( ! class_exists( 'WC_Admin_Dashboard', false ) ) :
if ( $top_seller && $top_seller->qty ) {
?>
<li class="best-seller-this-month">
<a href="<?php echo esc_url( admin_url( 'admin.php?page=wc-reports&tab=orders&report=sales_by_product&range=month&product_ids=' . $top_seller->product_id ) ); ?>">
<?php echo $reports->sales_sparkline( $top_seller->product_id, max( 7, gmdate( 'd', current_time( 'timestamp' ) ) ), 'count' ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped ?>
<a href="<?php echo esc_url( admin_url( $top_seller_link . $top_seller->product_id ) ); ?>">
<?php echo $this->sales_sparkline( $reports, $is_wc_admin_disabled, $top_seller->product_id, 'count' ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped ?>
<?php
printf(
/* translators: 1: top seller product title 2: top seller quantity */
@ -151,7 +177,7 @@ if ( ! class_exists( 'WC_Admin_Dashboard', false ) ) :
}
$this->status_widget_order_rows();
$this->status_widget_stock_rows();
$this->status_widget_stock_rows( $is_wc_admin_disabled );
do_action( 'woocommerce_after_dashboard_status_widget', $reports );
echo '</ul>';
@ -200,8 +226,10 @@ if ( ! class_exists( 'WC_Admin_Dashboard', false ) ) :
/**
* Show stock data is status widget.
*
* @param bool $is_wc_admin_disabled if woocommerce admin is disabled.
*/
private function status_widget_stock_rows() {
private function status_widget_stock_rows( $is_wc_admin_disabled ) {
global $wpdb;
// Requires lookup table added in 3.6.
@ -246,6 +274,13 @@ if ( ! class_exists( 'WC_Admin_Dashboard', false ) ) :
$transient_name = 'wc_outofstock_count';
$outofstock_count = get_transient( $transient_name );
$lowstock_link = 'admin.php?page=wc-reports&tab=stock&report=low_in_stock';
$outofstock_link = 'admin.php?page=wc-reports&tab=stock&report=out_of_stock';
if ( false === $is_wc_admin_disabled ) {
$lowstock_link = 'admin.php?page=wc-admin&type=lowstock&path=%2Fanalytics%2Fstock';
$outofstock_link = 'admin.php?page=wc-admin&type=outofstock&path=%2Fanalytics%2Fstock';
}
if ( false === $outofstock_count ) {
/**
@ -274,7 +309,7 @@ if ( ! class_exists( 'WC_Admin_Dashboard', false ) ) :
}
?>
<li class="low-in-stock">
<a href="<?php echo esc_url( admin_url( 'admin.php?page=wc-reports&tab=stock&report=low_in_stock' ) ); ?>">
<a href="<?php echo esc_url( admin_url( $lowstock_link ) ); ?>">
<?php
printf(
/* translators: %s: order count */
@ -285,7 +320,7 @@ if ( ! class_exists( 'WC_Admin_Dashboard', false ) ) :
</a>
</li>
<li class="out-of-stock">
<a href="<?php echo esc_url( admin_url( 'admin.php?page=wc-reports&tab=stock&report=out_of_stock' ) ); ?>">
<a href="<?php echo esc_url( admin_url( $outofstock_link ) ); ?>">
<?php
printf(
/* translators: %s: order count */
@ -416,6 +451,106 @@ if ( ! class_exists( 'WC_Admin_Dashboard', false ) ) :
</div>
<?php
}
/**
* Gets the sales performance data from the new WooAdmin store.
*
* @return stdClass|WP_Error|WP_REST_Response
*/
private function get_wc_admin_performance_data() {
$request = new \WP_REST_Request( 'GET', '/wc-analytics/reports/performance-indicators' );
$start_date = gmdate( 'Y-m-01 00:00:00', current_time( 'timestamp' ) );
$end_date = gmdate( 'Y-m-d 23:59:59', current_time( 'timestamp' ) );
$request->set_query_params(
array(
'before' => $end_date,
'after' => $start_date,
'stats' => 'revenue/total_sales,revenue/net_revenue,orders/orders_count,products/items_sold,variations/items_sold',
)
);
$response = rest_do_request( $request );
if ( is_wp_error( $response ) ) {
return $response;
}
if ( 200 !== $response->get_status() ) {
return new \WP_Error( 'woocommerce_analytics_performance_indicators_result_failed', __( 'Sorry, fetching performance indicators failed.', 'woocommerce' ) );
}
$report_keys = array(
'net_revenue' => 'net_sales',
);
$performance_data = new stdClass();
foreach ( $response->get_data() as $indicator ) {
if ( isset( $indicator['chart'] ) && isset( $indicator['value'] ) ) {
$key = isset( $report_keys[ $indicator['chart'] ] ) ? $report_keys[ $indicator['chart'] ] : $indicator['chart'];
$performance_data->$key = $indicator['value'];
}
}
return $performance_data;
}
/**
* Overwrites the original sparkline to use the new reports data if WooAdmin is enabled.
* Prepares a sparkline to show sales in the last X days.
*
* @param WC_Admin_Report $reports old class for getting reports.
* @param bool $is_wc_admin_disabled If WC Admin is disabled or not.
* @param int $id ID of the product to show. Blank to get all orders.
* @param string $type Type of sparkline to get. Ignored if ID is not set.
* @return string
*/
private function sales_sparkline( $reports, $is_wc_admin_disabled = false, $id = '', $type = 'sales' ) {
$days = max( 7, gmdate( 'd', current_time( 'timestamp' ) ) );
if ( $is_wc_admin_disabled ) {
return $reports->sales_sparkline( $id, $days, $type );
}
$sales_endpoint = '/wc-analytics/reports/revenue/stats';
$start_date = gmdate( 'Y-m-d 00:00:00', current_time( 'timestamp' ) - ( ( $days - 1 ) * DAY_IN_SECONDS ) );
$end_date = gmdate( 'Y-m-d 23:59:59', current_time( 'timestamp' ) );
$meta_key = 'net_revenue';
$params = array(
'order' => 'asc',
'interval' => 'day',
'per_page' => 100,
'before' => $end_date,
'after' => $start_date,
);
if ( $id ) {
$sales_endpoint = '/wc-analytics/reports/products/stats';
$meta_key = ( 'sales' === $type ) ? 'net_revenue' : 'items_sold';
$params['products'] = $id;
}
$request = new \WP_REST_Request( 'GET', $sales_endpoint );
$params['fields'] = array( $meta_key );
$request->set_query_params( $params );
$response = rest_do_request( $request );
if ( is_wp_error( $response ) ) {
return $response;
}
$resp_data = $response->get_data();
$data = $resp_data['intervals'];
$sparkline_data = array();
$total = 0;
foreach ( $data as $d ) {
$total += $d['subtotals']->$meta_key;
array_push( $sparkline_data, array( strval( strtotime( $d['interval'] ) * 1000 ), $d['subtotals']->$meta_key ) );
}
if ( 'sales' === $type ) {
/* translators: 1: total income 2: days */
$tooltip = sprintf( __( 'Sold %1$s worth in the last %2$d days', 'woocommerce' ), strip_tags( wc_price( $total ) ), $days );
} else {
/* translators: 1: total items sold 2: days */
$tooltip = sprintf( _n( 'Sold %1$d item in the last %2$d days', 'Sold %1$d items in the last %2$d days', $total, 'woocommerce' ), $total, $days );
}
return '<span class="wc_sparkline ' . ( ( 'sales' === $type ) ? 'lines' : 'bars' ) . ' tips" data-color="#777" data-tip="' . esc_attr( $tooltip ) . '" data-barwidth="' . 60 * 60 * 16 * 1000 . '" data-sparkline="' . wc_esc_json( wp_json_encode( $sparkline_data ) ) . '"></span>';
}
}
endif;

View File

@ -191,6 +191,30 @@ class WC_Admin_Exporters {
);
}
}
/**
* Gets the product types that can be exported.
*
* @since 5.1.0
* @return array The product types keys and labels.
*/
public static function get_product_types() {
$product_types = wc_get_product_types();
$product_types['variation'] = __( 'Product variations', 'woocommerce' );
/**
* Allow third-parties to filter the exportable product types.
*
* @since 5.1.0
* @param array $product_types {
* The product type key and label.
*
* @type string Product type key - eg 'variable', 'simple' etc.
* @type string A translated product label which appears in the export product type dropdown.
* }
*/
return apply_filters( 'woocommerce_exporter_product_types', $product_types );
}
}
new WC_Admin_Exporters();

View File

@ -65,7 +65,7 @@ class WC_Admin_Help {
'content' =>
'<h2>' . __( 'Found a bug?', 'woocommerce' ) . '</h2>' .
/* translators: 1: GitHub issues URL 2: GitHub contribution guide URL 3: System status report URL */
'<p>' . sprintf( __( 'If you find a bug within WooCommerce core you can create a ticket via <a href="%1$s">Github issues</a>. Ensure you read the <a href="%2$s">contribution guide</a> prior to submitting your report. To help us solve your issue, please be as descriptive as possible and include your <a href="%3$s">system status report</a>.', 'woocommerce' ), 'https://github.com/woocommerce/woocommerce/issues?state=open', 'https://github.com/woocommerce/woocommerce/blob/master/.github/CONTRIBUTING.md', admin_url( 'admin.php?page=wc-status' ) ) . '</p>' .
'<p>' . sprintf( __( 'If you find a bug within WooCommerce core you can create a ticket via <a href="%1$s">Github issues</a>. Ensure you read the <a href="%2$s">contribution guide</a> prior to submitting your report. To help us solve your issue, please be as descriptive as possible and include your <a href="%3$s">system status report</a>.', 'woocommerce' ), 'https://github.com/woocommerce/woocommerce/issues?state=open', 'https://github.com/woocommerce/woocommerce/blob/trunk/.github/CONTRIBUTING.md', admin_url( 'admin.php?page=wc-status' ) ) . '</p>' .
'<p><a href="https://github.com/woocommerce/woocommerce/issues/new?template=4-Bug-report.md" class="button button-primary">' . __( 'Report a bug', 'woocommerce' ) . '</a> <a href="' . admin_url( 'admin.php?page=wc-status' ) . '" class="button">' . __( 'System status', 'woocommerce' ) . '</a></p>',
)

View File

@ -22,6 +22,8 @@ class WC_Admin_Menus {
*/
public function __construct() {
// Add menus.
add_action( 'admin_menu', array( $this, 'menu_highlight' ) );
add_action( 'admin_menu', array( $this, 'menu_order_count' ) );
add_action( 'admin_menu', array( $this, 'admin_menu' ), 9 );
add_action( 'admin_menu', array( $this, 'reports_menu' ), 20 );
add_action( 'admin_menu', array( $this, 'settings_menu' ), 50 );
@ -31,8 +33,6 @@ class WC_Admin_Menus {
add_action( 'admin_menu', array( $this, 'addons_menu' ), 70 );
}
add_action( 'admin_head', array( $this, 'menu_highlight' ) );
add_action( 'admin_head', array( $this, 'menu_order_count' ) );
add_filter( 'menu_order', array( $this, 'menu_order' ) );
add_filter( 'custom_menu_order', array( $this, 'custom_menu_order' ) );
add_filter( 'set-screen-option', array( $this, 'set_screen_option' ), 10, 3 );
@ -55,11 +55,13 @@ class WC_Admin_Menus {
public function admin_menu() {
global $menu;
$woocommerce_icon = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDI0IDEwMjQiPjxwYXRoIGZpbGw9IiNhMmFhYjIiIGQ9Ik02MTIuMTkyIDQyNi4zMzZjMC02Ljg5Ni0zLjEzNi01MS42LTI4LTUxLjYtMzcuMzYgMC00Ni43MDQgNzIuMjU2LTQ2LjcwNCA4Mi42MjQgMCAzLjQwOCAzLjE1MiA1OC40OTYgMjguMDMyIDU4LjQ5NiAzNC4xOTItLjAzMiA0Ni42NzItNzIuMjg4IDQ2LjY3Mi04OS41MnptMjAyLjE5MiAwYzAtNi44OTYtMy4xNTItNTEuNi0yOC4wMzItNTEuNi0zNy4yOCAwLTQ2LjYwOCA3Mi4yNTYtNDYuNjA4IDgyLjYyNCAwIDMuNDA4IDMuMDcyIDU4LjQ5NiAyNy45NTIgNTguNDk2IDM0LjE5Mi0uMDMyIDQ2LjY4OC03Mi4yODggNDYuNjg4LTg5LjUyek0xNDEuMjk2Ljc2OGMtNjguMjI0IDAtMTIzLjUwNCA1NS40ODgtMTIzLjUwNCAxMjMuOTJ2NjUwLjcyYzAgNjguNDMyIDU1LjI5NiAxMjMuOTIgMTIzLjUwNCAxMjMuOTJoMzM5LjgwOGwxMjMuNTA0IDEyMy45MzZWODk5LjMyOGgyNzguMDQ4YzY4LjIyNCAwIDEyMy41Mi01NS40NzIgMTIzLjUyLTEyMy45MnYtNjUwLjcyYzAtNjguNDMyLTU1LjI5Ni0xMjMuOTItMTIzLjUyLTEyMy45MmgtNzQxLjM2em01MjYuODY0IDQyMi4xNmMwIDU1LjA4OC0zMS4wODggMTU0Ljg4LTEwMi42NCAxNTQuODgtNi4yMDggMC0xOC40OTYtMy42MTYtMjUuNDI0LTYuMDE2LTMyLjUxMi0xMS4xNjgtNTAuMTkyLTQ5LjY5Ni01Mi4zNTItNjYuMjU2IDAgMC0zLjA3Mi0xNy43OTItMy4wNzItNDAuNzUyIDAtMjIuOTkyIDMuMDcyLTQ1LjMyOCAzLjA3Mi00NS4zMjggMTUuNTUyLTc1LjcyOCA0My41NTItMTA2LjczNiA5Ni40NDgtMTA2LjczNiA1OS4wNzItLjAzMiA4My45NjggNTguNTI4IDgzLjk2OCAxMTAuMjA4ek00ODYuNDk2IDMwMi40YzAgMy4zOTItNDMuNTUyIDE0MS4xNjgtNDMuNTUyIDIxMy40MjR2NzUuNzEyYy0yLjU5MiAxMi4wOC00LjE2IDI0LjE0NC0yMS44MjQgMjQuMTQ0LTQ2LjYwOCAwLTg4Ljg4LTE1MS40NzItOTIuMDE2LTE2MS44NC02LjIwOCA2Ljg5Ni02Mi4yNCAxNjEuODQtOTYuNDQ4IDE2MS44NC0yNC44NjQgMC00My41NTItMTEzLjY0OC00Ni42MDgtMTIzLjkzNkMxNzYuNzA0IDQzNi42NzIgMTYwIDMzNC4yMjQgMTYwIDMyNy4zMjhjMC0yMC42NzIgMS4xNTItMzguNzM2IDI2LjA0OC0zOC43MzYgNi4yMDggMCAyMS42IDYuMDY0IDIzLjcxMiAxNy4xNjggMTEuNjQ4IDYyLjAzMiAxNi42ODggMTIwLjUxMiAyOS4xNjggMTg1Ljk2OCAxLjg1NiAyLjkyOCAxLjUwNCA3LjAwOCA0LjU2IDEwLjQzMiAzLjE1Mi0xMC4yODggNjYuOTI4LTE2OC43ODQgOTQuOTYtMTY4Ljc4NCAyMi41NDQgMCAzMC40IDQ0LjU5MiAzMy41MzYgNjEuODI0IDYuMjA4IDIwLjY1NiAxMy4wODggNTUuMjE2IDIyLjQxNiA4Mi43NTIgMC0xMy43NzYgMTIuNDgtMjAzLjEyIDY1LjM5Mi0yMDMuMTIgMTguNTkyLjAzMiAyNi43MDQgNi45MjggMjYuNzA0IDI3LjU2OHpNODcwLjMyIDQyMi45MjhjMCA1NS4wODgtMzEuMDg4IDE1NC44OC0xMDIuNjQgMTU0Ljg4LTYuMTkyIDAtMTguNDQ4LTMuNjE2LTI1LjQyNC02LjAxNi0zMi40MzItMTEuMTY4LTUwLjE3Ni00OS42OTYtNTIuMjg4LTY2LjI1NiAwIDAtMy44ODgtMTcuOTItMy44ODgtNDAuODk2czMuODg4LTQ1LjE4NCAzLjg4OC00NS4xODRjMTUuNTUyLTc1LjcyOCA0My40ODgtMTA2LjczNiA5Ni4zODQtMTA2LjczNiA1OS4xMDQtLjAzMiA4My45NjggNTguNTI4IDgzLjk2OCAxMTAuMjA4eiIvPjwvc3ZnPg==';
if ( current_user_can( 'edit_others_shop_orders' ) ) {
$menu[] = array( '', 'read', 'separator-woocommerce', '', 'wp-menu-separator woocommerce' ); // WPCS: override ok.
}
add_menu_page( __( 'WooCommerce', 'woocommerce' ), __( 'WooCommerce', 'woocommerce' ), 'edit_others_shop_orders', 'woocommerce', null, null, '55.5' );
add_menu_page( __( 'WooCommerce', 'woocommerce' ), __( 'WooCommerce', 'woocommerce' ), 'edit_others_shop_orders', 'woocommerce', null, $woocommerce_icon, '55.5' );
add_submenu_page( 'edit.php?post_type=product', __( 'Attributes', 'woocommerce' ), __( 'Attributes', 'woocommerce' ), 'manage_product_terms', 'product_attributes', array( $this, 'attributes_page' ) );
}
@ -71,7 +73,7 @@ class WC_Admin_Menus {
if ( current_user_can( 'edit_others_shop_orders' ) ) {
add_submenu_page( 'woocommerce', __( 'Reports', 'woocommerce' ), __( 'Reports', 'woocommerce' ), 'view_woocommerce_reports', 'wc-reports', array( $this, 'reports_page' ) );
} else {
add_menu_page( __( 'Sales reports', 'woocommerce' ), __( 'Sales reports', 'woocommerce' ), 'view_woocommerce_reports', 'wc-reports', array( $this, 'reports_page' ), null, '55.6' );
add_menu_page( __( 'Sales reports', 'woocommerce' ), __( 'Sales reports', 'woocommerce' ), 'view_woocommerce_reports', 'wc-reports', array( $this, 'reports_page' ), 'dashicons-chart-bar', '55.6' );
}
}

View File

@ -94,6 +94,7 @@ class WC_Admin {
switch ( $screen->id ) {
case 'dashboard':
case 'dashboard-network':
include __DIR__ . '/class-wc-admin-dashboard-setup.php';
include __DIR__ . '/class-wc-admin-dashboard.php';
break;
case 'options-permalink':

View File

@ -6,6 +6,8 @@
* @version 3.2.0
*/
use Automattic\Jetpack\Constants;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
@ -37,8 +39,13 @@ class WC_Updates_Screen_Updates extends WC_Plugin_Updates {
return;
}
$version_type = Constants::get_constant( 'WC_SSR_PLUGIN_UPDATE_RELEASE_VERSION_TYPE' );
if ( ! is_string( $version_type ) ) {
$version_type = 'none';
}
$this->new_version = wc_clean( $updateable_plugins['woocommerce/woocommerce.php']->update->new_version );
$this->major_untested_plugins = $this->get_untested_plugins( $this->new_version, 'major' );
$this->major_untested_plugins = $this->get_untested_plugins( $this->new_version, $version_type );
if ( ! empty( $this->major_untested_plugins ) ) {
echo $this->get_extensions_modal_warning(); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped

View File

@ -203,7 +203,7 @@ class WC_Settings_Emails extends WC_Settings_Page {
'id' => 'woocommerce_merchant_email_notifications',
'type' => 'checkbox',
'checkboxgroup' => 'start',
'default' => 'yes',
'default' => 'no',
'autoload' => false,
),

View File

@ -64,6 +64,12 @@ class WC_Settings_Products extends WC_Settings_Page {
$settings = $this->get_settings( $current_section );
WC_Admin_Settings::save_fields( $settings );
/*
* Product->Inventory has a setting `Out of stock visibility`.
* Because of this, we need to recount the terms to keep them in-sync.
*/
wc_recount_all_terms();
if ( $current_section ) {
do_action( 'woocommerce_update_options_' . $this->id . '_' . $current_section );
}

View File

@ -66,7 +66,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<div class="wc-shipping-zone-postcodes">
<textarea name="zone_postcodes" data-attribute="zone_postcodes" id="zone_postcodes" placeholder="<?php esc_attr_e( 'List 1 postcode per line', 'woocommerce' ); ?>" class="input-text large-text" cols="25" rows="5"><?php echo esc_textarea( implode( "\n", $postcodes ) ); ?></textarea>
<?php /* translators: WooCommerce link to setting up shipping zones */ ?>
<span class="description"><?php printf( __( 'Postcodes containing wildcards (e.g. CB23*) or fully numeric ranges (e.g. <code>90210...99000</code>) are also supported. Please see the shipping zones <a href="%s" target="_blank">documentation</a>) for more information.', 'woocommerce' ), 'https://docs.woocommerce.com/document/setting-up-shipping-zones/#section-3' ); ?></span><?php // @codingStandardsIgnoreLine. ?>
<span class="description"><?php printf( __( 'Postcodes containing wildcards (e.g. CB23*) or fully numeric ranges (e.g. <code>90210...99000</code>) are also supported. Please see the shipping zones <a href="%s" target="_blank">documentation</a> for more information.', 'woocommerce' ), 'https://docs.woocommerce.com/document/setting-up-shipping-zones/#section-3' ); ?></span><?php // @codingStandardsIgnoreLine. ?>
</div>
</td>
<?php endif; ?>

View File

@ -0,0 +1,29 @@
<?php
/**
* Admin View: Dashboard - Finish Setup
*
* @package WooCommerce\Admin
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<div class="dashboard-widget-finish-setup">
<span class='progress-wrapper'>
<svg class="circle-progress" width="17" height="17" version="1.1" xmlns="http://www.w3.org/2000/svg">
<circle r="6.5" cx="10" cy="10" fill="transparent" stroke-dasharray="40.859" stroke-dashoffset="0"></circle>
<circle class="bar" r="6.5" cx="190" cy="10" fill="transparent" stroke-dasharray="40.859" stroke-dashoffset="<?php echo esc_attr( $circle_dashoffset ); ?>" transform='rotate(-90 100 100)'></circle>
</svg>
<span><?php echo esc_html_e( 'Step', 'woocommerce' ); ?> <?php echo esc_html( $completed_tasks_count ); ?> <?php echo esc_html_e( 'of', 'woocommerce' ); ?> <?php echo esc_html( $tasks_count ); ?></span>
</span>
<div class="description">
<div>
<?php echo esc_html_e( 'You\'re almost there! Once you complete store setup you can start receiving orders.', 'woocommerce' ); ?>
<div><a href='<?php echo esc_attr( $button_link ); ?>' class='button button-primary'><?php echo esc_html_e( 'Start selling', 'woocommerce' ); ?></a></div>
</div>
<img src="<?php echo esc_url( WC()->plugin_url() ); ?>/assets/images/dashboard-widget-setup.png" />
</div>
<div class="clear"></div>
</div>

View File

@ -49,11 +49,10 @@ $exporter = new WC_Product_CSV_Exporter();
<td>
<select id="woocommerce-exporter-types" class="woocommerce-exporter-types wc-enhanced-select" style="width:100%;" multiple data-placeholder="<?php esc_attr_e( 'Export all products', 'woocommerce' ); ?>">
<?php
foreach ( wc_get_product_types() as $value => $label ) {
foreach ( WC_Admin_Exporters::get_product_types() as $value => $label ) {
echo '<option value="' . esc_attr( $value ) . '">' . esc_html( $label ) . '</option>';
}
?>
<option value="variation"><?php esc_html_e( 'Product variations', 'woocommerce' ); ?></option>
</select>
</td>
</tr>

View File

@ -9,6 +9,7 @@ if ( ! defined( 'ABSPATH' ) ) {
?>
<div class="wrap woocommerce">
<?php if ( WC()->is_wc_admin_active() ) { ?>
<div id="message" class="error inline" style="margin-top:30px">
<p>
<strong>
@ -19,6 +20,7 @@ if ( ! defined( 'ABSPATH' ) ) {
</strong>
</p>
</div>
<?php } ?>
<nav class="nav-tab-wrapper woo-nav-tab-wrapper">
<?php
foreach ( $reports as $key => $report_group ) {
@ -33,7 +35,7 @@ if ( ! defined( 'ABSPATH' ) ) {
?>
</nav>
<?php
if ( sizeof( $reports[ $current_tab ]['reports'] ) > 1 ) {
if ( count( $reports[ $current_tab ]['reports'] ) > 1 ) {
?>
<ul class="subsubsub">
<li>

View File

@ -5,16 +5,12 @@
* @package WooCommerce
*/
use Automattic\Jetpack\Constants;
defined( 'ABSPATH' ) || exit;
global $wpdb;
if ( ! defined( 'WC_SSR_PLUGIN_UPDATE_RELEASE_VERSION_TYPE' ) ) {
// Define if we're checking against major or minor versions.
// Since 5.0 all versions are backwards compatible, so there's no more check.
define( 'WC_SSR_PLUGIN_UPDATE_RELEASE_VERSION_TYPE', 'none' );
}
$report = wc()->api->get_endpoint_data( '/wc/v3/system_status' );
$environment = $report['environment'];
$database = $report['database'];
@ -27,7 +23,7 @@ $security = $report['security'];
$settings = $report['settings'];
$wp_pages = $report['pages'];
$plugin_updates = new WC_Plugin_Updates();
$untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, WC_SSR_PLUGIN_UPDATE_RELEASE_VERSION_TYPE );
$untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, Constants::get_constant( 'WC_SSR_PLUGIN_UPDATE_RELEASE_VERSION_TYPE' ) );
?>
<div class="updated woocommerce-message inline">
<p>
@ -1018,3 +1014,19 @@ if ( 0 < count( $dropins_mu_plugins['mu_plugins'] ) ) :
</table>
<?php do_action( 'woocommerce_system_status_report' ); ?>
<table class="wc_status_table widefat" cellspacing="0">
<thead>
<tr>
<th colspan="3" data-export-label="Status report information"><h2><?php esc_html_e( 'Status report information', 'woocommerce' ); ?><?php echo wc_help_tip( esc_html__( 'This section shows information about this status report.', 'woocommerce' ) ); ?></h2></th>
</tr>
</thead>
<tbody>
<tr>
<td data-export-label="Generated at"><?php esc_html_e( 'Generated at', 'woocommerce' ); ?>:</td>
<td class="help">&nbsp;</td>
<td><?php echo esc_html( current_time( 'Y-m-d H:i:s P' ) ); ?></td>
</tr>
</tbody>
</table>

View File

@ -1273,7 +1273,6 @@ class WC_AJAX {
}
if ( ! empty( $order_item_ids ) ) {
$order_notes = array();
foreach ( $order_item_ids as $item_id ) {
$item_id = absint( $item_id );
@ -1300,6 +1299,18 @@ class WC_AJAX {
$order->calculate_taxes( $calculate_tax_args );
$order->calculate_totals( false );
/**
* Fires after order items are removed.
*
* @since 5.2.0
*
* @param int $item_id WC item ID.
* @param WC_Order_Item|false $item As returned by $order->get_item( $item_id ).
* @param bool|array|WP_Error $changed_store Result of wc_maybe_adjust_line_item_product_stock().
* @param bool|WC_Order|WC_Order_Refund $order As returned by wc_get_order().
*/
do_action( 'woocommerce_ajax_order_items_removed', $item_id, $item, $changed_stock, $order );
// Get HTML to return.
ob_start();
include __DIR__ . '/admin/meta-boxes/views/html-order-items.php';
@ -1871,7 +1882,7 @@ class WC_AJAX {
$order = wc_get_order( $order_id );
$max_refund = wc_format_decimal( $order->get_total() - $order->get_total_refunded(), wc_get_price_decimals() );
if ( ! $refund_amount || $max_refund < $refund_amount || 0 > $refund_amount ) {
if ( ( ! $refund_amount && ( wc_format_decimal( 0, wc_get_price_decimals() ) !== $refund_amount ) ) || $max_refund < $refund_amount || 0 > $refund_amount ) {
throw new Exception( __( 'Invalid refund amount', 'woocommerce' ) );
}

View File

@ -26,6 +26,7 @@ class WC_Cache_Helper {
add_filter( 'nocache_headers', array( __CLASS__, 'additional_nocache_headers' ), 10 );
add_action( 'shutdown', array( __CLASS__, 'delete_transients_on_shutdown' ), 10 );
add_action( 'template_redirect', array( __CLASS__, 'geolocation_ajax_redirect' ) );
add_action( 'wc_ajax_update_order_review', array( __CLASS__, 'update_geolocation_hash' ), 5 );
add_action( 'admin_notices', array( __CLASS__, 'notices' ) );
add_action( 'delete_version_transients', array( __CLASS__, 'delete_version_transients' ), 10 );
add_action( 'wp', array( __CLASS__, 'prevent_caching' ) );
@ -190,6 +191,24 @@ class WC_Cache_Helper {
}
}
/**
* Updates the `woocommerce_geo_hash` cookie, which is used to help ensure we display
* the correct pricing etc to customers, according to their billing country.
*
* Note that:
*
* A) This only sets the cookie if the default customer address is set to "Geolocate (with
* Page Caching Support)".
*
* B) It is hooked into the `wc_ajax_update_order_review` action, which has the benefit of
* ensuring we update the cookie any time the billing country is changed.
*/
public static function update_geolocation_hash() {
if ( 'geolocation_ajax' === get_option( 'woocommerce_default_customer_address' ) ) {
wc_setcookie( 'woocommerce_geo_hash', static::geolocation_ajax_get_location_hash(), time() + HOUR_IN_SECONDS );
}
}
/**
* Get transient version.
*

View File

@ -1120,6 +1120,20 @@ class WC_Cart extends WC_Legacy_Cart {
}
}
// Validate variation ID.
if (
0 < $variation_id && // Only check if there's any variation_id.
(
! $product_data->is_type( 'variation' ) || // Check if isn't a variation, it suppose to be a variation at this point.
$product_data->get_parent_id() !== $product_id // Check if belongs to the selected variable product.
)
) {
$product = wc_get_product( $product_id );
/* translators: 1: product link, 2: product name */
throw new Exception( sprintf( __( 'The selected product isn\'t a variation of %2$s, please choose product options by visiting <a href="%1$s" title="%2$s">%2$s</a>.', 'woocommerce' ), esc_url( $product->get_permalink() ), esc_html( $product->get_name() ) ) );
}
// Load cart item data - may be added by other plugins.
$cart_item_data = (array) apply_filters( 'woocommerce_add_cart_item_data', $cart_item_data, $product_id, $variation_id, $quantity );

View File

@ -688,23 +688,25 @@ class WC_Checkout {
foreach ( $fieldset as $key => $field ) {
$type = sanitize_title( isset( $field['type'] ) ? $field['type'] : 'text' );
// phpcs:disable WordPress.Security.NonceVerification.Missing
switch ( $type ) {
case 'checkbox':
$value = isset( $_POST[ $key ] ) ? 1 : ''; // WPCS: input var ok, CSRF ok.
$value = isset( $_POST[ $key ] ) ? 1 : '';
break;
case 'multiselect':
$value = isset( $_POST[ $key ] ) ? implode( ', ', wc_clean( wp_unslash( $_POST[ $key ] ) ) ) : ''; // WPCS: input var ok, CSRF ok.
$value = isset( $_POST[ $key ] ) ? implode( ', ', wc_clean( wp_unslash( $_POST[ $key ] ) ) ) : '';
break;
case 'textarea':
$value = isset( $_POST[ $key ] ) ? wc_sanitize_textarea( wp_unslash( $_POST[ $key ] ) ) : ''; // WPCS: input var ok, CSRF ok.
$value = isset( $_POST[ $key ] ) ? wc_sanitize_textarea( wp_unslash( $_POST[ $key ] ) ) : '';
break;
case 'password':
$value = isset( $_POST[ $key ] ) ? wp_unslash( $_POST[ $key ] ) : ''; // WPCS: input var ok, CSRF ok, sanitization ok.
$value = isset( $_POST[ $key ] ) ? wp_unslash( $_POST[ $key ] ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
break;
default:
$value = isset( $_POST[ $key ] ) ? wc_clean( wp_unslash( $_POST[ $key ] ) ) : ''; // WPCS: input var ok, CSRF ok.
$value = isset( $_POST[ $key ] ) ? wc_clean( wp_unslash( $_POST[ $key ] ) ) : '';
break;
}
// phpcs:enable WordPress.Security.NonceVerification.Missing
$data[ $key ] = apply_filters( 'woocommerce_process_checkout_' . $type . '_field', apply_filters( 'woocommerce_process_checkout_field_' . $key, $value ) );
}
@ -744,6 +746,13 @@ class WC_Checkout {
$format = array_filter( isset( $field['validate'] ) ? (array) $field['validate'] : array() );
$field_label = isset( $field['label'] ) ? $field['label'] : '';
if ( $validate_fieldset &&
( isset( $field['type'] ) && 'country' === $field['type'] ) &&
! WC()->countries->country_exists( $data[ $key ] ) ) {
/* translators: ISO 3166-1 alpha-2 country code */
$errors->add( $key . '_validation', sprintf( __( "'%s' is not a valid country code.", 'woocommerce' ), $data[ $key ] ) );
}
switch ( $fieldset_key ) {
case 'shipping':
/* translators: %s: field name */
@ -830,18 +839,21 @@ class WC_Checkout {
$this->validate_posted_data( $data, $errors );
$this->check_cart_items();
if ( empty( $data['woocommerce_checkout_update_totals'] ) && empty( $data['terms'] ) && ! empty( $_POST['terms-field'] ) ) { // WPCS: input var ok, CSRF ok.
// phpcs:ignore WordPress.Security.NonceVerification.Missing
if ( empty( $data['woocommerce_checkout_update_totals'] ) && empty( $data['terms'] ) && ! empty( $_POST['terms-field'] ) ) {
$errors->add( 'terms', __( 'Please read and accept the terms and conditions to proceed with your order.', 'woocommerce' ) );
}
if ( WC()->cart->needs_shipping() ) {
$shipping_country = WC()->customer->get_shipping_country();
$shipping_country = isset( $data['shipping_country'] ) ? $data['shipping_country'] : WC()->customer->get_shipping_country();
if ( empty( $shipping_country ) ) {
$errors->add( 'shipping', __( 'Please enter an address to continue.', 'woocommerce' ) );
} elseif ( ! in_array( WC()->customer->get_shipping_country(), array_keys( WC()->countries->get_shipping_countries() ), true ) ) {
/* translators: %s: shipping location */
$errors->add( 'shipping', sprintf( __( 'Unfortunately <strong>we do not ship %s</strong>. Please enter an alternative shipping address.', 'woocommerce' ), WC()->countries->shipping_to_prefix() . ' ' . WC()->customer->get_shipping_country() ) );
} elseif ( ! in_array( $shipping_country, array_keys( WC()->countries->get_shipping_countries() ), true ) ) {
if ( WC()->countries->country_exists( $shipping_country ) ) {
/* translators: %s: shipping location (prefix e.g. 'to' + ISO 3166-1 alpha-2 country code) */
$errors->add( 'shipping', sprintf( __( 'Unfortunately <strong>we do not ship %s</strong>. Please enter an alternative shipping address.', 'woocommerce' ), WC()->countries->shipping_to_prefix() . ' ' . $shipping_country ) );
}
} else {
$chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods' );
@ -963,7 +975,7 @@ class WC_Checkout {
$result = apply_filters( 'woocommerce_payment_successful_result', $result, $order_id );
if ( ! is_ajax() ) {
wp_redirect( $result['redirect'] );
wp_safe_redirect( $result['redirect'] );
exit;
}
@ -1203,8 +1215,8 @@ class WC_Checkout {
*/
public function get_value( $input ) {
// If the form was posted, get the posted value. This will only tend to happen when JavaScript is disabled client side.
if ( ! empty( $_POST[ $input ] ) ) { // WPCS: input var ok, CSRF OK.
return wc_clean( wp_unslash( $_POST[ $input ] ) ); // WPCS: input var ok, CSRF OK.
if ( ! empty( $_POST[ $input ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
return wc_clean( wp_unslash( $_POST[ $input ] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
}
// Allow 3rd parties to short circuit the logic and return their own default value.

View File

@ -57,6 +57,17 @@ class WC_Countries {
return $this->countries;
}
/**
* Check if a given code represents a valid ISO 3166-1 alpha-2 code for a country known to us.
*
* @since 5.1.0
* @param string $country_code The country code to check as a ISO 3166-1 alpha-2 code.
* @return bool True if the country is known to us, false otherwise.
*/
public function country_exists( $country_code ) {
return isset( $this->get_countries()[ $country_code ] );
}
/**
* Get all continents.
*
@ -591,7 +602,12 @@ class WC_Countries {
array(
'{first_name}' => $args['first_name'],
'{last_name}' => $args['last_name'],
'{name}' => $args['first_name'] . ' ' . $args['last_name'],
'{name}' => sprintf(
/* translators: 1: first name 2: last name */
_x( '%1$s %2$s', 'full name', 'woocommerce' ),
$args['first_name'],
$args['last_name']
),
'{company}' => $args['company'],
'{address_1}' => $args['address_1'],
'{address_2}' => $args['address_2'],
@ -601,7 +617,14 @@ class WC_Countries {
'{country}' => $full_country,
'{first_name_upper}' => wc_strtoupper( $args['first_name'] ),
'{last_name_upper}' => wc_strtoupper( $args['last_name'] ),
'{name_upper}' => wc_strtoupper( $args['first_name'] . ' ' . $args['last_name'] ),
'{name_upper}' => wc_strtoupper(
sprintf(
/* translators: 1: first name 2: last name */
_x( '%1$s %2$s', 'full name', 'woocommerce' ),
$args['first_name'],
$args['last_name']
)
),
'{company_upper}' => wc_strtoupper( $args['company'] ),
'{address_1_upper}' => wc_strtoupper( $args['address_1'] ),
'{address_2_upper}' => wc_strtoupper( $args['address_2'] ),
@ -647,10 +670,14 @@ class WC_Countries {
* @return array
*/
public function get_default_address_fields() {
$address_2_label = __( 'Apartment, suite, unit, etc.', 'woocommerce' );
// If necessary, append '(optional)' to the placeholder: we don't need to worry about the
// label, though, as woocommerce_form_field() takes care of that.
if ( 'optional' === get_option( 'woocommerce_checkout_address_2_field', 'optional' ) ) {
$address_2_placeholder = __( 'Apartment, suite, unit, etc. (optional)', 'woocommerce' );
} else {
$address_2_placeholder = __( 'Apartment, suite, unit, etc.', 'woocommerce' );
$address_2_placeholder = $address_2_label;
}
$fields = array(
@ -693,6 +720,8 @@ class WC_Countries {
'priority' => 50,
),
'address_2' => array(
'label' => $address_2_label,
'label_class' => array( 'screen-reader-text' ),
'placeholder' => esc_attr( $address_2_placeholder ),
'class' => array( 'form-row-wide', 'address-field' ),
'autocomplete' => 'address-line2',

View File

@ -398,7 +398,12 @@ class WC_Frontend_Scripts {
self::enqueue_script( 'wc-single-product' );
}
if ( 'geolocation_ajax' === get_option( 'woocommerce_default_customer_address' ) ) {
// Only enqueue the geolocation script if the Default Current Address is set to "Geolocate
// (with Page Caching Support) and outside of the cart, checkout, account and customizer preview.
if (
'geolocation_ajax' === get_option( 'woocommerce_default_customer_address' )
&& ! ( is_cart() || is_account_page() || is_checkout() || is_customize_preview() )
) {
$ua = strtolower( wc_get_user_agent() ); // Exclude common bots from geolocation by user agent.
if ( ! strstr( $ua, 'bot' ) && ! strstr( $ua, 'spider' ) && ! strstr( $ua, 'crawl' ) ) {
@ -473,8 +478,6 @@ class WC_Frontend_Scripts {
$params = array(
'wc_ajax_url' => WC_AJAX::get_endpoint( '%%endpoint%%' ),
'home_url' => remove_query_arg( 'lang', home_url() ), // FIX for WPML compatibility.
'is_available' => ! ( is_cart() || is_account_page() || is_checkout() || is_customize_preview() ) ? '1' : '0',
'hash' => isset( $_GET['v'] ) ? wc_clean( wp_unslash( $_GET['v'] ) ) : '', // WPCS: input var ok, CSRF ok.
);
break;
case 'wc-single-product':

View File

@ -525,7 +525,8 @@ class WC_Install {
$held_duration = get_option( 'woocommerce_hold_stock_minutes', '60' );
if ( '' !== $held_duration ) {
wp_schedule_single_event( time() + ( absint( $held_duration ) * 60 ), 'woocommerce_cancel_unpaid_orders' );
$cancel_unpaid_interval = apply_filters( 'woocommerce_cancel_unpaid_orders_interval_minutes', absint( $held_duration ) );
wp_schedule_single_event( time() + ( absint( $cancel_unpaid_interval ) * 60 ), 'woocommerce_cancel_unpaid_orders' );
}
// Delay the first run of `woocommerce_cleanup_personal_data` by 10 seconds

View File

@ -907,7 +907,7 @@ class WC_Order extends WC_Abstract_Order {
$address = WC()->countries->get_formatted_address( $raw_address );
/**
* Filter orders formatterd billing address.
* Filter orders formatted billing address.
*
* @since 3.8.0
* @param string $address Formatted billing address string.
@ -933,7 +933,7 @@ class WC_Order extends WC_Abstract_Order {
}
/**
* Filter orders formatterd shipping address.
* Filter orders formatted shipping address.
*
* @since 3.8.0
* @param string $address Formatted billing address string.

View File

@ -339,6 +339,7 @@ class WC_Post_Types {
'description' => __( 'This is where you can add new products to your store.', 'woocommerce' ),
'public' => true,
'show_ui' => true,
'menu_icon' => 'dashicons-archive',
'capability_type' => 'product',
'map_meta_cap' => true,
'publicly_queryable' => true,

View File

@ -28,7 +28,28 @@ class WC_Privacy extends WC_Abstract_Privacy {
* Init - hook into events.
*/
public function __construct() {
parent::__construct( __( 'WooCommerce', 'woocommerce' ) );
parent::__construct();
// Initialize data exporters and erasers.
add_action( 'plugins_loaded', array( $this, 'register_erasers_exporters' ) );
// Cleanup orders daily - this is a callback on a daily cron event.
add_action( 'woocommerce_cleanup_personal_data', array( $this, 'queue_cleanup_personal_data' ) );
// Handles custom anonomization types not included in core.
add_filter( 'wp_privacy_anonymize_data', array( $this, 'anonymize_custom_data_types' ), 10, 3 );
// When this is fired, data is removed in a given order. Called from bulk actions.
add_action( 'woocommerce_remove_order_personal_data', array( 'WC_Privacy_Erasers', 'remove_order_personal_data' ) );
}
/**
* Initial registration of privacy erasers and exporters.
*
* Due to the use of translation functions, this should run only after plugins loaded.
*/
public function register_erasers_exporters() {
$this->name = __( 'WooCommerce', 'woocommerce' );
if ( ! self::$background_process ) {
self::$background_process = new WC_Privacy_Background_Process();
@ -49,15 +70,6 @@ class WC_Privacy extends WC_Abstract_Privacy {
$this->add_eraser( 'woocommerce-customer-orders', __( 'WooCommerce Customer Orders', 'woocommerce' ), array( 'WC_Privacy_Erasers', 'order_data_eraser' ) );
$this->add_eraser( 'woocommerce-customer-downloads', __( 'WooCommerce Customer Downloads', 'woocommerce' ), array( 'WC_Privacy_Erasers', 'download_data_eraser' ) );
$this->add_eraser( 'woocommerce-customer-tokens', __( 'WooCommerce Customer Payment Tokens', 'woocommerce' ), array( 'WC_Privacy_Erasers', 'customer_tokens_eraser' ) );
// Cleanup orders daily - this is a callback on a daily cron event.
add_action( 'woocommerce_cleanup_personal_data', array( $this, 'queue_cleanup_personal_data' ) );
// Handles custom anonomization types not included in core.
add_filter( 'wp_privacy_anonymize_data', array( $this, 'anonymize_custom_data_types' ), 10, 3 );
// When this is fired, data is removed in a given order. Called from bulk actions.
add_action( 'woocommerce_remove_order_personal_data', array( 'WC_Privacy_Erasers', 'remove_order_personal_data' ) );
}
/**

View File

@ -52,7 +52,15 @@ class WC_Product_Download implements ArrayAccess {
*/
public function get_type_of_file_path( $file_path = '' ) {
$file_path = $file_path ? $file_path : $this->get_file();
if ( 0 === strpos( $file_path, 'http' ) || 0 === strpos( $file_path, '//' ) ) {
$parsed_url = parse_url( $file_path );
if (
$parsed_url &&
isset( $parsed_url['host'] ) && // Absolute url means that it has a host.
( // Theoretically we could permit any scheme (like ftp as well), but that has not been the case before. So we allow none or http(s).
! isset( $parsed_url['scheme'] ) ||
in_array( $parsed_url['scheme'], array( 'http', 'https' ) )
)
) {
return 'absolute';
} elseif ( '[' === substr( $file_path, 0, 1 ) && ']' === substr( $file_path, -1 ) ) {
return 'shortcode';
@ -164,6 +172,11 @@ class WC_Product_Download implements ArrayAccess {
* @param string $value File URL/Path.
*/
public function set_file( $value ) {
// A `///` is recognized as an "absolute", but on the filesystem, so it bypasses the mime check in `self::is_allowed_filetype`.
// This will strip extra prepending / to the maximum of 2.
if ( preg_match( '#^//+(/[^/].+)$#i', $value, $matches ) ) {
$value = $matches[1];
}
switch ( $this->get_type_of_file_path( $value ) ) {
case 'absolute':
$this->data['file'] = esc_url_raw( $value );

View File

@ -622,9 +622,9 @@ class WC_Query {
$args['join'] = $this->append_product_sorting_table_join( $args['join'] );
$args['where'] .= $wpdb->prepare(
' AND wc_product_meta_lookup.min_price >= %f AND wc_product_meta_lookup.max_price <= %f ',
$current_min_price,
$current_max_price
' AND NOT (%f<wc_product_meta_lookup.min_price OR %f>wc_product_meta_lookup.max_price ) ',
$current_max_price,
$current_min_price
);
return $args;
}

View File

@ -162,7 +162,7 @@ class WC_Shipping_Rate {
}
/**
* Set ID for the rate. This is usually a combination of the method and instance IDs.
* Get ID for the rate. This is usually a combination of the method and instance IDs.
*
* @since 3.2.0
* @return string
@ -172,7 +172,7 @@ class WC_Shipping_Rate {
}
/**
* Set shipping method ID the rate belongs to.
* Get shipping method ID the rate belongs to.
*
* @since 3.2.0
* @return string
@ -182,7 +182,7 @@ class WC_Shipping_Rate {
}
/**
* Set instance ID the rate belongs to.
* Get instance ID the rate belongs to.
*
* @since 3.2.0
* @return int
@ -192,7 +192,7 @@ class WC_Shipping_Rate {
}
/**
* Set rate label.
* Get rate label.
*
* @return string
*/
@ -201,7 +201,7 @@ class WC_Shipping_Rate {
}
/**
* Set rate cost.
* Get rate cost.
*
* @since 3.2.0
* @return string
@ -211,7 +211,7 @@ class WC_Shipping_Rate {
}
/**
* Set rate taxes.
* Get rate taxes.
*
* @since 3.2.0
* @return array

View File

@ -405,7 +405,7 @@ class WC_Tax {
$criteria_string = implode( ' AND ', $criteria );
// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
// phpcs:disable WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
$found_rates = $wpdb->get_results(
"
SELECT tax_rates.*, COUNT( locations.location_id ) as postcode_count, COUNT( locations2.location_id ) as city_count
@ -481,6 +481,20 @@ class WC_Tax {
public static function get_rates( $tax_class = '', $customer = null ) {
$tax_class = sanitize_title( $tax_class );
$location = self::get_tax_location( $tax_class, $customer );
return self::get_rates_from_location( $tax_class, $location, $customer );
}
/**
* Get's an arrau of matching rates from location and tax class. $customer parameter is used to preserve backward compatibility for filter.
*
* @param string $tax_class Tax class to get rates for.
* @param array $location Location to compute rates for. Should be in form: array( country, state, postcode, city).
* @param object $customer Only used to maintain backward compatibility for filter `woocommerce-matched_rates`.
*
* @return mixed|void Tax rates.
*/
public static function get_rates_from_location( $tax_class, $location, $customer = null ) {
$tax_class = sanitize_title( $tax_class );
$matched_tax_rates = array();
if ( count( $location ) === 4 ) {
@ -747,7 +761,7 @@ class WC_Tax {
* @since 3.7.0
* @return array Array of tax class objects consisting of tax_rate_class_id, name, and slug.
*/
protected static function get_tax_rate_classes() {
public static function get_tax_rate_classes() {
global $wpdb;
$cache_key = 'tax-rate-classes';

View File

@ -166,6 +166,9 @@ class WC_Tracker {
// Cart & checkout tech (blocks or shortcodes).
$data['cart_checkout'] = self::get_cart_checkout_info();
// WooCommerce Admin info.
$data['wc_admin_disabled'] = apply_filters( 'woocommerce_admin_disabled', false ) ? 'yes' : 'no';
return apply_filters( 'woocommerce_tracker_data', $data );
}

View File

@ -23,7 +23,7 @@ final class WooCommerce {
*
* @var string
*/
public $version = '5.1.0';
public $version = '5.2.0';
/**
* WooCommerce Schema version.
@ -249,6 +249,18 @@ final class WooCommerce {
$this->define( 'WC_NOTICE_MIN_PHP_VERSION', '7.2' );
$this->define( 'WC_NOTICE_MIN_WP_VERSION', '5.2' );
$this->define( 'WC_PHP_MIN_REQUIREMENTS_NOTICE', 'wp_php_min_requirements_' . WC_NOTICE_MIN_PHP_VERSION . '_' . WC_NOTICE_MIN_WP_VERSION );
/** Define if we're checking against major, minor or no versions in the following places:
* - plugin screen in WP Admin (displaying extra warning when updating to new major versions)
* - System Status Report ('Installed version not tested with active version of WooCommerce' warning)
* - core update screen in WP Admin (displaying extra warning when updating to new major versions)
* - enable/disable automated updates in the plugin screen in WP Admin (if there are any plugins
* that don't declare compatibility, the auto-update is disabled)
*
* We dropped SemVer before WC 5.0, so all versions are backwards compatible now, thus no more check needed.
* The SSR in the name is preserved for bw compatibility, as this was initially used in System Status Report.
*/
$this->define( 'WC_SSR_PLUGIN_UPDATE_RELEASE_VERSION_TYPE', 'none' );
}
/**

View File

@ -818,7 +818,7 @@ class WC_Shop_Customizer {
'description' => __( 'Optionally add some text about your store privacy policy to show during checkout.', 'woocommerce' ),
'section' => 'woocommerce_checkout',
'settings' => 'woocommerce_checkout_privacy_policy_text',
'active_callback' => 'wc_privacy_policy_page_id',
'active_callback' => array( $this, 'has_privacy_policy_page_id' ),
'type' => 'textarea',
)
);
@ -830,7 +830,7 @@ class WC_Shop_Customizer {
'description' => __( 'Optionally add some text for the terms checkbox that customers must accept.', 'woocommerce' ),
'section' => 'woocommerce_checkout',
'settings' => 'woocommerce_checkout_terms_and_conditions_checkbox_text',
'active_callback' => 'wc_terms_and_conditions_page_id',
'active_callback' => array( $this, 'has_terms_and_conditions_page_id' ),
'type' => 'text',
)
);
@ -865,6 +865,24 @@ class WC_Shop_Customizer {
$options = array( 'hidden', 'optional', 'required' );
return in_array( $value, $options, true ) ? $value : '';
}
/**
* Whether or not a page has been chose for the privacy policy.
*
* @return bool
*/
public function has_privacy_policy_page_id() {
return wc_privacy_policy_page_id() > 0;
}
/**
* Whether or not a page has been chose for the terms and conditions.
*
* @return bool
*/
public function has_terms_and_conditions_page_id() {
return wc_terms_and_conditions_page_id() > 0;
}
}
new WC_Shop_Customizer();

View File

@ -710,6 +710,8 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
if ( $force || array_key_exists( 'shipping_class_id', $changes ) ) {
wp_set_post_terms( $product->get_id(), array( $product->get_shipping_class_id( 'edit' ) ), 'product_shipping_class', false );
}
_wc_recount_terms_by_product( $product->get_id() );
}
/**

View File

@ -100,7 +100,7 @@ if ( ! class_exists( 'WC_Email_New_Order' ) ) :
* Controls if new order emails can be resend multiple times.
*
* @since 5.0.0
* @param bool $allows Defaults to true.
* @param bool $allows Defaults to false.
*/
if ( 'true' === $email_already_sent && ! apply_filters( 'woocommerce_new_order_email_allows_resend', false ) ) {
return;

View File

@ -55,7 +55,7 @@ class WC_Product_CSV_Exporter extends WC_CSV_Batch_Exporter {
*/
public function __construct() {
parent::__construct();
$this->set_product_types_to_export( array_merge( array_keys( wc_get_product_types() ), array( 'variation' ) ) );
$this->set_product_types_to_export( array_keys( WC_Admin_Exporters::get_product_types() ) );
}
/**

View File

@ -174,10 +174,8 @@ abstract class WC_Product_Importer implements WC_Importer_Interface {
// Type is the most important part here because we need to be using the correct class and methods.
if ( isset( $data['type'] ) ) {
$types = array_keys( wc_get_product_types() );
$types[] = 'variation';
if ( ! in_array( $data['type'], $types, true ) ) {
if ( ! array_key_exists( $data['type'], WC_Admin_Exporters::get_product_types() ) ) {
return new WP_Error( 'woocommerce_product_importer_invalid_type', __( 'Invalid product type.', 'woocommerce' ), array( 'status' => 401 ) );
}

View File

@ -4,8 +4,6 @@
*
* Handles requests to the products/attributes endpoint.
*
* @author WooThemes
* @category API
* @package WooCommerce\RestApi
* @since 3.0.0
*/
@ -43,11 +41,21 @@ class WC_REST_Product_Attributes_V1_Controller extends WC_REST_Controller {
*/
protected $attribute = '';
/**
* Cached taxonomies by attribute id.
*
* @var array
*/
protected $taxonomies_by_id = array();
/**
* Register the routes for product attributes.
*/
public function register_routes() {
register_rest_route( $this->namespace, '/' . $this->rest_base, array(
register_rest_route(
$this->namespace,
'/' . $this->rest_base,
array(
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $this, 'get_items' ),
@ -58,18 +66,25 @@ class WC_REST_Product_Attributes_V1_Controller extends WC_REST_Controller {
'methods' => WP_REST_Server::CREATABLE,
'callback' => array( $this, 'create_item' ),
'permission_callback' => array( $this, 'create_item_permissions_check' ),
'args' => array_merge( $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), array(
'args' => array_merge(
$this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ),
array(
'name' => array(
'description' => __( 'Name for the resource.', 'woocommerce' ),
'type' => 'string',
'required' => true,
),
) ),
)
),
),
'schema' => array( $this, 'get_public_item_schema' ),
));
)
);
register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array(
register_rest_route(
$this->namespace,
'/' . $this->rest_base . '/(?P<id>[\d]+)',
array(
'args' => array(
'id' => array(
'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
@ -103,9 +118,13 @@ class WC_REST_Product_Attributes_V1_Controller extends WC_REST_Controller {
),
),
'schema' => array( $this, 'get_public_item_schema' ),
) );
)
);
register_rest_route( $this->namespace, '/' . $this->rest_base . '/batch', array(
register_rest_route(
$this->namespace,
'/' . $this->rest_base . '/batch',
array(
array(
'methods' => WP_REST_Server::EDITABLE,
'callback' => array( $this, 'batch_items' ),
@ -113,7 +132,8 @@ class WC_REST_Product_Attributes_V1_Controller extends WC_REST_Controller {
'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ),
),
'schema' => array( $this, 'get_public_batch_schema' ),
) );
)
);
}
/**
@ -216,7 +236,7 @@ class WC_REST_Product_Attributes_V1_Controller extends WC_REST_Controller {
/**
* Get all attributes.
*
* @param WP_REST_Request $request
* @param WP_REST_Request $request The request to get the attributes from.
* @return array
*/
public function get_items( $request ) {
@ -246,13 +266,15 @@ class WC_REST_Product_Attributes_V1_Controller extends WC_REST_Controller {
public function create_item( $request ) {
global $wpdb;
$id = wc_create_attribute( array(
$id = wc_create_attribute(
array(
'name' => $request['name'],
'slug' => wc_sanitize_taxonomy_name( stripslashes( $request['slug'] ) ),
'type' => ! empty( $request['type'] ) ? $request['type'] : 'select',
'order_by' => ! empty( $request['order_by'] ) ? $request['order_by'] : 'menu_order',
'has_archives' => true === $request['has_archives'],
) );
)
);
// Checks for errors.
if ( is_wp_error( $id ) ) {
@ -313,13 +335,16 @@ class WC_REST_Product_Attributes_V1_Controller extends WC_REST_Controller {
global $wpdb;
$id = (int) $request['id'];
$edited = wc_update_attribute( $id, array(
$edited = wc_update_attribute(
$id,
array(
'name' => $request['name'],
'slug' => wc_sanitize_taxonomy_name( stripslashes( $request['slug'] ) ),
'type' => $request['type'],
'order_by' => $request['order_by'],
'has_archives' => $request['has_archives'],
) );
)
);
// Checks for errors.
if ( is_wp_error( $edited ) ) {
@ -394,8 +419,8 @@ class WC_REST_Product_Attributes_V1_Controller extends WC_REST_Controller {
* Prepare a single product attribute output for response.
*
* @param obj $item Term object.
* @param WP_REST_Request $request
* @return WP_REST_Response $response
* @param WP_REST_Request $request The request to process.
* @return WP_REST_Response
*/
public function prepare_item_for_response( $item, $request ) {
$data = array(
@ -525,17 +550,22 @@ class WC_REST_Product_Attributes_V1_Controller extends WC_REST_Controller {
* @return string
*/
protected function get_taxonomy( $request ) {
if ( '' !== $this->attribute ) {
return $this->attribute;
$attribute_id = $request['id'];
if ( empty( $attribute_id ) ) {
return '';
}
if ( $request['id'] ) {
$name = wc_attribute_taxonomy_name_by_id( (int) $request['id'] );
$this->attribute = $name;
if ( isset( $this->taxonomies_by_id[ $attribute_id ] ) ) {
return $this->taxonomies_by_id[ $attribute_id ];
}
return $this->attribute;
$taxonomy = WC()->call_function( 'wc_attribute_taxonomy_name_by_id', (int) $request['id'] );
if ( ! empty( $taxonomy ) ) {
$this->taxonomies_by_id[ $attribute_id ] = $taxonomy;
}
return $taxonomy;
}
/**
@ -547,11 +577,16 @@ class WC_REST_Product_Attributes_V1_Controller extends WC_REST_Controller {
protected function get_attribute( $id ) {
global $wpdb;
$attribute = $wpdb->get_row( $wpdb->prepare( "
$attribute = $wpdb->get_row(
$wpdb->prepare(
"
SELECT *
FROM {$wpdb->prefix}woocommerce_attribute_taxonomies
WHERE attribute_id = %d
", $id ) );
",
$id
)
);
if ( is_wp_error( $attribute ) || is_null( $attribute ) ) {
return new WP_Error( 'woocommerce_rest_attribute_invalid', __( 'Resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) );
@ -564,16 +599,19 @@ class WC_REST_Product_Attributes_V1_Controller extends WC_REST_Controller {
* Validate attribute slug.
*
* @deprecated 3.2.0
* @param string $slug
* @param bool $new_data
* @param string $slug The slug to validate.
* @param bool $new_data If we are creating new data.
* @return bool|WP_Error
*/
protected function validate_attribute_slug( $slug, $new_data = true ) {
if ( strlen( $slug ) >= 28 ) {
/* translators: %s: slug being validated */
return new WP_Error( 'woocommerce_rest_invalid_product_attribute_slug_too_long', sprintf( __( 'Slug "%s" is too long (28 characters max). Shorten it, please.', 'woocommerce' ), $slug ), array( 'status' => 400 ) );
} elseif ( wc_check_if_attribute_name_is_reserved( $slug ) ) {
/* translators: %s: slug being validated */
return new WP_Error( 'woocommerce_rest_invalid_product_attribute_slug_reserved_name', sprintf( __( 'Slug "%s" is not allowed because it is a reserved term. Change it, please.', 'woocommerce' ), $slug ), array( 'status' => 400 ) );
} elseif ( $new_data && taxonomy_exists( wc_attribute_taxonomy_name( $slug ) ) ) {
/* translators: %s: slug being validated */
return new WP_Error( 'woocommerce_rest_invalid_product_attribute_slug_already_exists', sprintf( __( 'Slug "%s" is already in use. Change it, please.', 'woocommerce' ), $slug ), array( 'status' => 400 ) );
}

View File

@ -348,7 +348,7 @@ class WC_REST_Order_Refunds_V2_Controller extends WC_REST_Orders_V2_Controller {
}
/**
* Get the Order's schema, conforming to JSON Schema.
* Get the refund schema, conforming to JSON Schema.
*
* @return array
*/

Some files were not shown because too many files have changed in this diff Show More