Merge pull request #2 from woocommerce/master

update
This commit is contained in:
Rami Yushuvaev 2017-03-13 06:02:37 +02:00 committed by GitHub
commit 9382556534
419 changed files with 28521 additions and 14143 deletions

10
.gitattributes vendored Normal file
View File

@ -0,0 +1,10 @@
/.* export-ignore
apigen* export-ignore
CHANGELOG.txt export-ignore
composer.* export-ignore
Gruntfile.js export-ignore
package.json export-ignore
phpcs.ruleset.xml export-ignore
phpunit.* export-ignore
README.md export-ignore
tests export-ignore

View File

@ -6,7 +6,7 @@ When contributing please ensure you follow the guidelines below to help us keep
__Please Note:__
GitHub is for _bug reports and contributions only_ - if you have a support question or a request for a customization this is not the right place to post it. Use [WooThemes Support](https://support.woothemes.com) for customer support, [WordPress.org](https://wordpress.org/support/plugin/woocommerce) for community support, and for customizations we recommend one of the following services:
GitHub is for _bug reports and contributions only_ - if you have a support question or a request for a customization this is not the right place to post it. Use [WooCommerce Support](https://support.woocommerce.com) for customer support, [WordPress.org](https://wordpress.org/support/plugin/woocommerce) for community support, and for customizations we recommend one of the following services:
- [WooExperts](https://woocommerce.com/experts/)
- [Codeable](https://codeable.io/)
@ -86,7 +86,7 @@ If WooCommerce is already 100% translated for your language, join the team anywa
### Translating Video Tutorials
Another valuable way to help is by translating our growing library of WooCommerce video tutorials. Check out our [Video SRTs project](https://www.transifex.com/projects/p/video-srts/) and join the team for your language. If there isn't one, please request the new language and we will add it for you.
Another valuable way to help is by translating our growing library of WooCommerce video tutorials. Check out the [Translating Our Videos](https://docs.woocommerce.com/document/translating-our-videos/) doc and join in!
By translating video tutorials you'll be helping non-English speaking users and people affected by disabilities to get to grips with using WooCommerce for the first time, and to go on and create their businesses and make a living! That's something to be proud of and if you choose to dive into this area, we salute you.
@ -96,4 +96,4 @@ By translating video tutorials you'll be helping non-English speaking users and
* [GitHub pull request documentation](https://help.github.com/send-pull-requests/)
* [Translator Handbook](https://make.wordpress.org/polyglots/handbook/)
* [WooCommerce Docs](https://docs.woocommerce.com/)
* [WooThemes Support](https://support.woothemes.com)
* [WooCommerce Support](https://support.woocommerce.com)

BIN
.github/wiki.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 KiB

View File

@ -5,6 +5,7 @@ filter:
- dummy-data/*
- i18n/*
- includes/api/legacy/*
- includes/legacy/*
- includes/libraries/*
- includes/updates/*
- includes/gateways/simplify-commerce/*

View File

@ -12,20 +12,20 @@ php:
- hhvm
env:
- WP_VERSION=latest WP_MULTISITE=0
- WP_VERSION=latest WP_MULTISITE=0 PHP_LATEST_STABLE=7.1
# Additonal tests against stable PHP (min recommended version is 5.6) and past supported versions of WP.
matrix:
include:
- php: 5.6
env: WP_VERSION=latest WP_MULTISITE=1
env: WP_VERSION=latest WP_MULTISITE=1 PHP_LATEST_STABLE=7.1
before_script:
- bash tests/bin/install.sh woocommerce_test root '' localhost $WP_VERSION
- bash tests/bin/travis.sh before
script:
- phpunit -c phpunit.xml.dist
- bash tests/bin/phpunit.sh
- bash tests/bin/travis.sh during
after_script:

View File

@ -1,5 +1,59 @@
== Changelog ==
= 2.6.14 - 2017-02-02 =
* Fix - Ensure product exists in wc_update_product_stock.
* Fix - Send emails using the site language.
* Fix - Remove tilde typo.
* Fix - Fixed notice in get_rating_count.
* Tweak - Define arg and return data types, added extra descriptions, and correctly cast IDs in the Rest API.
* Tweak - Handle custom error data in WC_REST_Exception.
* Tweak - Display conflicted product ID when using a duplicate SKU via the API.
* Localization - Add Finnish defaults to the installer.
= 2.6.13 - 2017-01-18 =
* Fix - Demo store banner styling in 2017.
* Fix - Removed default instructions from COD, BACS and Check gateways so displayed messages can be unset.
* Fix - Made variation options update on first load.
* Localization - Added Romanian locale to the installer.
= 2.6.12 - 2017-01-12 =
* Fix - Make images shown up on pageload when using ajax variations.
* Fix - Allow variations options to be deselected in IE11.
* Fix - Disabled-button and pagination styling in 2017.
* Fix - PHP 7.1 compatibility issues with non-numeric math operations.
* Fix - Fix notices in abstract class when price is empty.
= 2.6.11 - 2016-12-22 =
* Fix - Variation form compatibility with quotes in attribute values, and initial variation image fadeIn on certain configs.
= 2.6.10 - 2016-12-22 =
* Fix - Flat rate no class costs when no shipping classes exist.
* Fix - Returned REST API coupon expiry date.
* Fix - reviews_allowed being set to false in Rest API.
* Fix - Sales date series for some custom ranges.
* Fix - Missing attributes when an option is chosen by default on variations. This was the result of a Firefox 50 compatibility fix. In order to support both Firefox, Chrome, IE, and Edge we've done some refactoring of the variation add to cart scripts.
* Tweak - Updated Geo IP API services.
* Dev - Added support for WP VIP/VIP GO GEO IP headers.
* Dev - API - Throw error messages when product image ID is not a valid WordPress attachment ID.
= 2.6.9 - 2016-12-07 =
* Theme - Added support for Twenty Seventeen Theme.
* Fix - Excluded webhook delivery logs from comments count.
* Fix - Included password strength meter in "Lost Password" page.
* Fix - Order fee currency in admin screen.
* Fix - Variation selection on Firefox 40.
* Fix - Don't prevent submission when table is not found on cart.
* Fix - Improved layered nav counts on attribute archives.
* Fix - Fixed pagination when removing layered nav items via widget.
* Fix - Default BE tax rate.
* Fix - Downloads should store variation ID rather than product if set. Also fixes link on account page.
* Fix - Use wp_list_sort instead of _usort_terms_by_ID to be compatible with 4.7.
* Fix - Only return empty string if empty for weight and dimension functions.
* Fix - Added correct fallbacks for logout/lost password URLs when endpoints are not defined.
* Security - Wrapped admin tax rate table values in _escape to thwart evil CSVs an admin user could upload. Vulnerability was discovered by Fortinets FortiGuard Labs.
* Dev - API - Only update categories menu order and display if defined.
* Dev - Fixed when should deliver wp_trash_post webhooks.
= 2.6.8 - 2016-11-10 =
* Fix - REQUEST_URI was missing a trailing slash when being compared in the cache prevention functions.
* Fix - Prevent issues when sending empty prices to PayPal.
@ -207,7 +261,7 @@
* Tweak - Allow failed orders to be edited.
* Tweak - If there are no shipping methods setup, dont prompt for shipping at checkout.
* Tweak - Allowed country exclusion, rather than just inclusion, in sell to setting.
* Lots, lots more - [see the comparison here: https://github.com/woocommerce/woocommerce/compare/2.5.5...2.6.0
* Lots, lots more - [see the comparison here](https://github.com/woocommerce/woocommerce/compare/2.5.5...2.6.0).
= 2.5.5 - 2016-03-11 =
* Fix - Before running dbdelta, drop indexes to prevent duplicate key notices.

View File

@ -128,6 +128,21 @@ module.exports = function( grunt ) {
}
},
// Generate RTL .css files
rtlcss: {
woocommerce: {
expand: true,
cwd: '<%= dirs.css %>',
src: [
'*.css',
'!select2.css',
'!*-rtl.css'
],
dest: '<%= dirs.css %>/',
ext: '-rtl.css'
}
},
// Minify all .css files.
cssmin: {
minify: {
@ -139,11 +154,21 @@ module.exports = function( grunt ) {
}
},
// Concatenate select2.css onto the admin.css files.
concat: {
admin: {
files: {
'<%= dirs.css %>/admin.css' : ['<%= dirs.css %>/select2.css', '<%= dirs.css %>/admin.css'],
'<%= dirs.css %>/admin-rtl.css' : ['<%= dirs.css %>/select2.css', '<%= dirs.css %>/admin-rtl.css']
}
}
},
// Watch changes for assets.
watch: {
css: {
files: ['<%= dirs.css %>/*.scss'],
tasks: ['sass', 'cssmin']
tasks: ['sass', 'rtlcss', 'cssmin', 'concat']
},
js: {
files: [
@ -259,11 +284,13 @@ module.exports = function( grunt ) {
// Load NPM tasks to be used here
grunt.loadNpmTasks( 'grunt-shell' );
grunt.loadNpmTasks( 'grunt-wp-i18n' );
grunt.loadNpmTasks( 'grunt-rtlcss' );
grunt.loadNpmTasks( 'grunt-checktextdomain' );
grunt.loadNpmTasks( 'grunt-contrib-jshint' );
grunt.loadNpmTasks( 'grunt-contrib-uglify' );
grunt.loadNpmTasks( 'grunt-contrib-sass' );
grunt.loadNpmTasks( 'grunt-contrib-cssmin' );
grunt.loadNpmTasks( 'grunt-contrib-concat' );
grunt.loadNpmTasks( 'grunt-contrib-watch' );
grunt.loadNpmTasks( 'grunt-contrib-clean' );
grunt.loadNpmTasks( 'grunt-stylelint' );
@ -284,7 +311,9 @@ module.exports = function( grunt ) {
grunt.registerTask( 'css', [
'sass',
'cssmin'
'rtlcss',
'cssmin',
'concat'
]);
grunt.registerTask( 'docs', [

View File

@ -6,7 +6,6 @@ If you are not a developer, please use the [WooCommerce plugin page](https://wor
## Documentation
* [WooCommerce Documentation](https://docs.woocommerce.com/documentation/plugins/woocommerce/)
* [WooCommerce Knowledge Base](https://support.woothemes.com/hc/en-us/categories/200146917-WooCommerce)
* [WooCommerce Code Reference](https://docs.woocommerce.com/wc-apidocs/)
* [WooCommerce REST API Docs](https://woocommerce.github.io/woocommerce-rest-api-docs/)
@ -16,7 +15,7 @@ To disclose a security issue to our team, [please submit a report via HackerOne
## Support
This repository is not suitable for support. Please don't use our issue tracker for support requests, but for core WooCommerce issues only. Support can take place in the appropriate channels:
* The [WooThemes premium support portal](https://support.woothemes.com/) for customers who have purchased themes or extensions.
* The [WooCommerce premium support portal](https://woocommerce.com/my-account/create-a-ticket/) for customers who have purchased themes or extensions.
* [Our community forum on wp.org](https://wordpress.org/support/plugin/woocommerce) which is available for all WooCommerce users.
Support requests in issues on this repository will be closed on sight.

View File

@ -231,7 +231,6 @@
text-transform: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
margin-right: 0.618em;
content: $glyph;
text-decoration: none;
}

View File

@ -0,0 +1 @@
div.woocommerce-message{overflow:hidden;position:relative;border-right-color:#cc99c2!important}div.woocommerce-message p{max-width:700px}.woocommerce-message a.button-primary,p.woocommerce-actions a.button-primary{background:#bb77ae;border-color:#a36597;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597;box-shadow:inset 0 1px 0 rgba(255,255,255,.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}.woocommerce-message a.button-primary:active,.woocommerce-message a.button-primary:focus,.woocommerce-message a.button-primary:hover,p.woocommerce-actions a.button-primary:active,p.woocommerce-actions a.button-primary:focus,p.woocommerce-actions a.button-primary:hover{background:#a36597;border-color:#a36597;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597;box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 #a36597}.woocommerce-message a.woocommerce-message-close,p.woocommerce-actions a.woocommerce-message-close{position:absolute;top:0;left:0;padding:10px 21px 10px 15px;font-size:13px;line-height:1.23076923;text-decoration:none}.woocommerce-message a.woocommerce-message-close::before,p.woocommerce-actions a.woocommerce-message-close::before{position:absolute;top:8px;right:0;-webkit-transition:all .1s ease-in-out;transition:all .1s ease-in-out}.woocommerce-message a.button-primary,.woocommerce-message a.button-secondary,p.woocommerce-actions a.button-primary,p.woocommerce-actions a.button-secondary{text-decoration:none!important}.woocommerce-message .twitter-share-button,p.woocommerce-actions .twitter-share-button{margin-top:-3px;margin-right:3px;vertical-align:middle}.woocommerce-about-text,p.woocommerce-actions{margin-bottom:1em!important}div.woocommerce-legacy-shipping-notice,div.woocommerce-no-shipping-methods-notice{overflow:hidden;padding:1px 12px}div.woocommerce-legacy-shipping-notice p,div.woocommerce-no-shipping-methods-notice p{position:relative;z-index:1;max-width:700px;line-height:1.5em;margin:12px 0}div.woocommerce-legacy-shipping-notice p.main,div.woocommerce-no-shipping-methods-notice p.main{font-size:1.1em}div.woocommerce-legacy-shipping-notice::before,div.woocommerce-no-shipping-methods-notice::before{content:'\e01b';font-family:WooCommerce;text-align:center;line-height:1;color:#f7f1f6;display:block;width:1em;font-size:20em;top:36px;left:12px;position:absolute}

2
assets/css/admin-rtl.css Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -11,7 +11,6 @@
@import 'mixins';
@import 'variables';
@import 'animation';
@import 'select2';
@import 'fonts';
/**
@ -580,6 +579,74 @@ table.wc_status_table {
}
}
/**
* DB log viewer
*/
.wp-list-table.logs {
.log-level {
display: inline;
padding: .2em .6em .3em;
font-size: 80%;
font-weight: bold;
line-height: 1;
color: #fff;
text-align: center;
white-space: nowrap;
vertical-align: baseline;
border-radius: .2em;
&:empty {
display: none;
}
}
/**
* Add color to levels
*
* Descending severity:
* emergency, alert -> red
* critical, error -> orange
* warning, notice -> yellow
* info -> blue
* debug -> gree
*/
.log-level--emergency,
.log-level--alert {
background-color: #ff4136;
}
.log-level--critical,
.log-level--error {
background-color: #ff851b;
}
.log-level--warning,
.log-level--notice {
color: #222;
background-color: #ffdc00;
}
.log-level--info {
background-color: #0074d9;
}
.log-level--debug {
background-color: #3d9970;
}
// Adjust log table columns only when table is not collapsed
@media screen and ( min-width: 783px ) {
.column-timestamp {
width: 18%;
}
.column-level {
width: 14%;
}
.column-source {
width: 15%;
}
}
}
#log-viewer-select {
padding: 10px 0 8px;
line-height: 28px;
@ -837,6 +904,7 @@ ul.wc_coupon_list_block {
.form-field {
float: left;
clear: left;
width: 48%;
padding: 0;
margin: 9px 0 0;
@ -875,11 +943,24 @@ ul.wc_coupon_list_block {
}
}
.form-field.last {
.form-field.last,
._billing_last_name_field,
._billing_address_2_field,
._billing_postcode_field,
._billing_state_field,
._billing_phone_field,
._shipping_last_name_field,
._shipping_address_2_field,
._shipping_postcode_field,
._shipping_state_field {
float: right;
clear: right;
}
.form-field-wide {
.form-field-wide,
._billing_company_field,
._shipping_company_field,
._transaction_id_field {
width: 100%;
clear: both;
@ -896,41 +977,6 @@ ul.wc_coupon_list_block {
color: #999;
}
._billing_first_name_field,
._billing_address_1_field,
._billing_city_field,
._billing_country_field,
._billing_email_field,
._shipping_first_name_field,
._shipping_address_1_field,
._shipping_city_field,
._shipping_country_field {
float: left;
}
._billing_last_name_field,
._billing_address_2_field,
._billing_postcode_field,
._billing_state_field,
._billing_phone_field,
._shipping_last_name_field,
._shipping_address_2_field,
._shipping_postcode_field,
._shipping_state_field {
float: right;
}
._billing_company_field,
._shipping_company_field,
._transaction_id_field {
clear: both;
width: 100%;
}
._billing_email_field {
clear: left;
}
div.edit_address {
display: none;
zoom: 1;
@ -2543,9 +2589,10 @@ table.wc_shipping {
}
}
.wc-shipping-zone-postcodes-toggle {
margin: 0;
margin: 0.5em 0 0;
font-size: 0.9em;
text-decoration: underline;
display: block;
}
.wc-shipping-zone-postcodes-toggle + .wc-shipping-zone-postcodes {
display:none;
@ -2560,6 +2607,9 @@ table.wc_shipping {
}
}
}
.wc-shipping-zone-settings + p.submit {
margin-top: 0;
}
table {
tr, tr:hover {
table.wc-shipping-zone-methods {
@ -2576,6 +2626,9 @@ table {
}
}
}
.wc-shipping-zones-heading .page-title-action {
display: inline-block;
}
table.wc-shipping-zones, table.wc-shipping-zone-methods, table.wc-shipping-classes {
td, th {
vertical-align: top;
@ -2608,6 +2661,13 @@ table.wc-shipping-zones, table.wc-shipping-zone-methods, table.wc-shipping-class
position: relative;
padding: 7.5em 7.5% !important;
border-bottom: 2px solid #eee2ec;
&.wc-shipping-zone-method-blank-state {
padding: 2em !important;
p {
margin-bottom: 0;
}
}
p, li {
color: #a46497;
font-size: 1.5em;
@ -2777,7 +2837,7 @@ table.wc-shipping-zones, table.wc-shipping-zone-methods, table.wc-shipping-class
}
}
.wc-shipping-zone-method-title {
width: 33%;
width: 25%;
.wc-shipping-zone-method-delete {
color: red;
}
@ -2793,6 +2853,9 @@ table.wc-shipping-zones, table.wc-shipping-zone-methods, table.wc-shipping-class
margin-top: 3px;
}
}
.wc-shipping-zone-method-type {
display: block;
}
tfoot {
input, select {
vertical-align: middle !important;
@ -3395,6 +3458,11 @@ img.help_tip {
line-height: 20px !important;
border-bottom: 1px solid #eee;
span {
margin-left: 0.618em;
margin-right: 0.618em;
}
&::before {
@include iconbeforedashicons( '\f107' );
}
@ -3480,6 +3548,10 @@ img.help_tip {
* Shipping
*/
.woocommerce_page_wc-settings {
input[type=url], input[type=email] {
direction: ltr;
}
.shippingrows {
th.check-column {
padding-top: 20px;
@ -4228,7 +4300,7 @@ img.help_tip {
}
input[type=checkbox] {
margin: -3px 0 0 .5em;
margin: 0 5px 0 .5em!important;
vertical-align: middle;
}
}
@ -4307,11 +4379,10 @@ img.tips {
display: none;
position: absolute;
top: 0;
/*rtl:ignore*/
left: 0;
z-index: 9999999;
}
#tiptip_holder {
&.tip_top {
padding-bottom: 5px;
@ -4381,6 +4452,13 @@ img.tips {
width: 0;
}
/*rtl:raw:
#tiptip_arrow {
margin-right: 79.5px!important;
margin-left: 0!important;
}
*/
.wc_error_tip {
max-width: 20em;
line-height: 1.8em;

1
assets/css/auth-rtl.css Normal file
View File

@ -0,0 +1 @@
body{background:#f1f1f1;box-shadow:none;margin:100px auto 24px;padding:0}#wc-logo{border:0;margin:0 0 24px;padding:0;text-align:center}#wc-logo img{max-width:50%}.wc-auth-content{background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.13);overflow:hidden;padding:24px 24px 0;zoom:1}.wc-auth-content h1,.wc-auth-content h2,.wc-auth-content h3,.wc-auth-content table{border:0;clear:none;color:#666;margin:0 0 24px;padding:0}.wc-auth-content p,.wc-auth-content ul{color:#666;font-size:1em;line-height:1.75em;margin:0 0 24px}.wc-auth-content p{padding:0}.wc-auth-content a{color:#a16696}.wc-auth-content a:focus,.wc-auth-content a:hover{color:#111}.wc-auth-content .wc-auth-login label{color:#999;display:block;margin-bottom:.5em}.wc-auth-content .wc-auth-login input{box-sizing:border-box;font-size:1.3em;padding:.5em;width:100%}.wc-auth-content .wc-auth-login .wc-auth-actions{padding:0}.wc-auth-content .wc-auth-login .wc-auth-actions .wc-auth-login-button{float:none;width:100%}.wc-auth-permissions{list-style:disc inside;padding:0}.wc-auth-permissions li{font-size:1em}.wc-auth-logged-in-as{background:#f5f5f5;border-bottom:2px solid #eee;line-height:70px;margin:0 0 24px;padding:0 0 0 1em}.wc-auth-logged-in-as p{margin:0;line-height:70px}.wc-auth-logged-in-as img{float:right;height:70px;margin:0 0 0 1em}.wc-auth-logged-in-as .wc-auth-logout{float:left}.wc-auth .wc-auth-actions{overflow:hidden;padding-right:24px}.wc-auth .wc-auth-actions .button{background:#f7f7f7;border:1px solid #d7d7d7;box-sizing:border-box;color:#777;float:left;font-size:1.25em;height:auto;line-height:1em;padding:1em 2em;text-align:center;width:50%}.wc-auth .wc-auth-actions .button:focus,.wc-auth .wc-auth-actions .button:hover{background:#fcfcfc}.wc-auth .wc-auth-actions .button-primary{background:#ad6ea1;border-color:#a16696;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 0 rgba(0,0,0,.15);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 0 rgba(0,0,0,.15);color:#fff;float:left;opacity:1;text-shadow:0 -1px 1px #8a4f7f,-1px 0 1px #8a4f7f,0 1px 1px #8a4f7f,1px 0 1px #8a4f7f}.wc-auth .wc-auth-actions .button-primary:focus,.wc-auth .wc-auth-actions .button-primary:hover{background:#b472a8;color:#fff}.wc-auth .wc-auth-actions .wc-auth-approve{float:left}.wc-auth .wc-auth-actions .wc-auth-deny{float:right;margin-right:-24px}

View File

@ -0,0 +1 @@
@charset "UTF-8";@font-face{font-family:star;src:url(../fonts/star.eot);src:url(../fonts/star.eot?#iefix) format("embedded-opentype"),url(../fonts/star.woff) format("woff"),url(../fonts/star.ttf) format("truetype"),url(../fonts/star.svg#star) format("svg");font-weight:400;font-style:normal}@font-face{font-family:WooCommerce;src:url(../fonts/WooCommerce.eot);src:url(../fonts/WooCommerce.eot?#iefix) format("embedded-opentype"),url(../fonts/WooCommerce.woff) format("woff"),url(../fonts/WooCommerce.ttf) format("truetype"),url(../fonts/WooCommerce.svg#WooCommerce) format("svg");font-weight:400;font-style:normal}ul.woocommerce_stats{overflow:hidden;zoom:1}ul.woocommerce_stats li{width:25%;padding:0 1em;text-align:center;float:right;font-size:.8em;border-right:1px solid #fff;border-left:1px solid #ececec;box-sizing:border-box}ul.woocommerce_stats li:first-child{border-right:0}ul.woocommerce_stats li:last-child{border-left:0}#woocommerce_dashboard_status .wc_status_list li.low-in-stock,#woocommerce_dashboard_status .wc_status_list li.processing-orders{border-left:1px solid #ececec}ul.woocommerce_stats strong{font-family:Georgia,'Times New Roman','Bitstream Charter',Times,serif;font-size:4em;line-height:1.2em;font-weight:400;text-align:center;display:block}#woocommerce_dashboard_status .inside{padding:0;margin:0}#woocommerce_dashboard_status .wc_status_list{overflow:hidden;margin:0}#woocommerce_dashboard_status .wc_status_list li{width:50%;float:right;padding:0;box-sizing:border-box;margin:0;border-top:1px solid #ececec;color:#aaa}#woocommerce_dashboard_status .wc_status_list li a{display:block;color:#aaa;padding:9px 12px;-webkit-transition:all ease .5s;position:relative;font-size:12px}#woocommerce_dashboard_status .wc_status_list li a .wc_sparkline{width:4em;height:2em;display:block;float:left;position:absolute;left:0;top:50%;margin-left:12px;margin-top:-1.25em}#woocommerce_dashboard_status .wc_status_list li a strong{font-size:18px;line-height:1.2em;font-weight:400;display:block;color:#21759b}#woocommerce_dashboard_status .wc_status_list li a:hover{color:#2ea2cc}#woocommerce_dashboard_status .wc_status_list li a:hover strong,#woocommerce_dashboard_status .wc_status_list li a:hover::before{color:#2ea2cc!important}#woocommerce_dashboard_status .wc_status_list li a::before{font-family:WooCommerce;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;margin:0 0 12px 12px;text-indent:0;top:0;right:0;height:100%;text-align:center;content:"";font-size:2em;position:relative;width:auto;line-height:1.2em;color:#464646;float:right}#woocommerce_dashboard_status .wc_status_list li.best-seller-this-month,#woocommerce_dashboard_status .wc_status_list li.sales-this-month{width:100%}#woocommerce_dashboard_status .wc_status_list li:first-child{border-top:0}#woocommerce_dashboard_status .wc_status_list li.sales-this-month a::before{font-family:Dashicons;content:'\f185'}#woocommerce_dashboard_status .wc_status_list li.best-seller-this-month a::before{content:'\e006'}#woocommerce_dashboard_status .wc_status_list li.processing-orders a::before{content:'\e011';color:#7ad03a}#woocommerce_dashboard_status .wc_status_list li.on-hold-orders a::before{content:'\e033';color:#999}#woocommerce_dashboard_status .wc_status_list li.low-in-stock a::before{content:'\e016';color:#ffba00}#woocommerce_dashboard_status .wc_status_list li.out-of-stock a::before{content:'\e013';color:#a00}#woocommerce_dashboard_recent_reviews li{line-height:1.5em;margin-bottom:12px}#woocommerce_dashboard_recent_reviews h4.meta{line-height:1.4;margin:-.2em 0 0;font-weight:400;color:#999}#woocommerce_dashboard_recent_reviews blockquote{padding:0;margin:0}#woocommerce_dashboard_recent_reviews .avatar{float:right;margin:0 0 5px 10px}#woocommerce_dashboard_recent_reviews .star-rating{float:left;overflow:hidden;position:relative;height:1.5em;line-height:1.5;margin-right:.5em;width:5.4em;font-family:WooCommerce!important}#woocommerce_dashboard_recent_reviews .star-rating::before{content:'\e021\e021\e021\e021\e021';color:#b3b3b3;float:right;top:0;right:0;position:absolute;letter-spacing:.1em;letter-spacing:0\9}#woocommerce_dashboard_recent_reviews .star-rating span{overflow:hidden;float:right;top:0;right:0;position:absolute;padding-top:1.5em}#woocommerce_dashboard_recent_reviews .star-rating span::before{content:'\e020\e020\e020\e020\e020';top:0;position:absolute;right:0;letter-spacing:.1em;letter-spacing:0\9;color:#9c5d90}#dash-right-now li.product-count a::before{font-family:WooCommerce;content:'\e01d'}

1
assets/css/menu-rtl.css Normal file
View File

@ -0,0 +1 @@
@charset "UTF-8";@font-face{font-family:star;src:url(../fonts/star.eot);src:url(../fonts/star.eot?#iefix) format("embedded-opentype"),url(../fonts/star.woff) format("woff"),url(../fonts/star.ttf) format("truetype"),url(../fonts/star.svg#star) format("svg");font-weight:400;font-style:normal}@font-face{font-family:WooCommerce;src:url(../fonts/WooCommerce.eot);src:url(../fonts/WooCommerce.eot?#iefix) format("embedded-opentype"),url(../fonts/WooCommerce.woff) format("woff"),url(../fonts/WooCommerce.ttf) format("truetype"),url(../fonts/WooCommerce.svg#WooCommerce) format("svg");font-weight:400;font-style:normal}#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;display:block;text-indent:-9999px;position:relative;height:1em;width:1em}span.mce_woocommerce_shortcodes_button::before{font-family:WooCommerce;speak:none;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;margin:0;text-indent:0;position:absolute;top:0;right:0;width:100%;height:100%;text-align:center;content:"";font-size:.9em;line-height:1.2}.wc_plugin_upgrade_notice{font-weight:400;color:#fff;background:#d54d21;padding:1em;margin:9px 0}.wc_plugin_upgrade_notice a{color:#fff;text-decoration:underline}.wc_plugin_upgrade_notice::before{content:'\f348';display:inline-block;font:400 18px/1 dashicons;speak:none;margin:0 -2px 0 8px;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;vertical-align:top}

0
assets/css/photoswipe/default-skin/default-skin.css Executable file → Normal file
View File

0
assets/css/photoswipe/default-skin/default-skin.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 547 B

After

Width:  |  Height:  |  Size: 547 B

0
assets/css/photoswipe/default-skin/default-skin.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

0
assets/css/photoswipe/default-skin/preloader.gif Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 866 B

After

Width:  |  Height:  |  Size: 866 B

0
assets/css/photoswipe/photoswipe.css Executable file → Normal file
View File

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
*{background:0 0!important;color:#000!important;text-shadow:none!important;filter:none!important;-ms-filter:none!important;font-size:9pt!important;opacity:1;-webkit-transition:none!important}@page{margin:.5cm}#adminmenuback,#adminmenuwrap,#screen-meta-links,#wpadminbar,#wpfooter,.update-nag,.updated,.woo-nav-tab-wrapper,.woocommerce-reports-wide .button,.woocommerce-reports-wide .postbox h3.stats_range .export_csv,.woocommerce-reports-wrap .postbox h3.stats_range .export_csv{display:none}h2 .nav-tab{line-height:14px}.woocommerce-reports-wide .postbox h3.stats_range ul li a,.woocommerce-reports-wide .postbox h3.stats_range ul li.custom,.woocommerce-reports-wrap .postbox h3.stats_range ul li a,.woocommerce-reports-wrap .postbox h3.stats_range ul li.custom{padding:5px;line-height:14px}#wpcontent{margin-right:0}.woocommerce-reports-wide .postbox .chart-with-sidebar .chart-sidebar,.woocommerce-reports-wrap .postbox .chart-with-sidebar .chart-sidebar{margin-right:-130px;width:130px;display:block}.woocommerce-reports-wide .postbox .chart-with-sidebar,.woocommerce-reports-wrap .postbox .chart-with-sidebar{padding-right:130px}.chart-legend{overflow:hidden;zoom:1}.chart-legend li{padding:.25em .5em!important;box-shadow:none!important;border-bottom:1px solid gray!important}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -281,17 +281,25 @@ a.remove {
}
}
dl.variation {
dt {
dl.variation, .wc-item-meta {
list-style: none outside;
dt, .wc-item-meta-label {
float: left;
clear: both;
margin-right: .25em;
display: inline-block;
list-style: none outside;
}
dd {
margin: 0;
}
p,
&:last-child {
margin-bottom: 0;
}
}
/**
@ -364,6 +372,11 @@ table.variations {
margin: 0;
}
.woocommerce-product-gallery__image:nth-child(n+2) {
width: 25%;
display: inline-block;
}
.flex-control-thumbs {
li {
list-style: none;
@ -518,6 +531,26 @@ table.variations {
}
}
/**
* Photoswipe
* 1. These styles are required to overwrite default theme button styles (Twenty Twelve adds gradients via background-image).
*/
button.pswp__button,
button.pswp__button:hover,
button.pswp__button--arrow--left::before,
button.pswp__button--arrow--right::before {
background-color: transparent !important; /* 1 */
}
button.pswp__button--close:hover {
background-position: 0 -44px;
}
button.pswp__button--zoom:hover {
background-position: -88px 0;
}
/**
* Widgets
*/
@ -763,7 +796,7 @@ table.variations {
li {
margin-bottom: .5em;
input {
float: left;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -304,11 +304,18 @@
.form-row-first,
.form-row-last {
float: left;
width: 47%;
overflow: visible;
}
.form-row-first {
float: left;
/*rtl:raw:
float: right;
*/
}
.form-row-last {
float: right;
}
@ -548,14 +555,5 @@
float: left;
}
}
form {
.form-row-first,
.form-row-last {
float: right;
}
.form-row-last {
float: left;
}
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -176,6 +176,11 @@ p.demo_store,
transition: all cubic-bezier(0.795, -0.035, 0.000, 1.000) .5s;
}
.woocommerce-product-gallery__image:nth-child(n+2) {
width: 25%;
display: inline-block;
}
.woocommerce-product-gallery__trigger {
position: absolute;
top: .5em;
@ -457,6 +462,18 @@ p.demo_store,
padding-bottom: 0.5em;
border: 0;
}
td:first-child {
width: 4em;
text-align: center;
}
.wc-grouped-product-add-to-cart-checkbox {
display: inline-block;
width: auto;
margin: 0 auto;
transform:scale(1.5, 1.5);
}
}
}
}
@ -1114,30 +1131,24 @@ p.demo_store,
}
td.product-name {
dl.variation {
margin: 0.25em 0;
@include clearfix();
dl.variation, .wc-item-meta {
list-style: none outside;
dt,
dd {
display: inline-block;
dt, .wc-item-meta-label {
float: left;
margin-bottom: 1em;
}
dt {
font-weight: 700;
padding: 0 0 0.25em;
margin: 0 4px 0 0;
clear: left;
clear: both;
margin-right: .25em;
display: inline-block;
list-style: none outside;
}
dd {
padding: 0 0 0.25em;
margin: 0;
}
p:last-child {
margin-bottom: 0;
}
p,
&:last-child {
margin-bottom: 0;
}
}
@ -1390,9 +1401,9 @@ p.demo_store,
/**
* Order page
*/
.order_details {
ul.order_details {
@include clearfix();
margin: 0 0 1.5em;
margin: 0 0 3em;
list-style: none;
li {
@ -1420,6 +1431,10 @@ p.demo_store,
}
}
.wc-bacs-bank-details-account-name {
font-weight: bold;
}
/**
* Layered nav widget
*/

0
assets/fonts/WooCommerce.eot Executable file → Normal file
View File

0
assets/fonts/WooCommerce.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 50 KiB

0
assets/fonts/WooCommerce.ttf Executable file → Normal file
View File

0
assets/fonts/WooCommerce.woff Executable file → Normal file
View File

0
assets/images/icons/credit-cards/amex.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

0
assets/images/icons/credit-cards/diners.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

0
assets/images/icons/credit-cards/discover.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

0
assets/images/icons/credit-cards/jcb.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

0
assets/images/icons/credit-cards/maestro.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

0
assets/images/icons/credit-cards/visa.svg Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -99,10 +99,26 @@ jQuery( function ( $ ) {
edit_address: function( e ) {
e.preventDefault();
$( this ).hide();
$( this ).parent().find( 'a:not(.edit_address)' ).show();
$( this ).closest( '.order_data_column' ).find( 'div.address' ).hide();
$( this ).closest( '.order_data_column' ).find( 'div.edit_address' ).show();
var $this = $( this ),
$wrapper = $this.closest( '.order_data_column' ),
$edit_address = $wrapper.find( 'div.edit_address' ),
$address = $wrapper.find( 'div.address' ),
$country_input = $edit_address.find( '.js_field-country' ),
$state_input = $edit_address.find( '.js_field-state' );
$address.hide();
$this.parent().find( 'a' ).toggle();
if ( ! $country_input.val() ) {
$country_input.val( woocommerce_admin_meta_boxes_order.default_country ).change();
}
if ( ! $state_input.val() ) {
$state_input.val( woocommerce_admin_meta_boxes_order.default_state ).change();
}
$edit_address.show();
},
change_customer_user: function() {
@ -1042,39 +1058,27 @@ jQuery( function ( $ ) {
},
add_item: function( add_item_ids ) {
add_item_ids = add_item_ids.split( ',' );
if ( add_item_ids ) {
var count = add_item_ids.length;
wc_meta_boxes_order_items.block();
$.each( add_item_ids, function( index, value ) {
var data = {
action : 'woocommerce_add_order_item',
item_to_add: add_item_ids,
dataType : 'json',
order_id : woocommerce_admin_meta_boxes.post_id,
security : woocommerce_admin_meta_boxes.order_item_nonce
};
var data = {
action : 'woocommerce_add_order_item',
item_to_add: value,
dataType : 'json',
order_id : woocommerce_admin_meta_boxes.post_id,
security : woocommerce_admin_meta_boxes.order_item_nonce
};
$.post( woocommerce_admin_meta_boxes.ajax_url, data, function( response ) {
if ( response.success ) {
$( 'table.woocommerce_order_items tbody#order_line_items' ).append( response.data.html );
} else {
window.alert( response.data.error );
}
if ( !--count ) {
wc_meta_boxes_order.init_tiptip();
wc_meta_boxes_order_items.unblock();
}
});
$.post( woocommerce_admin_meta_boxes.ajax_url, data, function( response ) {
if ( response.success ) {
$( 'table.woocommerce_order_items tbody#order_line_items' ).append( response.data.html );
} else {
window.alert( response.data.error );
}
wc_meta_boxes_order.init_tiptip();
wc_meta_boxes_order_items.unblock();
});
}
},

File diff suppressed because one or more lines are too long

View File

@ -118,21 +118,19 @@ jQuery( function( $ ) {
});
// Datepicker fields
$( '.sale_price_dates_fields', wrapper ).each( function() {
var dates = $( this ).find( 'input' ).datepicker({
defaultDate: '',
dateFormat: 'yy-mm-dd',
numberOfMonths: 1,
showButtonPanel: true,
onSelect: function( selectedDate ) {
var option = $( this ).is( '.sale_price_dates_from' ) ? 'minDate' : 'maxDate',
instance = $( this ).data( 'datepicker' ),
date = $.datepicker.parseDate( instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings );
$( '.sale_price_dates_fields', wrapper ).find( 'input' ).datepicker({
defaultDate: '',
dateFormat: 'yy-mm-dd',
numberOfMonths: 1,
showButtonPanel: true,
onSelect: function( selectedDate, instance ) {
var option = $( this ).is( '.sale_price_dates_from' ) ? 'minDate' : 'maxDate',
dates = $( this ).closest( '.sale_price_dates_fields' ).find( 'input' ),
date = $.datepicker.parseDate( instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings );
dates.not( this ).datepicker( 'option', option, date );
$( this ).change();
}
});
dates.not( this ).datepicker( 'option', option, date );
$( this ).change();
}
});
// Allow sorting

File diff suppressed because one or more lines are too long

View File

@ -21,17 +21,7 @@ jQuery( function( $ ) {
return ui;
},
start: function( event, ui ) {
ui.placeholder.children().each( function() {
var $original = ui.item.children().eq( ui.placeholder.children().index( this ) ),
$this = $( this );
$.each( $original[0].attributes, function( k, attr ) {
$this.attr( attr.name, attr.value );
});
});
if ( ! ui.item.hasClass( 'alternate' ) ) {
ui.item.css( 'background-color', '#ffffff' );
}
ui.item.css( 'background-color', '#ffffff' );
ui.item.children( 'td, th' ).css( 'border-bottom-width', '0' );
ui.item.css( 'outline', '1px solid #dfdfdf' );
},

View File

@ -1 +1 @@
jQuery(function(a){a("table.widefat tbody th, table.widefat tbody td").css("cursor","move"),a("table.widefat tbody").sortable({items:"tr:not(.inline-edit-row)",cursor:"move",axis:"y",containment:"table.widefat",scrollSensitivity:40,helper:function(b,c){return c.each(function(){a(this).width(a(this).width())}),c},start:function(b,c){c.placeholder.children().each(function(){var b=c.item.children().eq(c.placeholder.children().index(this)),d=a(this);a.each(b[0].attributes,function(a,b){d.attr(b.name,b.value)})}),c.item.hasClass("alternate")||c.item.css("background-color","#ffffff"),c.item.children("td, th").css("border-bottom-width","0"),c.item.css("outline","1px solid #dfdfdf")},stop:function(a,b){b.item.removeAttr("style"),b.item.children("td,th").css("border-bottom-width","1px")},update:function(b,c){a("table.widefat tbody th, table.widefat tbody td").css("cursor","default"),a("table.widefat tbody").sortable("disable");var d=c.item.find(".check-column input").val(),e=c.item.prev().find(".check-column input").val(),f=c.item.next().find(".check-column input").val();c.item.find(".check-column input").hide().after('<img alt="processing" src="images/wpspin_light.gif" class="waiting" style="margin-left: 6px;" />'),a.post(ajaxurl,{action:"woocommerce_product_ordering",id:d,previd:e,nextid:f},function(b){a.each(b,function(b,c){a("#inline_"+b+" .menu_order").html(c)}),c.item.find(".check-column input").show().siblings("img").remove(),a("table.widefat tbody th, table.widefat tbody td").css("cursor","move"),a("table.widefat tbody").sortable("enable")}),a("table.widefat tbody tr").each(function(){var b=a("table.widefat tbody tr").index(this);b%2===0?a(this).addClass("alternate"):a(this).removeClass("alternate")})}})});
jQuery(function(a){a("table.widefat tbody th, table.widefat tbody td").css("cursor","move"),a("table.widefat tbody").sortable({items:"tr:not(.inline-edit-row)",cursor:"move",axis:"y",containment:"table.widefat",scrollSensitivity:40,helper:function(b,c){return c.each(function(){a(this).width(a(this).width())}),c},start:function(a,b){b.item.css("background-color","#ffffff"),b.item.children("td, th").css("border-bottom-width","0"),b.item.css("outline","1px solid #dfdfdf")},stop:function(a,b){b.item.removeAttr("style"),b.item.children("td,th").css("border-bottom-width","1px")},update:function(b,c){a("table.widefat tbody th, table.widefat tbody td").css("cursor","default"),a("table.widefat tbody").sortable("disable");var d=c.item.find(".check-column input").val(),e=c.item.prev().find(".check-column input").val(),f=c.item.next().find(".check-column input").val();c.item.find(".check-column input").hide().after('<img alt="processing" src="images/wpspin_light.gif" class="waiting" style="margin-left: 6px;" />'),a.post(ajaxurl,{action:"woocommerce_product_ordering",id:d,previd:e,nextid:f},function(b){a.each(b,function(b,c){a("#inline_"+b+" .menu_order").html(c)}),c.item.find(".check-column input").show().siblings("img").remove(),a("table.widefat tbody th, table.widefat tbody td").css("cursor","move"),a("table.widefat tbody").sortable("enable")}),a("table.widefat tbody tr").each(function(){var b=a("table.widefat tbody tr").index(this);b%2===0?a(this).addClass("alternate"):a(this).removeClass("alternate")})}})});

View File

@ -136,6 +136,7 @@ jQuery(function( $ ) {
exclude_series = exclude_series.split( ',' );
var xaxes_label = $( this ).data( 'xaxes' );
var groupby = $( this ) .data( 'groupby' );
var index_type = $( this ).data( 'index_type' );
var export_format = $( this ).data( 'export' );
var csv_data = 'data:application/csv;charset=utf-8,';
var s, series_data, d;
@ -217,10 +218,14 @@ jQuery(function( $ ) {
$.each( xaxis, function( index, value ) {
var date = new Date( parseInt( index, 10 ) );
if ( groupby === 'day' ) {
csv_data += '"' + date.getUTCFullYear() + '-' + parseInt( date.getUTCMonth() + 1, 10 ) + '-' + date.getUTCDate() + '",';
if ( 'none' === index_type ) {
csv_data += '"' + index + '",';
} else {
csv_data += '"' + date.getUTCFullYear() + '-' + parseInt( date.getUTCMonth() + 1, 10 ) + '",';
if ( groupby === 'day' ) {
csv_data += '"' + date.getUTCFullYear() + '-' + parseInt( date.getUTCMonth() + 1, 10 ) + '-' + date.getUTCDate() + '",';
} else {
csv_data += '"' + date.getUTCFullYear() + '-' + parseInt( date.getUTCMonth() + 1, 10 ) + '",';
}
}
for ( var d = 0; d < value.length; ++d ) {

View File

@ -1 +1 @@
jQuery(function(a){function b(b,c,d){a('<div class="chart-tooltip">'+d+"</div>").css({top:c-16,left:b+20}).appendTo("body").fadeIn(200)}var c=null,d=null;a(".chart-placeholder").bind("plothover",function(e,f,g){if(g){if((c!==g.dataIndex||d!==g.seriesIndex)&&(c=g.dataIndex,d=g.seriesIndex,a(".chart-tooltip").remove(),g.series.points.show||g.series.enable_tooltip)){var h=g.series.data[g.dataIndex][1],i="";g.series.prepend_label&&(i=i+g.series.label+": "),g.series.prepend_tooltip&&(i+=g.series.prepend_tooltip),i+=h,g.series.append_tooltip&&(i+=g.series.append_tooltip),g.series.pie.show?b(f.pageX,f.pageY,i):b(g.pageX,g.pageY,i)}}else a(".chart-tooltip").remove(),c=null}),a(".wc_sparkline.bars").each(function(){var b=a(this).data("sparkline"),c={grid:{show:!1}},d=[{data:b,color:a(this).data("color"),bars:{fillColor:a(this).data("color"),fill:!0,show:!0,lineWidth:1,barWidth:a(this).data("barwidth"),align:"center"},shadowSize:0}];a.plot(a(this),d,c)}),a(".wc_sparkline.lines").each(function(){var b=a(this).data("sparkline"),c={grid:{show:!1}},d=[{data:b,color:a(this).data("color"),lines:{fill:!1,show:!0,lineWidth:1,align:"center"},shadowSize:0}];a.plot(a(this),d,c)});var e=a(".range_datepicker").datepicker({changeMonth:!0,changeYear:!0,defaultDate:"",dateFormat:"yy-mm-dd",numberOfMonths:1,maxDate:"+0D",showButtonPanel:!0,showOn:"focus",buttonImageOnly:!0,onSelect:function(b){var c=a(this).is(".from")?"minDate":"maxDate",d=a(this).data("datepicker"),f=a.datepicker.parseDate(d.settings.dateFormat||a.datepicker._defaults.dateFormat,b,d.settings);e.not(this).datepicker("option",c,f)}}),f=document.createElement("a");"undefined"==typeof f.download&&a(".export_csv").hide(),a(".export_csv").click(function(){var b=a(this).data("exclude_series")||"";b=b.toString(),b=b.split(",");var c,d,e,f=a(this).data("xaxes"),g=a(this).data("groupby"),h=a(this).data("export"),i="data:application/csv;charset=utf-8,";if("table"===h)a(this).offsetParent().find("thead tr,tbody tr").each(function(){a(this).find("th, td").each(function(){var b=a(this).text();b=b.replace("[?]","").replace("#",""),i+='"'+b+'",'}),i=i.substring(0,i.length-1),i+="\n"}),a(this).offsetParent().find("tfoot tr").each(function(){a(this).find("th, td").each(function(){var b=a(this).text();if(b=b.replace("[?]","").replace("#",""),i+='"'+b+'",',a(this).attr("colspan")>0)for(m=1;m<a(this).attr("colspan");m++)i+='"",'}),i=i.substring(0,i.length-1),i+="\n"});else{if(!window.main_chart)return!1;var j=window.main_chart.getData(),k=[];for(i+='"'+f+'",',a.each(j,function(c,d){b&&a.inArray(c.toString(),b)!==-1||k.push(d)}),c=0;c<k.length;++c)i+='"'+k[c].label+'",';i=i.substring(0,i.length-1),i+="\n";var l={};for(c=0;c<k.length;++c)for(d=k[c].data,e=0;e<d.length;++e){l[d[e][0]]=[];for(var m=0;m<k.length;++m)l[d[e][0]].push(0)}for(c=0;c<k.length;++c)for(d=k[c].data,e=0;e<d.length;++e)l[d[e][0]][c]=d[e][1];a.each(l,function(a,b){var c=new Date(parseInt(a,10));i+="day"===g?'"'+c.getUTCFullYear()+"-"+parseInt(c.getUTCMonth()+1,10)+"-"+c.getUTCDate()+'",':'"'+c.getUTCFullYear()+"-"+parseInt(c.getUTCMonth()+1,10)+'",';for(var d=0;d<b.length;++d){var e=b[d];Math.round(e)!==e&&(e=parseFloat(e),e=e.toFixed(2)),i+='"'+e+'",'}i=i.substring(0,i.length-1),i+="\n"})}return a(this).attr("href",encodeURI(i)),!0})});
jQuery(function(a){function b(b,c,d){a('<div class="chart-tooltip">'+d+"</div>").css({top:c-16,left:b+20}).appendTo("body").fadeIn(200)}var c=null,d=null;a(".chart-placeholder").bind("plothover",function(e,f,g){if(g){if((c!==g.dataIndex||d!==g.seriesIndex)&&(c=g.dataIndex,d=g.seriesIndex,a(".chart-tooltip").remove(),g.series.points.show||g.series.enable_tooltip)){var h=g.series.data[g.dataIndex][1],i="";g.series.prepend_label&&(i=i+g.series.label+": "),g.series.prepend_tooltip&&(i+=g.series.prepend_tooltip),i+=h,g.series.append_tooltip&&(i+=g.series.append_tooltip),g.series.pie.show?b(f.pageX,f.pageY,i):b(g.pageX,g.pageY,i)}}else a(".chart-tooltip").remove(),c=null}),a(".wc_sparkline.bars").each(function(){var b=a(this).data("sparkline"),c={grid:{show:!1}},d=[{data:b,color:a(this).data("color"),bars:{fillColor:a(this).data("color"),fill:!0,show:!0,lineWidth:1,barWidth:a(this).data("barwidth"),align:"center"},shadowSize:0}];a.plot(a(this),d,c)}),a(".wc_sparkline.lines").each(function(){var b=a(this).data("sparkline"),c={grid:{show:!1}},d=[{data:b,color:a(this).data("color"),lines:{fill:!1,show:!0,lineWidth:1,align:"center"},shadowSize:0}];a.plot(a(this),d,c)});var e=a(".range_datepicker").datepicker({changeMonth:!0,changeYear:!0,defaultDate:"",dateFormat:"yy-mm-dd",numberOfMonths:1,maxDate:"+0D",showButtonPanel:!0,showOn:"focus",buttonImageOnly:!0,onSelect:function(b){var c=a(this).is(".from")?"minDate":"maxDate",d=a(this).data("datepicker"),f=a.datepicker.parseDate(d.settings.dateFormat||a.datepicker._defaults.dateFormat,b,d.settings);e.not(this).datepicker("option",c,f)}}),f=document.createElement("a");"undefined"==typeof f.download&&a(".export_csv").hide(),a(".export_csv").click(function(){var b=a(this).data("exclude_series")||"";b=b.toString(),b=b.split(",");var c,d,e,f=a(this).data("xaxes"),g=a(this).data("groupby"),h=a(this).data("index_type"),i=a(this).data("export"),j="data:application/csv;charset=utf-8,";if("table"===i)a(this).offsetParent().find("thead tr,tbody tr").each(function(){a(this).find("th, td").each(function(){var b=a(this).text();b=b.replace("[?]","").replace("#",""),j+='"'+b+'",'}),j=j.substring(0,j.length-1),j+="\n"}),a(this).offsetParent().find("tfoot tr").each(function(){a(this).find("th, td").each(function(){var b=a(this).text();if(b=b.replace("[?]","").replace("#",""),j+='"'+b+'",',a(this).attr("colspan")>0)for(n=1;n<a(this).attr("colspan");n++)j+='"",'}),j=j.substring(0,j.length-1),j+="\n"});else{if(!window.main_chart)return!1;var k=window.main_chart.getData(),l=[];for(j+='"'+f+'",',a.each(k,function(c,d){b&&a.inArray(c.toString(),b)!==-1||l.push(d)}),c=0;c<l.length;++c)j+='"'+l[c].label+'",';j=j.substring(0,j.length-1),j+="\n";var m={};for(c=0;c<l.length;++c)for(d=l[c].data,e=0;e<d.length;++e){m[d[e][0]]=[];for(var n=0;n<l.length;++n)m[d[e][0]].push(0)}for(c=0;c<l.length;++c)for(d=l[c].data,e=0;e<d.length;++e)m[d[e][0]][c]=d[e][1];a.each(m,function(a,b){var c=new Date(parseInt(a,10));j+="none"===h?'"'+a+'",':"day"===g?'"'+c.getUTCFullYear()+"-"+parseInt(c.getUTCMonth()+1,10)+"-"+c.getUTCDate()+'",':'"'+c.getUTCFullYear()+"-"+parseInt(c.getUTCMonth()+1,10)+'",';for(var d=0;d<b.length;++d){var e=b[d];Math.round(e)!==e&&(e=parseFloat(e),e=e.toFixed(2)),j+='"'+e+'",'}j=j.substring(0,j.length-1),j+="\n"})}return a(this).attr("href",encodeURI(j)),!0})});

View File

@ -3,53 +3,48 @@ jQuery( function( $ ) {
function getEnhancedSelectFormatString() {
var formatString = {
formatMatches: function( matches ) {
if ( 1 === matches ) {
return wc_enhanced_select_params.i18n_matches_1;
}
return wc_enhanced_select_params.i18n_matches_n.replace( '%qty%', matches );
},
formatNoMatches: function() {
noResults: function() {
return wc_enhanced_select_params.i18n_no_matches;
},
formatAjaxError: function() {
errorLoading: function() {
return wc_enhanced_select_params.i18n_ajax_error;
},
formatInputTooShort: function( input, min ) {
var number = min - input.length;
inputTooShort: function( args ) {
var remainingChars = args.minimum - args.input.length;
if ( 1 === number ) {
if ( 1 === remainingChars ) {
return wc_enhanced_select_params.i18n_input_too_short_1;
}
return wc_enhanced_select_params.i18n_input_too_short_n.replace( '%qty%', number );
return wc_enhanced_select_params.i18n_input_too_short_n.replace( '%qty%', remainingChars );
},
formatInputTooLong: function( input, max ) {
var number = input.length - max;
inputTooLong: function( args ) {
var overChars = args.input.length - args.maximum;
if ( 1 === number ) {
if ( 1 === overChars ) {
return wc_enhanced_select_params.i18n_input_too_long_1;
}
return wc_enhanced_select_params.i18n_input_too_long_n.replace( '%qty%', number );
return wc_enhanced_select_params.i18n_input_too_long_n.replace( '%qty%', overChars );
},
formatSelectionTooBig: function( limit ) {
if ( 1 === limit ) {
maximumSelected: function( args ) {
if ( args.maximum === 1 ) {
return wc_enhanced_select_params.i18n_selection_too_long_1;
}
return wc_enhanced_select_params.i18n_selection_too_long_n.replace( '%qty%', limit );
return wc_enhanced_select_params.i18n_selection_too_long_n.replace( '%qty%', args.maximum );
},
formatLoadMore: function() {
loadingMore: function() {
return wc_enhanced_select_params.i18n_load_more;
},
formatSearching: function() {
searching: function() {
return wc_enhanced_select_params.i18n_searching;
}
};
var language = { 'language' : formatString };
return formatString;
return language;
}
$( document.body )

View File

@ -1 +1 @@
jQuery(function(a){function b(){var a={formatMatches:function(a){return 1===a?wc_enhanced_select_params.i18n_matches_1:wc_enhanced_select_params.i18n_matches_n.replace("%qty%",a)},formatNoMatches:function(){return wc_enhanced_select_params.i18n_no_matches},formatAjaxError:function(){return wc_enhanced_select_params.i18n_ajax_error},formatInputTooShort:function(a,b){var c=b-a.length;return 1===c?wc_enhanced_select_params.i18n_input_too_short_1:wc_enhanced_select_params.i18n_input_too_short_n.replace("%qty%",c)},formatInputTooLong:function(a,b){var c=a.length-b;return 1===c?wc_enhanced_select_params.i18n_input_too_long_1:wc_enhanced_select_params.i18n_input_too_long_n.replace("%qty%",c)},formatSelectionTooBig:function(a){return 1===a?wc_enhanced_select_params.i18n_selection_too_long_1:wc_enhanced_select_params.i18n_selection_too_long_n.replace("%qty%",a)},formatLoadMore:function(){return wc_enhanced_select_params.i18n_load_more},formatSearching:function(){return wc_enhanced_select_params.i18n_searching}};return a}a(document.body).on("wc-enhanced-select-init",function(){a(":input.wc-enhanced-select, :input.chosen_select").filter(":not(.enhanced)").each(function(){var c=a.extend({minimumResultsForSearch:10,allowClear:!!a(this).data("allow_clear"),placeholder:a(this).data("placeholder")},b());a(this).select2(c).addClass("enhanced")}),a(":input.wc-enhanced-select-nostd, :input.chosen_select_nostd").filter(":not(.enhanced)").each(function(){var c=a.extend({minimumResultsForSearch:10,allowClear:!0,placeholder:a(this).data("placeholder")},b());a(this).select2(c).addClass("enhanced")}),a(":input.wc-product-search").filter(":not(.enhanced)").each(function(){var c={allowClear:!!a(this).data("allow_clear"),placeholder:a(this).data("placeholder"),minimumInputLength:a(this).data("minimum_input_length")?a(this).data("minimum_input_length"):"3",escapeMarkup:function(a){return a},ajax:{url:wc_enhanced_select_params.ajax_url,dataType:"json",quietMillis:250,data:function(b){return{term:b.term,action:a(this).data("action")||"woocommerce_json_search_products_and_variations",security:wc_enhanced_select_params.search_products_nonce,exclude:a(this).data("exclude"),include:a(this).data("include"),limit:a(this).data("limit")}},processResults:function(b){var c=[];return b&&a.each(b,function(a,b){c.push({id:a,text:b})}),{results:c}},cache:!0}};if(c=a.extend(c,b()),a(this).select2(c).addClass("enhanced"),a(this).data("sortable")){var d=a(this),e=a(this).next(".select2-container").find("ul.select2-selection__rendered");e.sortable({placeholder:"ui-state-highlight select2-selection__choice",forcePlaceholderSize:!0,items:"li:not(.select2-search__field)",tolerance:"pointer",stop:function(){a(e.find(".select2-selection__choice").get().reverse()).each(function(){var b=a(this).data("data").id,c=d.find('option[value="'+b+'"]')[0];d.prepend(c)})}})}}),a(":input.wc-customer-search").filter(":not(.enhanced)").each(function(){var c={allowClear:!!a(this).data("allow_clear"),placeholder:a(this).data("placeholder"),minimumInputLength:a(this).data("minimum_input_length")?a(this).data("minimum_input_length"):"3",escapeMarkup:function(a){return a},ajax:{url:wc_enhanced_select_params.ajax_url,dataType:"json",quietMillis:250,data:function(b){return{term:b.term,action:"woocommerce_json_search_customers",security:wc_enhanced_select_params.search_customers_nonce,exclude:a(this).data("exclude")}},processResults:function(b){var c=[];return b&&a.each(b,function(a,b){c.push({id:a,text:b})}),{results:c}},cache:!0}};if(c=a.extend(c,b()),a(this).select2(c).addClass("enhanced"),a(this).data("sortable")){var d=a(this),e=a(this).next(".select2-container").find("ul.select2-selection__rendered");e.sortable({placeholder:"ui-state-highlight select2-selection__choice",forcePlaceholderSize:!0,items:"li:not(.select2-search__field)",tolerance:"pointer",stop:function(){a(e.find(".select2-selection__choice").get().reverse()).each(function(){var b=a(this).data("data").id,c=d.find('option[value="'+b+'"]')[0];d.prepend(c)})}})}})}).on("wc_backbone_modal_before_remove",function(){a(".wc-enhanced-select, :input.wc-product-search, :input.wc-customer-search").filter(".select2-hidden-accessible").select2("close")}).trigger("wc-enhanced-select-init"),a("html").on("click",function(b){this===b.target&&a(".wc-enhanced-select, :input.wc-product-search, :input.wc-customer-search").filter(".select2-hidden-accessible").select2("close")})});
jQuery(function(a){function b(){var a={noResults:function(){return wc_enhanced_select_params.i18n_no_matches},errorLoading:function(){return wc_enhanced_select_params.i18n_ajax_error},inputTooShort:function(a){var b=a.minimum-a.input.length;return 1===b?wc_enhanced_select_params.i18n_input_too_short_1:wc_enhanced_select_params.i18n_input_too_short_n.replace("%qty%",b)},inputTooLong:function(a){var b=a.input.length-a.maximum;return 1===b?wc_enhanced_select_params.i18n_input_too_long_1:wc_enhanced_select_params.i18n_input_too_long_n.replace("%qty%",b)},maximumSelected:function(a){return 1===a.maximum?wc_enhanced_select_params.i18n_selection_too_long_1:wc_enhanced_select_params.i18n_selection_too_long_n.replace("%qty%",a.maximum)},loadingMore:function(){return wc_enhanced_select_params.i18n_load_more},searching:function(){return wc_enhanced_select_params.i18n_searching}},b={language:a};return b}a(document.body).on("wc-enhanced-select-init",function(){a(":input.wc-enhanced-select, :input.chosen_select").filter(":not(.enhanced)").each(function(){var c=a.extend({minimumResultsForSearch:10,allowClear:!!a(this).data("allow_clear"),placeholder:a(this).data("placeholder")},b());a(this).select2(c).addClass("enhanced")}),a(":input.wc-enhanced-select-nostd, :input.chosen_select_nostd").filter(":not(.enhanced)").each(function(){var c=a.extend({minimumResultsForSearch:10,allowClear:!0,placeholder:a(this).data("placeholder")},b());a(this).select2(c).addClass("enhanced")}),a(":input.wc-product-search").filter(":not(.enhanced)").each(function(){var c={allowClear:!!a(this).data("allow_clear"),placeholder:a(this).data("placeholder"),minimumInputLength:a(this).data("minimum_input_length")?a(this).data("minimum_input_length"):"3",escapeMarkup:function(a){return a},ajax:{url:wc_enhanced_select_params.ajax_url,dataType:"json",quietMillis:250,data:function(b){return{term:b.term,action:a(this).data("action")||"woocommerce_json_search_products_and_variations",security:wc_enhanced_select_params.search_products_nonce,exclude:a(this).data("exclude"),include:a(this).data("include"),limit:a(this).data("limit")}},processResults:function(b){var c=[];return b&&a.each(b,function(a,b){c.push({id:a,text:b})}),{results:c}},cache:!0}};if(c=a.extend(c,b()),a(this).select2(c).addClass("enhanced"),a(this).data("sortable")){var d=a(this),e=a(this).next(".select2-container").find("ul.select2-selection__rendered");e.sortable({placeholder:"ui-state-highlight select2-selection__choice",forcePlaceholderSize:!0,items:"li:not(.select2-search__field)",tolerance:"pointer",stop:function(){a(e.find(".select2-selection__choice").get().reverse()).each(function(){var b=a(this).data("data").id,c=d.find('option[value="'+b+'"]')[0];d.prepend(c)})}})}}),a(":input.wc-customer-search").filter(":not(.enhanced)").each(function(){var c={allowClear:!!a(this).data("allow_clear"),placeholder:a(this).data("placeholder"),minimumInputLength:a(this).data("minimum_input_length")?a(this).data("minimum_input_length"):"3",escapeMarkup:function(a){return a},ajax:{url:wc_enhanced_select_params.ajax_url,dataType:"json",quietMillis:250,data:function(b){return{term:b.term,action:"woocommerce_json_search_customers",security:wc_enhanced_select_params.search_customers_nonce,exclude:a(this).data("exclude")}},processResults:function(b){var c=[];return b&&a.each(b,function(a,b){c.push({id:a,text:b})}),{results:c}},cache:!0}};if(c=a.extend(c,b()),a(this).select2(c).addClass("enhanced"),a(this).data("sortable")){var d=a(this),e=a(this).next(".select2-container").find("ul.select2-selection__rendered");e.sortable({placeholder:"ui-state-highlight select2-selection__choice",forcePlaceholderSize:!0,items:"li:not(.select2-search__field)",tolerance:"pointer",stop:function(){a(e.find(".select2-selection__choice").get().reverse()).each(function(){var b=a(this).data("data").id,c=d.find('option[value="'+b+'"]')[0];d.prepend(c)})}})}})}).on("wc_backbone_modal_before_remove",function(){a(".wc-enhanced-select, :input.wc-product-search, :input.wc-customer-search").filter(".select2-hidden-accessible").select2("close")}).trigger("wc-enhanced-select-init"),a("html").on("click",function(b){this===b.target&&a(".wc-enhanced-select, :input.wc-product-search, :input.wc-customer-search").filter(".select2-hidden-accessible").select2("close")})});

View File

@ -113,7 +113,7 @@
view = this;
// Set name.
$('.wc-shipping-zone-name').text( zone_name );
$('.wc-shipping-zone-name').text( zone_name ? zone_name : data.strings.default_zone_name );
// Blank out the contents.
this.$el.empty();
@ -362,7 +362,7 @@
onChangeShippingMethodSelector: function() {
var description = $( this ).find( 'option:selected' ).data( 'description' );
$( this ).parent().find( '.wc-shipping-zone-method-description' ).remove();
$( this ).after( '<p class="wc-shipping-zone-method-description">' + description + '</p>' );
$( this ).after( '<div class="wc-shipping-zone-method-description">' + description + '</div>' );
$( this ).closest( 'article' ).height( $( this ).parent().height() );
},
onTogglePostcodes: function( event ) {

File diff suppressed because one or more lines are too long

View File

@ -258,7 +258,7 @@ jQuery( function ( $ ) {
// Load videos when help button is clicked.
$( '#contextual-help-link' ).on( 'click', function() {
var frame = $( '#tab-panel-woocommerce_101_tab iframe' );
var frame = $( '#tab-panel-woocommerce_guided_tour_tab iframe' );
frame.attr( 'src', frame.data( 'src' ) );
});

File diff suppressed because one or more lines are too long

0
assets/js/flexslider/jquery.flexslider.js Executable file → Normal file
View File

0
assets/js/flexslider/jquery.flexslider.min.js vendored Executable file → Normal file
View File

View File

@ -162,11 +162,13 @@
if ( variation ) {
form.$form.trigger( 'found_variation', [ variation ] );
} else {
window.alert( wc_add_to_cart_variation_params.i18n_no_matching_variations_text );
form.$form.trigger( 'reset_data' );
form.$form.find( '.single_variation' ).after( '<p class="wc-no-matching-variations woocommerce-info">' + wc_add_to_cart_variation_params.i18n_no_matching_variations_text + '</p>' );
form.$form.find( '.wc-no-matching-variations' ).slideDown( 200 );
}
}
} else {
form.$form.trigger( 'update_variation_values' );
form.$form.trigger( 'reset_data' );
}
@ -521,6 +523,25 @@
}
};
/**
* Reset the slide position if the variation has a different image than the current one
*/
$.fn.wc_maybe_trigger_slide_position_reset = function( variation ) {
var $form = $( this ),
reset_slide_position = false,
new_image_id = ( variation && variation.image_id ) ? variation.image_id : '';
if ( $form.attr( 'current-image' ) !== new_image_id ) {
reset_slide_position = true;
}
$form.attr( 'current-image', new_image_id );
if ( reset_slide_position ) {
$( 'body' ).trigger( 'woocommerce_gallery_reset_slide_position' );
}
};
/**
* Sets product images for the chosen variation
*/
@ -544,9 +565,8 @@
$product_img.wc_set_variation_attr( 'data-large-image-width', variation.image.full_src_w );
$product_img.wc_set_variation_attr( 'data-large-image-height', variation.image.full_src_h );
$product_img_wrap.wc_set_variation_attr( 'data-thumb', variation.image.src );
$gallery_img.wc_set_variation_attr( 'src', variation.image.src );
} else {
$product_img_wrap.wc_reset_variation_attr( 'data-thumb' );
$product_img.wc_reset_variation_attr( 'large-image' );
$product_img.wc_reset_variation_attr( 'src' );
$product_img.wc_reset_variation_attr( 'width' );
$product_img.wc_reset_variation_attr( 'height' );
@ -554,16 +574,19 @@
$product_img.wc_reset_variation_attr( 'sizes' );
$product_img.wc_reset_variation_attr( 'title' );
$product_img.wc_reset_variation_attr( 'alt' );
$gallery_img.wc_reset_variation_attr( 'src' );
$product_img.wc_reset_variation_attr( 'data-large-image' );
$product_img.wc_reset_variation_attr( 'data-large-image-width' );
$product_img.wc_reset_variation_attr( 'data-large-image-height' );
window.setTimeout( function() {
$( window ).trigger( 'resize' );
}, 10 );
$product_img_wrap.wc_reset_variation_attr( 'data-thumb' );
$product_img.wc_reset_variation_attr( 'large-image' );
$gallery_img.wc_reset_variation_attr( 'src' );
}
$('body').trigger( 'woocommerce_init_gallery' );
window.setTimeout( function() {
$( 'body' ).trigger( 'woocommerce_init_gallery' );
$form.wc_maybe_trigger_slide_position_reset( variation );
$( window ).trigger( 'resize' );
}, 10 );
};
$(function() {

File diff suppressed because one or more lines are too long

View File

@ -113,7 +113,7 @@ jQuery( function( $ ) {
});
var fieldsets = $('.woocommerce-billing-fields, .woocommerce-shipping-fields, .woocommerce-address-fields');
var fieldsets = $('.woocommerce-billing-fields__field-wrapper, .woocommerce-shipping-fields__field-wrapper, .woocommerce-address-fields__field-wrapper, .woocommerce-additional-fields__field-wrapper .woocommerce-account-fields');
fieldsets.each( function( index, fieldset ) {
var rows = $( fieldset ).find( '.form-row' );

View File

@ -1 +1 @@
jQuery(function(a){function b(a,b){b?(a.find("label").append(' <abbr class="required" title="'+wc_address_i18n_params.i18n_required_text+'">*</abbr>'),a.addClass("validate-required")):(a.find("label abbr").remove(),a.removeClass("validate-required"))}if("undefined"==typeof wc_address_i18n_params)return!1;var c=wc_address_i18n_params.locale.replace(/&quot;/g,'"'),d=a.parseJSON(c);a(document.body).bind("country_to_state_changing",function(c,e,f){var g,h=f;g="undefined"!=typeof d[e]?d[e]:d.default;var i=h.find("#billing_postcode_field, #shipping_postcode_field"),j=h.find("#billing_city_field, #shipping_city_field"),k=h.find("#billing_state_field, #shipping_state_field");i.attr("data-o_class")||(i.attr("data-o_class",i.attr("class")),j.attr("data-o_class",j.attr("class")),k.attr("data-o_class",k.attr("class")));var l=a.parseJSON(wc_address_i18n_params.locale_fields);a.each(l,function(a,c){var e=h.find(c);g[a]?(g[a].label&&e.find("label").html(g[a].label),g[a].placeholder&&e.find("input").attr("placeholder",g[a].placeholder),b(e,!1),"undefined"==typeof g[a].required&&d.default[a].required===!0?b(e,!0):g[a].required===!0&&b(e,!0),"state"!==a&&(g[a].hidden===!0?e.hide().find("input").val(""):e.show()),g[a].sort?e.data("priority",g[a].sort):d.default[a].sort&&e.data("priority",d.default[a].sort)):d.default[a]&&("state"!==a&&("undefined"==typeof d.default[a].hidden||d.default[a].hidden===!1?e.show():d.default[a].hidden===!0&&e.hide().find("input").val("")),"postcode"!==a&&"city"!==a&&"state"!==a||(d.default[a].label&&e.find("label").html(d.default[a].label),d.default[a].placeholder&&e.find("input").attr("placeholder",d.default[a].placeholder)),d.default[a].required===!0&&0===e.find("label abbr").length&&b(e,!0),d.default[a].sort&&e.data("priority",d.default[a].sort))});var m=a(".woocommerce-billing-fields, .woocommerce-shipping-fields, .woocommerce-address-fields");m.each(function(b,c){var d=a(c).find(".form-row"),e=d.first().parent(),f=0;d.each(function(){a(this).data("priority")||a(this).data("priority",f+1),f=a(this).data("priority")}),d.sort(function(b,c){var d=a(b).data("priority"),e=a(c).data("priority");return d>e?1:d<e?-1:0}),d.detach().appendTo(e)})})});
jQuery(function(a){function b(a,b){b?(a.find("label").append(' <abbr class="required" title="'+wc_address_i18n_params.i18n_required_text+'">*</abbr>'),a.addClass("validate-required")):(a.find("label abbr").remove(),a.removeClass("validate-required"))}if("undefined"==typeof wc_address_i18n_params)return!1;var c=wc_address_i18n_params.locale.replace(/&quot;/g,'"'),d=a.parseJSON(c);a(document.body).bind("country_to_state_changing",function(c,e,f){var g,h=f;g="undefined"!=typeof d[e]?d[e]:d.default;var i=h.find("#billing_postcode_field, #shipping_postcode_field"),j=h.find("#billing_city_field, #shipping_city_field"),k=h.find("#billing_state_field, #shipping_state_field");i.attr("data-o_class")||(i.attr("data-o_class",i.attr("class")),j.attr("data-o_class",j.attr("class")),k.attr("data-o_class",k.attr("class")));var l=a.parseJSON(wc_address_i18n_params.locale_fields);a.each(l,function(a,c){var e=h.find(c);g[a]?(g[a].label&&e.find("label").html(g[a].label),g[a].placeholder&&e.find("input").attr("placeholder",g[a].placeholder),b(e,!1),"undefined"==typeof g[a].required&&d.default[a].required===!0?b(e,!0):g[a].required===!0&&b(e,!0),"state"!==a&&(g[a].hidden===!0?e.hide().find("input").val(""):e.show()),g[a].sort?e.data("priority",g[a].sort):d.default[a].sort&&e.data("priority",d.default[a].sort)):d.default[a]&&("state"!==a&&("undefined"==typeof d.default[a].hidden||d.default[a].hidden===!1?e.show():d.default[a].hidden===!0&&e.hide().find("input").val("")),"postcode"!==a&&"city"!==a&&"state"!==a||(d.default[a].label&&e.find("label").html(d.default[a].label),d.default[a].placeholder&&e.find("input").attr("placeholder",d.default[a].placeholder)),d.default[a].required===!0&&0===e.find("label abbr").length&&b(e,!0),d.default[a].sort&&e.data("priority",d.default[a].sort))});var m=a(".woocommerce-billing-fields__field-wrapper, .woocommerce-shipping-fields__field-wrapper, .woocommerce-address-fields__field-wrapper, .woocommerce-additional-fields__field-wrapper .woocommerce-account-fields");m.each(function(b,c){var d=a(c).find(".form-row"),e=d.first().parent(),f=0;d.each(function(){a(this).data("priority")||a(this).data("priority",f+1),f=a(this).data("priority")}),d.sort(function(b,c){var d=a(b).data("priority"),e=a(c).data("priority");return d>e?1:d<e?-1:0}),d.detach().appendTo(e)})})});

View File

@ -70,11 +70,11 @@ jQuery( function( $ ) {
var cart_timeout = null,
day_in_ms = ( 24 * 60 * 60 * 1000 );
$( document.body ).bind( 'wc_fragment_refresh updated_wc_div', function() {
$( document.body ).on( 'wc_fragment_refresh updated_wc_div', function() {
refresh_cart_fragment();
});
$( document.body ).bind( 'added_to_cart', function( event, fragments, cart_hash ) {
$( document.body ).on( 'added_to_cart', function( event, fragments, cart_hash ) {
var prev_cart_hash = sessionStorage.getItem( cart_hash_key );
if ( prev_cart_hash === null || prev_cart_hash === undefined || prev_cart_hash === '' ) {
@ -85,7 +85,7 @@ jQuery( function( $ ) {
set_cart_hash( cart_hash );
});
$( document.body ).bind( 'wc_fragments_refreshed', function() {
$( document.body ).on( 'wc_fragments_refreshed', function() {
clearTimeout( cart_timeout );
cart_timeout = setTimeout( refresh_cart_fragment, day_in_ms );
} );
@ -158,7 +158,7 @@ jQuery( function( $ ) {
$( '.hide_cart_widget_if_empty' ).closest( '.widget_shopping_cart' ).hide();
}
$( document.body ).bind( 'adding_to_cart', function() {
$( document.body ).on( 'adding_to_cart', function() {
$( '.hide_cart_widget_if_empty' ).closest( '.widget_shopping_cart' ).show();
});
});

View File

@ -1 +1 @@
jQuery(function(a){function b(){e&&sessionStorage.setItem("wc_cart_created",(new Date).getTime())}function c(a){e&&(localStorage.setItem(f,a),sessionStorage.setItem(f,a))}function d(){a.ajax(g)}if("undefined"==typeof wc_cart_fragments_params)return!1;var e,f=wc_cart_fragments_params.ajax_url.toString()+"-wc_cart_hash";try{e="sessionStorage"in window&&null!==window.sessionStorage,window.sessionStorage.setItem("wc","test"),window.sessionStorage.removeItem("wc"),window.localStorage.setItem("wc","test"),window.localStorage.removeItem("wc")}catch(a){e=!1}var g={url:wc_cart_fragments_params.wc_ajax_url.toString().replace("%%endpoint%%","get_refreshed_fragments"),type:"POST",success:function(d){d&&d.fragments&&(a.each(d.fragments,function(b,c){a(b).replaceWith(c)}),e&&(sessionStorage.setItem(wc_cart_fragments_params.fragment_name,JSON.stringify(d.fragments)),c(d.cart_hash),d.cart_hash&&b()),a(document.body).trigger("wc_fragments_refreshed"))}};if(e){var h=null,i=864e5;a(document.body).bind("wc_fragment_refresh updated_wc_div",function(){d()}),a(document.body).bind("added_to_cart",function(a,d,e){var g=sessionStorage.getItem(f);null!==g&&void 0!==g&&""!==g||b(),sessionStorage.setItem(wc_cart_fragments_params.fragment_name,JSON.stringify(d)),c(e)}),a(document.body).bind("wc_fragments_refreshed",function(){clearTimeout(h),h=setTimeout(d,i)}),a(window).on("storage onstorage",function(a){f===a.originalEvent.key&&localStorage.getItem(f)!==sessionStorage.getItem(f)&&d()}),a(window).on("pageshow",function(b){b.originalEvent.persisted&&(a(".widget_shopping_cart_content").empty(),a(document.body).trigger("wc_fragment_refresh"))});try{var j=a.parseJSON(sessionStorage.getItem(wc_cart_fragments_params.fragment_name)),k=sessionStorage.getItem(f),l=Cookies.get("woocommerce_cart_hash"),m=sessionStorage.getItem("wc_cart_created");if(null!==k&&void 0!==k&&""!==k||(k=""),null!==l&&void 0!==l&&""!==l||(l=""),k&&(null===m||void 0===m||""===m))throw"No cart_created";if(m){var n=1*m+i,o=(new Date).getTime();if(n<o)throw"Fragment expired";h=setTimeout(d,n-o)}if(!j||!j["div.widget_shopping_cart_content"]||k!==l)throw"No fragment";a.each(j,function(b,c){a(b).replaceWith(c)}),a(document.body).trigger("wc_fragments_loaded")}catch(a){d()}}else d();Cookies.get("woocommerce_items_in_cart")>0?a(".hide_cart_widget_if_empty").closest(".widget_shopping_cart").show():a(".hide_cart_widget_if_empty").closest(".widget_shopping_cart").hide(),a(document.body).bind("adding_to_cart",function(){a(".hide_cart_widget_if_empty").closest(".widget_shopping_cart").show()})});
jQuery(function(a){function b(){e&&sessionStorage.setItem("wc_cart_created",(new Date).getTime())}function c(a){e&&(localStorage.setItem(f,a),sessionStorage.setItem(f,a))}function d(){a.ajax(g)}if("undefined"==typeof wc_cart_fragments_params)return!1;var e,f=wc_cart_fragments_params.ajax_url.toString()+"-wc_cart_hash";try{e="sessionStorage"in window&&null!==window.sessionStorage,window.sessionStorage.setItem("wc","test"),window.sessionStorage.removeItem("wc"),window.localStorage.setItem("wc","test"),window.localStorage.removeItem("wc")}catch(a){e=!1}var g={url:wc_cart_fragments_params.wc_ajax_url.toString().replace("%%endpoint%%","get_refreshed_fragments"),type:"POST",success:function(d){d&&d.fragments&&(a.each(d.fragments,function(b,c){a(b).replaceWith(c)}),e&&(sessionStorage.setItem(wc_cart_fragments_params.fragment_name,JSON.stringify(d.fragments)),c(d.cart_hash),d.cart_hash&&b()),a(document.body).trigger("wc_fragments_refreshed"))}};if(e){var h=null,i=864e5;a(document.body).on("wc_fragment_refresh updated_wc_div",function(){d()}),a(document.body).on("added_to_cart",function(a,d,e){var g=sessionStorage.getItem(f);null!==g&&void 0!==g&&""!==g||b(),sessionStorage.setItem(wc_cart_fragments_params.fragment_name,JSON.stringify(d)),c(e)}),a(document.body).on("wc_fragments_refreshed",function(){clearTimeout(h),h=setTimeout(d,i)}),a(window).on("storage onstorage",function(a){f===a.originalEvent.key&&localStorage.getItem(f)!==sessionStorage.getItem(f)&&d()}),a(window).on("pageshow",function(b){b.originalEvent.persisted&&(a(".widget_shopping_cart_content").empty(),a(document.body).trigger("wc_fragment_refresh"))});try{var j=a.parseJSON(sessionStorage.getItem(wc_cart_fragments_params.fragment_name)),k=sessionStorage.getItem(f),l=Cookies.get("woocommerce_cart_hash"),m=sessionStorage.getItem("wc_cart_created");if(null!==k&&void 0!==k&&""!==k||(k=""),null!==l&&void 0!==l&&""!==l||(l=""),k&&(null===m||void 0===m||""===m))throw"No cart_created";if(m){var n=1*m+i,o=(new Date).getTime();if(n<o)throw"Fragment expired";h=setTimeout(d,n-o)}if(!j||!j["div.widget_shopping_cart_content"]||k!==l)throw"No fragment";a.each(j,function(b,c){a(b).replaceWith(c)}),a(document.body).trigger("wc_fragments_loaded")}catch(a){d()}}else d();Cookies.get("woocommerce_items_in_cart")>0?a(".hide_cart_widget_if_empty").closest(".widget_shopping_cart").show():a(".hide_cart_widget_if_empty").closest(".widget_shopping_cart").hide(),a(document.body).on("adding_to_cart",function(){a(".hide_cart_widget_if_empty").closest(".widget_shopping_cart").show()})});

View File

@ -437,7 +437,7 @@ jQuery( function( $ ) {
success: function( response ) {
$( '.woocommerce-error, .woocommerce-message, .woocommerce-info' ).remove();
show_notice( response );
$( document.body ).trigger( 'applied_coupon' );
$( document.body ).trigger( 'applied_coupon', [ coupon_code ] );
},
complete: function() {
unblock( $form );
@ -474,7 +474,7 @@ jQuery( function( $ ) {
success: function( response ) {
$( '.woocommerce-error, .woocommerce-message, .woocommerce-info' ).remove();
show_notice( response );
$( document.body ).trigger( 'removed_coupon' );
$( document.body ).trigger( 'removed_coupon', [ coupon ] );
unblock( $wrapper );
},
complete: function() {
@ -489,22 +489,24 @@ jQuery( function( $ ) {
* @param {JQuery Object} $form The cart form.
*/
quantity_update: function( $form ) {
// Provide the submit button value because wc-form-handler expects it.
$( '<input />' ).attr( 'type', 'hidden' )
.attr( 'name', 'update_cart' )
.attr( 'value', 'Update Cart' )
.appendTo( $form );
block( $form );
block( $( 'div.cart_totals' ) );
// Provide the submit button value because wc-form-handler expects it.
$( '<input />' ).attr( 'type', 'hidden' )
.attr( 'name', 'update_cart' )
.attr( 'value', 'Update Cart' )
.appendTo( $form );
// Make call to actual form post URL.
$.ajax( {
type: $form.attr( 'method' ),
url: $form.attr( 'action' ),
data: $form.serialize(),
dataType: 'html',
success: update_wc_div,
success: function( response ) {
update_wc_div( response );
},
complete: function() {
unblock( $form );
unblock( $( 'div.cart_totals' ) );

File diff suppressed because one or more lines are too long

View File

@ -25,11 +25,14 @@ jQuery( function( $ ) {
this.$order_review.on( 'click', 'input[name="payment_method"]', this.payment_method_selected );
}
// Prevent HTML5 validation which can conflict.
this.$checkout_form.attr( 'novalidate', 'novalidate' );
// Form submission
this.$checkout_form.on( 'submit', this.submit );
// Inline validation
this.$checkout_form.on( 'blur change', '.input-text, select, input:checkbox', this.validate_field );
this.$checkout_form.on( 'input blur change', '.input-text, select, input:checkbox', this.validate_field );
// Manual trigger
this.$checkout_form.on( 'update', this.trigger_update_checkout );
@ -104,6 +107,8 @@ jQuery( function( $ ) {
$( 'div.create-account' ).hide();
if ( $( this ).is( ':checked' ) ) {
// Ensure password is not pre-populated.
$( '#account_password' ).val( '' ).change();
$( 'div.create-account' ).slideDown();
}
},
@ -163,36 +168,45 @@ jQuery( function( $ ) {
reset_update_checkout_timer: function() {
clearTimeout( wc_checkout_form.updateTimer );
},
validate_field: function() {
var $this = $( this ),
$parent = $this.closest( '.form-row' ),
validated = true;
validate_field: function( e ) {
var $this = $( this ),
$parent = $this.closest( '.form-row' ),
validated = true,
validate_required = $parent.is( '.validate-required' ),
validate_email = $parent.is( '.validate-email' ),
event_type = e.type;
if ( $parent.is( '.validate-required' ) ) {
if ( 'checkbox' === $this.attr( 'type' ) && ! $this.is( ':checked' ) ) {
$parent.removeClass( 'woocommerce-validated' ).addClass( 'woocommerce-invalid woocommerce-invalid-required-field' );
validated = false;
} else if ( $this.val() === '' ) {
$parent.removeClass( 'woocommerce-validated' ).addClass( 'woocommerce-invalid woocommerce-invalid-required-field' );
validated = false;
}
if ( 'input' === event_type ) {
$parent.removeClass( 'woocommerce-invalid woocommerce-invalid-required-field woocommerce-invalid-email woocommerce-validated' );
}
if ( $parent.is( '.validate-email' ) ) {
if ( $this.val() ) {
if ( 'focusout' === event_type || 'change' === event_type ) {
/* 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])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\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]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([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])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);
if ( ! pattern.test( $this.val() ) ) {
$parent.removeClass( 'woocommerce-validated' ).addClass( 'woocommerce-invalid woocommerce-invalid-email' );
if ( validate_required ) {
if ( 'checkbox' === $this.attr( 'type' ) && ! $this.is( ':checked' ) ) {
$parent.removeClass( 'woocommerce-validated' ).addClass( 'woocommerce-invalid woocommerce-invalid-required-field' );
validated = false;
} else if ( $this.val() === '' ) {
$parent.removeClass( 'woocommerce-validated' ).addClass( 'woocommerce-invalid woocommerce-invalid-required-field' );
validated = false;
}
}
}
if ( validated ) {
$parent.removeClass( 'woocommerce-invalid woocommerce-invalid-required-field' ).addClass( 'woocommerce-validated' );
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])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\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]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([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])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);
if ( ! pattern.test( $this.val() ) ) {
$parent.removeClass( 'woocommerce-validated' ).addClass( 'woocommerce-invalid woocommerce-invalid-email' );
validated = false;
}
}
}
if ( validated ) {
$parent.removeClass( 'woocommerce-invalid woocommerce-invalid-required-field woocommerce-invalid-email' ).addClass( 'woocommerce-validated' );
}
}
},
update_checkout: function( event, args ) {
@ -280,7 +294,7 @@ jQuery( function( $ ) {
var selectedPaymentMethod = $( '.woocommerce-checkout input[name="payment_method"]:checked' ).attr( 'id' );
// Reload the page if requested
if ( 'true' === data.reload ) {
if ( true === data.reload ) {
window.location.reload();
return;
}
@ -290,6 +304,20 @@ jQuery( function( $ ) {
var termsCheckBoxChecked = $( '#terms' ).prop( 'checked' );
// Save payment details to a temporary object
var paymentDetails = {};
$( '.payment_box input' ).each( function() {
var ID = $( this ).attr( 'id' );
if ( ID ) {
if ( $.inArray( $( this ).attr( 'type' ), [ 'checkbox', 'radio' ] ) !== -1 ) {
paymentDetails[ ID ] = $( this ).prop( 'checked' );
} else {
paymentDetails[ ID ] = $( this ).val();
}
}
});
// Always update the fragments
if ( data && data.fragments ) {
$.each( data.fragments, function ( key, value ) {
@ -303,6 +331,21 @@ jQuery( function( $ ) {
$( '#terms' ).prop( 'checked', true );
}
// Fill in the payment details if possible
if ( ! $.isEmptyObject( paymentDetails ) ) {
$( '.payment_box input' ).each( function() {
var ID = $( this ).attr( 'id' );
if ( ID ) {
if ( $.inArray( $( this ).attr( 'type' ), [ 'checkbox', 'radio' ] ) !== -1 ) {
$( this ).prop( 'checked', paymentDetails[ ID ] ).change();
} else {
$( this ).val( paymentDetails[ ID ] ).change();
}
}
});
}
// Check for error
if ( 'failure' === data.result ) {
@ -313,7 +356,7 @@ jQuery( function( $ ) {
// Add new errors returned by this event
if ( data.messages ) {
$form.prepend( '<div class="woocommerce-NoticeGroup-updateOrderReview">' + data.messages + '</div>' );
$form.prepend( '<div class="woocommerce-NoticeGroup woocommerce-NoticeGroup-updateOrderReview">' + data.messages + '</div>' );
} else {
$form.prepend( data );
}
@ -405,26 +448,26 @@ jQuery( function( $ ) {
dataType: 'json',
success: function( result ) {
try {
if ( result.result === 'success' ) {
if ( 'success' === result.result ) {
if ( -1 === result.redirect.indexOf( 'https://' ) || -1 === result.redirect.indexOf( 'http://' ) ) {
window.location = result.redirect;
} else {
window.location = decodeURI( result.redirect );
}
} else if ( result.result === 'failure' ) {
} else if ( 'failure' === result.result ) {
throw 'Result failure';
} else {
throw 'Invalid response';
}
} catch( err ) {
// Reload page
if ( result.reload === 'true' ) {
if ( true === result.reload ) {
window.location.reload();
return;
}
// Trigger update in case we need a fresh nonce
if ( result.refresh === 'true' ) {
if ( true === result.refresh ) {
$( document.body ).trigger( 'update_checkout' );
}
@ -445,8 +488,8 @@ jQuery( function( $ ) {
return false;
},
submit_error: function( error_message ) {
$( '.woocommerce-error, .woocommerce-message' ).remove();
wc_checkout_form.$checkout_form.prepend( error_message );
$( '.woocommerce-NoticeGroup-checkout, .woocommerce-error, .woocommerce-message' ).remove();
wc_checkout_form.$checkout_form.prepend( '<div class="woocommerce-NoticeGroup woocommerce-NoticeGroup-checkout">' + error_message + '</div>' );
wc_checkout_form.$checkout_form.removeClass( 'processing' ).unblock();
wc_checkout_form.$checkout_form.find( '.input-text, select, input:checkbox' ).blur();
$( 'html, body' ).animate({

File diff suppressed because one or more lines are too long

View File

@ -8,53 +8,47 @@ jQuery( function( $ ) {
function getEnhancedSelectFormatString() {
var formatString = {
formatMatches: function( matches ) {
if ( 1 === matches ) {
return wc_country_select_params.i18n_matches_1;
}
return wc_country_select_params.i18n_matches_n.replace( '%qty%', matches );
},
formatNoMatches: function() {
noResults: function() {
return wc_country_select_params.i18n_no_matches;
},
formatAjaxError: function() {
errorLoading: function() {
return wc_country_select_params.i18n_ajax_error;
},
formatInputTooShort: function( input, min ) {
var number = min - input.length;
inputTooShort: function( args ) {
var remainingChars = args.minimum - args.input.length;
if ( 1 === number ) {
if ( 1 === remainingChars ) {
return wc_country_select_params.i18n_input_too_short_1;
}
return wc_country_select_params.i18n_input_too_short_n.replace( '%qty%', number );
return wc_country_select_params.i18n_input_too_short_n.replace( '%qty%', remainingChars );
},
formatInputTooLong: function( input, max ) {
var number = input.length - max;
inputTooLong: function( args ) {
var overChars = args.input.length - args.maximum;
if ( 1 === number ) {
if ( 1 === overChars ) {
return wc_country_select_params.i18n_input_too_long_1;
}
return wc_country_select_params.i18n_input_too_long_n.replace( '%qty%', number );
return wc_country_select_params.i18n_input_too_long_n.replace( '%qty%', overChars );
},
formatSelectionTooBig: function( limit ) {
if ( 1 === limit ) {
maximumSelected: function( args ) {
if ( 1 === args.maximum ) {
return wc_country_select_params.i18n_selection_too_long_1;
}
return wc_country_select_params.i18n_selection_too_long_n.replace( '%qty%', limit );
return wc_country_select_params.i18n_selection_too_long_n.replace( '%qty%', args.maximum );
},
formatLoadMore: function() {
loadingMore: function() {
return wc_country_select_params.i18n_load_more;
},
formatSearching: function() {
searching: function() {
return wc_country_select_params.i18n_searching;
}
};
return formatString;
var language = { 'language' : formatString };
return language;
}
// Select2 Enhancement if it exists
@ -67,6 +61,10 @@ jQuery( function( $ ) {
}, getEnhancedSelectFormatString() );
$( this ).select2( select2_args );
// Maintain focus after select https://github.com/select2/select2/issues/4384
$( this ).on( 'select2:select', function() {
$( this ).focus();
} );
});
};

View File

@ -1 +1 @@
jQuery(function(a){function b(){var a={formatMatches:function(a){return 1===a?wc_country_select_params.i18n_matches_1:wc_country_select_params.i18n_matches_n.replace("%qty%",a)},formatNoMatches:function(){return wc_country_select_params.i18n_no_matches},formatAjaxError:function(){return wc_country_select_params.i18n_ajax_error},formatInputTooShort:function(a,b){var c=b-a.length;return 1===c?wc_country_select_params.i18n_input_too_short_1:wc_country_select_params.i18n_input_too_short_n.replace("%qty%",c)},formatInputTooLong:function(a,b){var c=a.length-b;return 1===c?wc_country_select_params.i18n_input_too_long_1:wc_country_select_params.i18n_input_too_long_n.replace("%qty%",c)},formatSelectionTooBig:function(a){return 1===a?wc_country_select_params.i18n_selection_too_long_1:wc_country_select_params.i18n_selection_too_long_n.replace("%qty%",a)},formatLoadMore:function(){return wc_country_select_params.i18n_load_more},formatSearching:function(){return wc_country_select_params.i18n_searching}};return a}if("undefined"==typeof wc_country_select_params)return!1;if(a().select2){var c=function(){a("select.country_select:visible, select.state_select:visible").each(function(){var c=a.extend({placeholderOption:"first",width:"100%"},b());a(this).select2(c)})};c(),a(document.body).bind("country_to_state_changed",function(){c()})}var d=wc_country_select_params.countries.replace(/&quot;/g,'"'),e=a.parseJSON(d);a(document.body).on("change","select.country_to_state, input.country_to_state",function(){var b=a(this).closest(".woocommerce-billing-fields, .woocommerce-shipping-fields, .woocommerce-shipping-calculator");b.length||(b=a(this).closest(".form-row").parent());var c=a(this).val(),d=b.find("#billing_state, #shipping_state, #calc_shipping_state"),f=d.parent(),g=d.attr("name"),h=d.attr("id"),i=d.val(),j=d.attr("placeholder")||d.attr("data-placeholder")||"";if(e[c])if(a.isEmptyObject(e[c]))d.parent().hide().find(".select2-container").remove(),d.replaceWith('<input type="hidden" class="hidden" name="'+g+'" id="'+h+'" value="" placeholder="'+j+'" />'),a(document.body).trigger("country_to_state_changed",[c,b]);else{var k="",l=e[c];for(var m in l)l.hasOwnProperty(m)&&(k=k+'<option value="'+m+'">'+l[m]+"</option>");d.parent().show(),d.is("input")&&(d.replaceWith('<select name="'+g+'" id="'+h+'" class="state_select" data-placeholder="'+j+'"></select>'),d=b.find("#billing_state, #shipping_state, #calc_shipping_state")),d.html('<option value="">'+wc_country_select_params.i18n_select_state_text+"</option>"+k),d.val(i).change(),a(document.body).trigger("country_to_state_changed",[c,b])}else d.is("select")?(f.show().find(".select2-container").remove(),d.replaceWith('<input type="text" class="input-text" name="'+g+'" id="'+h+'" placeholder="'+j+'" />'),a(document.body).trigger("country_to_state_changed",[c,b])):d.is('input[type="hidden"]')&&(f.show().find(".select2-container").remove(),d.replaceWith('<input type="text" class="input-text" name="'+g+'" id="'+h+'" placeholder="'+j+'" />'),a(document.body).trigger("country_to_state_changed",[c,b]));a(document.body).trigger("country_to_state_changing",[c,b])}),a(function(){a(":input.country_to_state").change()})});
jQuery(function(a){function b(){var a={noResults:function(){return wc_country_select_params.i18n_no_matches},errorLoading:function(){return wc_country_select_params.i18n_ajax_error},inputTooShort:function(a){var b=a.minimum-a.input.length;return 1===b?wc_country_select_params.i18n_input_too_short_1:wc_country_select_params.i18n_input_too_short_n.replace("%qty%",b)},inputTooLong:function(a){var b=a.input.length-a.maximum;return 1===b?wc_country_select_params.i18n_input_too_long_1:wc_country_select_params.i18n_input_too_long_n.replace("%qty%",b)},maximumSelected:function(a){return 1===a.maximum?wc_country_select_params.i18n_selection_too_long_1:wc_country_select_params.i18n_selection_too_long_n.replace("%qty%",a.maximum)},loadingMore:function(){return wc_country_select_params.i18n_load_more},searching:function(){return wc_country_select_params.i18n_searching}},b={language:a};return b}if("undefined"==typeof wc_country_select_params)return!1;if(a().select2){var c=function(){a("select.country_select:visible, select.state_select:visible").each(function(){var c=a.extend({placeholderOption:"first",width:"100%"},b());a(this).select2(c),a(this).on("select2:select",function(){a(this).focus()})})};c(),a(document.body).bind("country_to_state_changed",function(){c()})}var d=wc_country_select_params.countries.replace(/&quot;/g,'"'),e=a.parseJSON(d);a(document.body).on("change","select.country_to_state, input.country_to_state",function(){var b=a(this).closest(".woocommerce-billing-fields, .woocommerce-shipping-fields, .woocommerce-shipping-calculator");b.length||(b=a(this).closest(".form-row").parent());var c=a(this).val(),d=b.find("#billing_state, #shipping_state, #calc_shipping_state"),f=d.parent(),g=d.attr("name"),h=d.attr("id"),i=d.val(),j=d.attr("placeholder")||d.attr("data-placeholder")||"";if(e[c])if(a.isEmptyObject(e[c]))d.parent().hide().find(".select2-container").remove(),d.replaceWith('<input type="hidden" class="hidden" name="'+g+'" id="'+h+'" value="" placeholder="'+j+'" />'),a(document.body).trigger("country_to_state_changed",[c,b]);else{var k="",l=e[c];for(var m in l)l.hasOwnProperty(m)&&(k=k+'<option value="'+m+'">'+l[m]+"</option>");d.parent().show(),d.is("input")&&(d.replaceWith('<select name="'+g+'" id="'+h+'" class="state_select" data-placeholder="'+j+'"></select>'),d=b.find("#billing_state, #shipping_state, #calc_shipping_state")),d.html('<option value="">'+wc_country_select_params.i18n_select_state_text+"</option>"+k),d.val(i).change(),a(document.body).trigger("country_to_state_changed",[c,b])}else d.is("select")?(f.show().find(".select2-container").remove(),d.replaceWith('<input type="text" class="input-text" name="'+g+'" id="'+h+'" placeholder="'+j+'" />'),a(document.body).trigger("country_to_state_changed",[c,b])):d.is('input[type="hidden"]')&&(f.show().find(".select2-container").remove(),d.replaceWith('<input type="text" class="input-text" name="'+g+'" id="'+h+'" placeholder="'+j+'" />'),a(document.body).trigger("country_to_state_changed",[c,b]));a(document.body).trigger("country_to_state_changing",[c,b])}),a(function(){a(":input.country_to_state").change()})});

View File

@ -19,16 +19,17 @@ jQuery( function( $ ) {
* Strength Meter.
*/
strengthMeter: function() {
var wrapper = $( 'form.register, form.checkout, form.edit-account, form.lost_reset_password' ),
submit = $( 'input[type="submit"]', wrapper ),
field = $( '#reg_password, #account_password, #password_1', wrapper ),
strength = 1;
var wrapper = $( 'form.register, form.checkout, form.edit-account, form.lost_reset_password' ),
submit = $( 'input[type="submit"]', wrapper ),
field = $( '#reg_password, #account_password, #password_1', wrapper ),
strength = 1,
fieldValue = field.val();
wc_password_strength_meter.includeMeter( wrapper, field );
strength = wc_password_strength_meter.checkPasswordStrength( wrapper, field );
if ( strength < wc_password_strength_meter_params.min_password_strength && ! wrapper.is( 'form.checkout' ) ) {
if ( fieldValue.length > 0 && strength < wc_password_strength_meter_params.min_password_strength && ! wrapper.is( 'form.checkout' ) ) {
submit.attr( 'disabled', 'disabled' ).addClass( 'disabled' );
} else {
submit.removeAttr( 'disabled', 'disabled' ).removeClass( 'disabled' );

View File

@ -1 +1 @@
jQuery(function(a){var b={init:function(){a(document.body).on("keyup change","form.register #reg_password, form.checkout #account_password, form.edit-account #password_1, form.lost_reset_password #password_1",this.strengthMeter),a("form.checkout #createaccount").change()},strengthMeter:function(){var c=a("form.register, form.checkout, form.edit-account, form.lost_reset_password"),d=a('input[type="submit"]',c),e=a("#reg_password, #account_password, #password_1",c),f=1;b.includeMeter(c,e),f=b.checkPasswordStrength(c,e),f<wc_password_strength_meter_params.min_password_strength&&!c.is("form.checkout")?d.attr("disabled","disabled").addClass("disabled"):d.removeAttr("disabled","disabled").removeClass("disabled")},includeMeter:function(b,c){var d=b.find(".woocommerce-password-strength");""===c.val()?(d.remove(),a(document.body).trigger("wc-password-strength-removed")):0===d.length&&(c.after('<div class="woocommerce-password-strength" aria-live="polite"></div>'),a(document.body).trigger("wc-password-strength-added"))},checkPasswordStrength:function(a,b){var c=a.find(".woocommerce-password-strength"),d=a.find(".woocommerce-password-hint"),e='<small class="woocommerce-password-hint">'+wc_password_strength_meter_params.i18n_password_hint+"</small>",f=wp.passwordStrength.meter(b.val(),wp.passwordStrength.userInputBlacklist()),g="";switch(c.removeClass("short bad good strong"),d.remove(),f<wc_password_strength_meter_params.min_password_strength&&(g=" - "+wc_password_strength_meter_params.i18n_password_error),f){case 0:c.addClass("short").html(pwsL10n.short+g),c.after(e);break;case 1:c.addClass("bad").html(pwsL10n.bad+g),c.after(e);break;case 2:c.addClass("bad").html(pwsL10n.bad+g),c.after(e);break;case 3:c.addClass("good").html(pwsL10n.good+g);break;case 4:c.addClass("strong").html(pwsL10n.strong+g);break;case 5:c.addClass("short").html(pwsL10n.mismatch)}return f}};b.init()});
jQuery(function(a){var b={init:function(){a(document.body).on("keyup change","form.register #reg_password, form.checkout #account_password, form.edit-account #password_1, form.lost_reset_password #password_1",this.strengthMeter),a("form.checkout #createaccount").change()},strengthMeter:function(){var c=a("form.register, form.checkout, form.edit-account, form.lost_reset_password"),d=a('input[type="submit"]',c),e=a("#reg_password, #account_password, #password_1",c),f=1,g=e.val();b.includeMeter(c,e),f=b.checkPasswordStrength(c,e),g.length>0&&f<wc_password_strength_meter_params.min_password_strength&&!c.is("form.checkout")?d.attr("disabled","disabled").addClass("disabled"):d.removeAttr("disabled","disabled").removeClass("disabled")},includeMeter:function(b,c){var d=b.find(".woocommerce-password-strength");""===c.val()?(d.remove(),a(document.body).trigger("wc-password-strength-removed")):0===d.length&&(c.after('<div class="woocommerce-password-strength" aria-live="polite"></div>'),a(document.body).trigger("wc-password-strength-added"))},checkPasswordStrength:function(a,b){var c=a.find(".woocommerce-password-strength"),d=a.find(".woocommerce-password-hint"),e='<small class="woocommerce-password-hint">'+wc_password_strength_meter_params.i18n_password_hint+"</small>",f=wp.passwordStrength.meter(b.val(),wp.passwordStrength.userInputBlacklist()),g="";switch(c.removeClass("short bad good strong"),d.remove(),f<wc_password_strength_meter_params.min_password_strength&&(g=" - "+wc_password_strength_meter_params.i18n_password_error),f){case 0:c.addClass("short").html(pwsL10n.short+g),c.after(e);break;case 1:c.addClass("bad").html(pwsL10n.bad+g),c.after(e);break;case 2:c.addClass("bad").html(pwsL10n.bad+g),c.after(e);break;case 3:c.addClass("good").html(pwsL10n.good+g);break;case 4:c.addClass("strong").html(pwsL10n.strong+g);break;case 5:c.addClass("short").html(pwsL10n.mismatch)}return f}};b.init()});

View File

@ -67,7 +67,7 @@ jQuery( function( $ ) {
}
})
.on( 'woocommerce_init_gallery', function() {
if ( $.isFunction( $.fn.zoom ) ) {
if ( $.isFunction( $.fn.zoom ) && wc_single_product_params.zoom_enabled ) {
wc_product_gallery.init_zoom();
}
});
@ -84,34 +84,17 @@ jQuery( function( $ ) {
* Initialize gallery actions and events.
*/
init: function() {
// Init FlexSlider if present.
if ( $.isFunction( $.fn.flexslider ) ) {
if ( $.isFunction( $.fn.flexslider ) && wc_single_product_params.flexslider_enabled ) {
this.init_flexslider();
}
// Init Zoom if present.
if ( $.isFunction( $.fn.zoom ) ) {
if ( $.isFunction( $.fn.zoom ) && wc_single_product_params.zoom_enabled ) {
this.init_zoom();
}
// Init PhotoSwipe if present.
if ( typeof PhotoSwipe !== 'undefined' ) {
if ( typeof PhotoSwipe !== 'undefined' && wc_single_product_params.photoswipe_enabled ) {
this.init_photoswipe();
// Trigger photoswipe.
$( document ).on( 'click', '.woocommerce-product-gallery__trigger', this.trigger_photoswipe );
}
},
/**
* Detect if the visitor is using a touch device.
*
* @return bool
*/
is_touch_device: function() {
return 'ontouchstart' in window || navigator.maxTouchPoints;
},
/**
* Initialize flexSlider.
*/
@ -124,18 +107,54 @@ jQuery( function( $ ) {
controlNav: wc_single_product_params.flexslider.controlNav,
slideshow: wc_single_product_params.flexslider.slideshow,
animationSpeed: wc_single_product_params.flexslider.animationSpeed,
animationLoop: false // Breaks photoswipe pagination if true. It's hard disabled because we don't need it anyway (no next/prev enabled in flex).
animationLoop: wc_single_product_params.flexslider.animationLoop, // Breaks photoswipe pagination if true.
start: function() {
var $images = $( '.woocommerce-product-gallery__image' );
var largest_height = 0;
$images.each( function() {
var height = $( this ).height();
if ( height > largest_height ) {
largest_height = height;
}
});
$images.each( function() {
$( this ).css( 'min-height', largest_height );
});
}
});
$( 'body' ).on( 'woocommerce_gallery_reset_slide_position', function(){
$( '.woocommerce-product-gallery' ).flexslider( 0 );
} );
},
/**
* Init zoom.
*/
init_zoom: function() {
var zoom_target = $( '.woocommerce-product-gallery__image' ),
enable_zoom = false;
if ( ! wc_single_product_params.flexslider_enabled ) {
zoom_target = zoom_target.first();
}
$( zoom_target ).each( function( index, target ) {
var image = $( target ).find( 'img' );
if ( image.attr( 'width' ) > $( '.woocommerce-product-gallery' ).width() ) {
enable_zoom = true;
return false;
}
} );
// But only zoom if the img is larger than its container.
if ( ( $( '.woocommerce-product-gallery__image img' ).attr( 'width' ) > $( '.woocommerce-product-gallery' ).width() ) ) {
$( '.woocommerce-product-gallery__image' ).trigger( 'zoom.destroy' );
$( '.woocommerce-product-gallery__image' ).zoom({
if ( enable_zoom ) {
zoom_target.trigger( 'zoom.destroy' );
zoom_target.zoom({
touch: false
});
}
@ -175,7 +194,11 @@ jQuery( function( $ ) {
* Init PhotoSwipe.
*/
init_photoswipe: function() {
$( '.woocommerce-product-gallery' ).prepend( '<a href="#" class="woocommerce-product-gallery__trigger">🔍</a>' );
if ( wc_single_product_params.zoom_enabled ) {
$( '.woocommerce-product-gallery--with-images' ).prepend( '<a href="#" class="woocommerce-product-gallery__trigger">🔍</a>' );
$( document ).on( 'click', '.woocommerce-product-gallery__trigger', this.trigger_photoswipe );
}
$( document ).on( 'click', '.woocommerce-product-gallery__image a', this.trigger_photoswipe );
},
/**
@ -184,14 +207,19 @@ jQuery( function( $ ) {
trigger_photoswipe: function( e ) {
e.preventDefault();
var pswpElement = $( '.pswp' )[0];
var pswpElement = $( '.pswp' )[0],
items = wc_product_gallery.get_gallery_items(),
target = $( e.target ),
clicked;
// Build items array.
var items = wc_product_gallery.get_gallery_items();
if ( ! target.is( '.woocommerce-product-gallery__trigger' ) ) {
clicked = e.target.closest( 'figure' );
} else {
clicked = target.parents( '.woocommerce-product-gallery' ).find( '.flex-active-slide' );
}
// Define options.
var options = {
index: items.index,
index: $( clicked ).index(),
shareEl: false,
closeOnScroll: false,
history: false,

View File

@ -1 +1 @@
jQuery(function(a){if("undefined"==typeof wc_single_product_params)return!1;a("body").on("init",".wc-tabs-wrapper, .woocommerce-tabs",function(){a(".wc-tab, .woocommerce-tabs .panel:not(.panel .panel)").hide();var b=window.location.hash,c=window.location.href,d=a(this).find(".wc-tabs, ul.tabs").first();b.toLowerCase().indexOf("comment-")>=0||"#reviews"===b||"#tab-reviews"===b?d.find("li.reviews_tab a").click():c.indexOf("comment-page-")>0||c.indexOf("cpage=")>0?d.find("li.reviews_tab a").click():d.find("li:first a").click()}).on("click",".wc-tabs li a, ul.tabs li a",function(b){b.preventDefault();var c=a(this),d=c.closest(".wc-tabs-wrapper, .woocommerce-tabs"),e=d.find(".wc-tabs, ul.tabs");e.find("li").removeClass("active"),d.find(".wc-tab, .panel:not(.panel .panel)").hide(),c.closest("li").addClass("active"),d.find(c.attr("href")).show()}).on("click","a.woocommerce-review-link",function(){return a(".reviews_tab a").click(),!0}).on("init","#rating",function(){a("#rating").hide().before('<p class="stars"><span><a class="star-1" href="#">1</a><a class="star-2" href="#">2</a><a class="star-3" href="#">3</a><a class="star-4" href="#">4</a><a class="star-5" href="#">5</a></span></p>')}).on("click","#respond p.stars a",function(){var b=a(this),c=a(this).closest("#respond").find("#rating"),d=a(this).closest(".stars");return c.val(b.text()),b.siblings("a").removeClass("active"),b.addClass("active"),d.addClass("selected"),!1}).on("click","#respond #submit",function(){var b=a(this).closest("#respond").find("#rating"),c=b.val();if(b.length>0&&!c&&"yes"===wc_single_product_params.review_rating_required)return window.alert(wc_single_product_params.i18n_required_rating_text),!1}).on("woocommerce_init_gallery",function(){a.isFunction(a.fn.zoom)&&b.init_zoom()}),a(".wc-tabs-wrapper, .woocommerce-tabs, #rating").trigger("init");var b={init:function(){a.isFunction(a.fn.flexslider)&&this.init_flexslider(),a.isFunction(a.fn.zoom)&&this.init_zoom(),"undefined"!=typeof PhotoSwipe&&(this.init_photoswipe(),a(document).on("click",".woocommerce-product-gallery__trigger",this.trigger_photoswipe))},is_touch_device:function(){return"ontouchstart"in window||navigator.maxTouchPoints},init_flexslider:function(){a(".woocommerce-product-gallery").flexslider({selector:".woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image",animation:wc_single_product_params.flexslider.animation,smoothHeight:wc_single_product_params.flexslider.smoothHeight,directionNav:wc_single_product_params.flexslider.directionNav,controlNav:wc_single_product_params.flexslider.controlNav,slideshow:wc_single_product_params.flexslider.slideshow,animationSpeed:wc_single_product_params.flexslider.animationSpeed,animationLoop:!1})},init_zoom:function(){a(".woocommerce-product-gallery__image img").attr("width")>a(".woocommerce-product-gallery").width()&&(a(".woocommerce-product-gallery__image").trigger("zoom.destroy"),a(".woocommerce-product-gallery__image").zoom({touch:!1}))},get_gallery_items:function(){var b=a(".woocommerce-product-gallery__wrapper").children(),c=[],d=b.filter(".flex-active-slide").index();return b.length>0&&b.each(function(b,d){var e=a(d).find("img"),f=e.attr("data-large-image"),g=e.attr("data-large-image-width"),h=e.attr("data-large-image-height"),i={src:f,w:g,h:h,title:e.attr("title")};c.push(i)}),{index:d,items:c}},init_photoswipe:function(){a(".woocommerce-product-gallery").prepend('<a href="#" class="woocommerce-product-gallery__trigger">🔍</a>')},trigger_photoswipe:function(c){c.preventDefault();var d=a(".pswp")[0],e=b.get_gallery_items(),f={index:e.index,shareEl:!1,closeOnScroll:!1,history:!1,hideAnimationDuration:0,showAnimationDuration:0},g=new PhotoSwipe(d,PhotoSwipeUI_Default,e.items,f);g.init()}};b.init()});
jQuery(function(a){if("undefined"==typeof wc_single_product_params)return!1;a("body").on("init",".wc-tabs-wrapper, .woocommerce-tabs",function(){a(".wc-tab, .woocommerce-tabs .panel:not(.panel .panel)").hide();var b=window.location.hash,c=window.location.href,d=a(this).find(".wc-tabs, ul.tabs").first();b.toLowerCase().indexOf("comment-")>=0||"#reviews"===b||"#tab-reviews"===b?d.find("li.reviews_tab a").click():c.indexOf("comment-page-")>0||c.indexOf("cpage=")>0?d.find("li.reviews_tab a").click():d.find("li:first a").click()}).on("click",".wc-tabs li a, ul.tabs li a",function(b){b.preventDefault();var c=a(this),d=c.closest(".wc-tabs-wrapper, .woocommerce-tabs"),e=d.find(".wc-tabs, ul.tabs");e.find("li").removeClass("active"),d.find(".wc-tab, .panel:not(.panel .panel)").hide(),c.closest("li").addClass("active"),d.find(c.attr("href")).show()}).on("click","a.woocommerce-review-link",function(){return a(".reviews_tab a").click(),!0}).on("init","#rating",function(){a("#rating").hide().before('<p class="stars"><span><a class="star-1" href="#">1</a><a class="star-2" href="#">2</a><a class="star-3" href="#">3</a><a class="star-4" href="#">4</a><a class="star-5" href="#">5</a></span></p>')}).on("click","#respond p.stars a",function(){var b=a(this),c=a(this).closest("#respond").find("#rating"),d=a(this).closest(".stars");return c.val(b.text()),b.siblings("a").removeClass("active"),b.addClass("active"),d.addClass("selected"),!1}).on("click","#respond #submit",function(){var b=a(this).closest("#respond").find("#rating"),c=b.val();if(b.length>0&&!c&&"yes"===wc_single_product_params.review_rating_required)return window.alert(wc_single_product_params.i18n_required_rating_text),!1}).on("woocommerce_init_gallery",function(){a.isFunction(a.fn.zoom)&&wc_single_product_params.zoom_enabled&&b.init_zoom()}),a(".wc-tabs-wrapper, .woocommerce-tabs, #rating").trigger("init");var b={init:function(){a.isFunction(a.fn.flexslider)&&wc_single_product_params.flexslider_enabled&&this.init_flexslider(),a.isFunction(a.fn.zoom)&&wc_single_product_params.zoom_enabled&&this.init_zoom(),"undefined"!=typeof PhotoSwipe&&wc_single_product_params.photoswipe_enabled&&this.init_photoswipe()},init_flexslider:function(){a(".woocommerce-product-gallery").flexslider({selector:".woocommerce-product-gallery__wrapper > .woocommerce-product-gallery__image",animation:wc_single_product_params.flexslider.animation,smoothHeight:wc_single_product_params.flexslider.smoothHeight,directionNav:wc_single_product_params.flexslider.directionNav,controlNav:wc_single_product_params.flexslider.controlNav,slideshow:wc_single_product_params.flexslider.slideshow,animationSpeed:wc_single_product_params.flexslider.animationSpeed,animationLoop:wc_single_product_params.flexslider.animationLoop,start:function(){var b=a(".woocommerce-product-gallery__image"),c=0;b.each(function(){var b=a(this).height();b>c&&(c=b)}),b.each(function(){a(this).css("min-height",c)})}}),a("body").on("woocommerce_gallery_reset_slide_position",function(){a(".woocommerce-product-gallery").flexslider(0)})},init_zoom:function(){var b=a(".woocommerce-product-gallery__image"),c=!1;wc_single_product_params.flexslider_enabled||(b=b.first()),a(b).each(function(b,d){var e=a(d).find("img");if(e.attr("width")>a(".woocommerce-product-gallery").width())return c=!0,!1}),c&&(b.trigger("zoom.destroy"),b.zoom({touch:!1}))},get_gallery_items:function(){var b=a(".woocommerce-product-gallery__wrapper").children(),c=[],d=b.filter(".flex-active-slide").index();return b.length>0&&b.each(function(b,d){var e=a(d).find("img"),f=e.attr("data-large-image"),g=e.attr("data-large-image-width"),h=e.attr("data-large-image-height"),i={src:f,w:g,h:h,title:e.attr("title")};c.push(i)}),{index:d,items:c}},init_photoswipe:function(){wc_single_product_params.zoom_enabled&&(a(".woocommerce-product-gallery--with-images").prepend('<a href="#" class="woocommerce-product-gallery__trigger">🔍</a>'),a(document).on("click",".woocommerce-product-gallery__trigger",this.trigger_photoswipe)),a(document).on("click",".woocommerce-product-gallery__image a",this.trigger_photoswipe)},trigger_photoswipe:function(c){c.preventDefault();var d,e=a(".pswp")[0],f=b.get_gallery_items(),g=a(c.target);d=g.is(".woocommerce-product-gallery__trigger")?g.parents(".woocommerce-product-gallery").find(".flex-active-slide"):c.target.closest("figure");var h={index:a(d).index(),shareEl:!1,closeOnScroll:!1,history:!1,hideAnimationDuration:0,showAnimationDuration:0},i=new PhotoSwipe(e,PhotoSwipeUI_Default,f.items,h);i.init()}};b.init()});

0
assets/js/jquery-payment/jquery.payment.js Executable file → Normal file
View File

0
assets/js/jquery-payment/jquery.payment.min.js vendored Executable file → Normal file
View File

0
assets/js/photoswipe/photoswipe-ui-default.js Executable file → Normal file
View File

0
assets/js/photoswipe/photoswipe.js Executable file → Normal file
View File

0
assets/js/select2/select2.full.js vendored Executable file → Normal file
View File

0
assets/js/select2/select2.full.min.js vendored Executable file → Normal file
View File

0
assets/js/select2/select2.js vendored Executable file → Normal file
View File

0
assets/js/select2/select2.min.js vendored Executable file → Normal file
View File

42
assets/js/zoom/jquery.zoom.js Executable file → Normal file
View File

@ -1,5 +1,5 @@
/*!
Zoom 1.7.15
Zoom 1.7.18
license: MIT
http://www.jacklmoore.com/zoom
*/
@ -30,9 +30,8 @@
$source = $(source);
// The parent element needs positioning so that the zoomed element can be correctly positioned within.
$target.css('position', /(absolute|fixed)/.test(position) ? position : 'relative');
$target.css('overflow', 'hidden');
target.style.position = /(absolute|fixed)/.test(position) ? position : 'relative';
target.style.overflow = 'hidden';
img.style.width = img.style.height = '';
$(img)
@ -55,7 +54,7 @@
targetWidth = $target.outerWidth();
targetHeight = $target.outerHeight();
if (source === $target[0]) {
if (source === target) {
sourceWidth = targetWidth;
sourceHeight = targetHeight;
} else {
@ -86,41 +85,34 @@
var
settings = $.extend({}, defaults, options || {}),
//target will display the zoomed image
target = settings.target || this,
target = settings.target && $(settings.target)[0] || this,
//source will provide zoom location info (thumbnail)
source = this,
$source = $(source),
$target = $(target),
img = document.createElement('img'),
$img = $(img),
mousemove = 'mousemove.zoom',
clicked = false,
touched = false,
$urlElement;
touched = false;
// If a url wasn't specified, look for an image element.
if (!settings.url) {
$urlElement = $source.find('img');
if ($urlElement[0]) {
settings.url = $urlElement.data('src') || $urlElement.attr('src');
var srcElement = source.querySelector('img');
if (srcElement) {
settings.url = srcElement.getAttribute('data-src') || srcElement.currentSrc || srcElement.src;
}
if (!settings.url) {
return;
}
}
(function(){
var position = $target.css('position');
var overflow = $target.css('overflow');
$source.one('zoom.destroy', function(){
$source.off(".zoom");
$target.css('position', position);
$target.css('overflow', overflow);
$img.remove();
});
}());
$source.one('zoom.destroy', function(position, overflow){
$source.off(".zoom");
target.style.position = position;
target.style.overflow = overflow;
img.onload = null;
$img.remove();
}.bind(this, target.style.position, target.style.overflow));
img.onload = function () {
var zoom = $.zoom(target, source, img, settings.magnify);
@ -228,7 +220,7 @@
}
});
}
if ($.isFunction(settings.callback)) {
settings.callback.call(img);
}

4
assets/js/zoom/jquery.zoom.min.js vendored Executable file → Normal file
View File

@ -1,6 +1,6 @@
/*!
Zoom 1.7.15
Zoom 1.7.18
license: MIT
http://www.jacklmoore.com/zoom
*/
!function(a){var b={url:!1,callback:!1,target:!1,duration:120,on:"mouseover",touch:!0,onZoomIn:!1,onZoomOut:!1,magnify:1};a.zoom=function(b,c,d,e){var f,g,h,i,j,k,l,m=a(b),n=m.css("position"),o=a(c);return m.css("position",/(absolute|fixed)/.test(n)?n:"relative"),m.css("overflow","hidden"),d.style.width=d.style.height="",a(d).addClass("zoomImg").css({position:"absolute",top:0,left:0,opacity:0,width:d.width*e,height:d.height*e,border:"none",maxWidth:"none",maxHeight:"none"}).appendTo(b),{init:function(){g=m.outerWidth(),f=m.outerHeight(),c===m[0]?(i=g,h=f):(i=o.outerWidth(),h=o.outerHeight()),j=(d.width-g)/i,k=(d.height-f)/h,l=o.offset()},move:function(a){var b=a.pageX-l.left,c=a.pageY-l.top;c=Math.max(Math.min(c,h),0),b=Math.max(Math.min(b,i),0),d.style.left=b*-j+"px",d.style.top=c*-k+"px"}}},a.fn.zoom=function(c){return this.each(function(){var d,e=a.extend({},b,c||{}),f=e.target||this,g=this,h=a(g),i=a(f),j=document.createElement("img"),k=a(j),l="mousemove.zoom",m=!1,n=!1;(e.url||(d=h.find("img"),d[0]&&(e.url=d.data("src")||d.attr("src")),e.url))&&(!function(){var a=i.css("position"),b=i.css("overflow");h.one("zoom.destroy",function(){h.off(".zoom"),i.css("position",a),i.css("overflow",b),k.remove()})}(),j.onload=function(){function b(b){d.init(),d.move(b),k.stop().fadeTo(a.support.opacity?e.duration:0,1,!!a.isFunction(e.onZoomIn)&&e.onZoomIn.call(j))}function c(){k.stop().fadeTo(e.duration,0,!!a.isFunction(e.onZoomOut)&&e.onZoomOut.call(j))}var d=a.zoom(f,g,j,e.magnify);"grab"===e.on?h.on("mousedown.zoom",function(e){1===e.which&&(a(document).one("mouseup.zoom",function(){c(),a(document).off(l,d.move)}),b(e),a(document).on(l,d.move),e.preventDefault())}):"click"===e.on?h.on("click.zoom",function(e){return m?void 0:(m=!0,b(e),a(document).on(l,d.move),a(document).one("click.zoom",function(){c(),m=!1,a(document).off(l,d.move)}),!1)}):"toggle"===e.on?h.on("click.zoom",function(a){m?c():b(a),m=!m}):"mouseover"===e.on&&(d.init(),h.on("mouseenter.zoom",b).on("mouseleave.zoom",c).on(l,d.move)),e.touch&&h.on("touchstart.zoom",function(a){a.preventDefault(),n?(n=!1,c()):(n=!0,b(a.originalEvent.touches[0]||a.originalEvent.changedTouches[0]))}).on("touchmove.zoom",function(a){a.preventDefault(),d.move(a.originalEvent.touches[0]||a.originalEvent.changedTouches[0])}).on("touchend.zoom",function(a){a.preventDefault(),n&&(n=!1,c())}),a.isFunction(e.callback)&&e.callback.call(j)},j.src=e.url)})},a.fn.zoom.defaults=b}(window.jQuery);
!function(a){var b={url:!1,callback:!1,target:!1,duration:120,on:"mouseover",touch:!0,onZoomIn:!1,onZoomOut:!1,magnify:1};a.zoom=function(b,c,d,e){var f,g,h,i,j,k,l,m=a(b),n=m.css("position"),o=a(c);return b.style.position=/(absolute|fixed)/.test(n)?n:"relative",b.style.overflow="hidden",d.style.width=d.style.height="",a(d).addClass("zoomImg").css({position:"absolute",top:0,left:0,opacity:0,width:d.width*e,height:d.height*e,border:"none",maxWidth:"none",maxHeight:"none"}).appendTo(b),{init:function(){g=m.outerWidth(),f=m.outerHeight(),c===b?(i=g,h=f):(i=o.outerWidth(),h=o.outerHeight()),j=(d.width-g)/i,k=(d.height-f)/h,l=o.offset()},move:function(a){var b=a.pageX-l.left,c=a.pageY-l.top;c=Math.max(Math.min(c,h),0),b=Math.max(Math.min(b,i),0),d.style.left=b*-j+"px",d.style.top=c*-k+"px"}}},a.fn.zoom=function(c){return this.each(function(){var d=a.extend({},b,c||{}),e=d.target&&a(d.target)[0]||this,f=this,g=a(f),h=document.createElement("img"),i=a(h),j="mousemove.zoom",k=!1,l=!1;if(!d.url){var m=f.querySelector("img");if(m&&(d.url=m.getAttribute("data-src")||m.currentSrc||m.src),!d.url)return}g.one("zoom.destroy",function(a,b){g.off(".zoom"),e.style.position=a,e.style.overflow=b,h.onload=null,i.remove()}.bind(this,e.style.position,e.style.overflow)),h.onload=function(){function b(b){m.init(),m.move(b),i.stop().fadeTo(a.support.opacity?d.duration:0,1,!!a.isFunction(d.onZoomIn)&&d.onZoomIn.call(h))}function c(){i.stop().fadeTo(d.duration,0,!!a.isFunction(d.onZoomOut)&&d.onZoomOut.call(h))}var m=a.zoom(e,f,h,d.magnify);"grab"===d.on?g.on("mousedown.zoom",function(d){1===d.which&&(a(document).one("mouseup.zoom",function(){c(),a(document).off(j,m.move)}),b(d),a(document).on(j,m.move),d.preventDefault())}):"click"===d.on?g.on("click.zoom",function(d){return k?void 0:(k=!0,b(d),a(document).on(j,m.move),a(document).one("click.zoom",function(){c(),k=!1,a(document).off(j,m.move)}),!1)}):"toggle"===d.on?g.on("click.zoom",function(a){k?c():b(a),k=!k}):"mouseover"===d.on&&(m.init(),g.on("mouseenter.zoom",b).on("mouseleave.zoom",c).on(j,m.move)),d.touch&&g.on("touchstart.zoom",function(a){a.preventDefault(),l?(l=!1,c()):(l=!0,b(a.originalEvent.touches[0]||a.originalEvent.changedTouches[0]))}).on("touchmove.zoom",function(a){a.preventDefault(),m.move(a.originalEvent.touches[0]||a.originalEvent.changedTouches[0])}).on("touchend.zoom",function(a){a.preventDefault(),l&&(l=!1,c())}),a.isFunction(d.callback)&&d.callback.call(h)},h.src=d.url})},a.fn.zoom.defaults=b}(window.jQuery);

View File

@ -5,7 +5,7 @@
"type": "wordpress-plugin",
"license": "GPL-2.0+",
"require": {
"composer/installers": "~1.0"
"composer/installers": "~1.2"
},
"require-dev": {
"squizlabs/php_codesniffer": "*",

View File

@ -121,7 +121,7 @@ return array(
'ID' => __( 'Indonesia', 'woocommerce' ),
'IR' => __( 'Iran', 'woocommerce' ),
'IQ' => __( 'Iraq', 'woocommerce' ),
'IE' => __( 'Republic of Ireland', 'woocommerce' ),
'IE' => __( 'Ireland', 'woocommerce' ),
'IM' => __( 'Isle of Man', 'woocommerce' ),
'IL' => __( 'Israel', 'woocommerce' ),
'IT' => __( 'Italy', 'woocommerce' ),

File diff suppressed because it is too large Load Diff

View File

@ -254,6 +254,26 @@ return array(
),
),
),
'FI' => array(
'currency_code' => 'EUR',
'currency_pos' => 'right_space',
'thousand_sep' => ' ',
'decimal_sep' => ',',
'num_decimals' => 2,
'weight_unit' => 'kg',
'dimension_unit' => 'cm',
'tax_rates' => array(
'' => array(
array(
'country' => 'FI',
'state' => '',
'rate' => '24.0000',
'name' => 'ALV',
'shipping' => true,
),
),
),
),
'FR' => array(
'currency_code' => 'EUR',
'currency_pos' => 'right',
@ -434,6 +454,26 @@ return array(
),
),
),
'RO' => array(
'currency_code' => 'RON',
'currency_pos' => 'right_space',
'thousand_sep' => '.',
'decimal_sep' => ',',
'num_decimals' => 2,
'weight_unit' => 'kg',
'dimension_unit' => 'cm',
'tax_rates' => array(
'' => array(
array(
'country' => 'RO',
'state' => '',
'rate' => '19.0000',
'name' => 'TVA',
'shipping' => true,
),
),
),
),
'TH' => array(
'currency_code' => 'THB',
'currency_pos' => 'left',

21
i18n/states/PK.php Normal file
View File

@ -0,0 +1,21 @@
<?php
/**
* Pakistan's states
*
* @author WooCommerce
* @category i18n
* @package WooCommerce/i18n
* @version 2.7.0
*/
global $states;
$states['PK'] = array(
'JK' => __( 'Azad Kashmir', 'woocommerce' ),
'BA' => __( 'Balochistan', 'woocommerce' ),
'TA' => __( 'FATA', 'woocommerce' ),
'GB' => __( 'Gilgit Baltistan', 'woocommerce' ),
'IS' => __( 'Islamabad Capital Territory', 'woocommerce' ),
'KP' => __( 'Khyber Pakhtunkhwa', 'woocommerce' ),
'PB' => __( 'Punjab', 'woocommerce' ),
'SD' => __( 'Sindh', 'woocommerce' ),
);

View File

@ -17,30 +17,40 @@ abstract class WC_Data {
/**
* ID for this object.
*
* @since 2.7.0
* @var int
*/
protected $id = 0;
/**
* Core data for this object. Name value pairs (name + default value).
*
* @since 2.7.0
* @var array
*/
protected $data = array();
/**
* Core data changes for this object.
*
* @since 2.7.0
* @var array
*/
protected $changes = array();
/**
* This is false until the object is read from the DB.
*
* @since 2.7.0
* @var bool
*/
protected $object_read = false;
/**
* This is the name of this object type.
*
* @since 2.7.0
* @var string
*/
protected $object_type = 'data';
@ -49,18 +59,24 @@ abstract class WC_Data {
* Extra data for this object. Name value pairs (name + default value).
* Used as a standard way for sub classes (like product types) to add
* additional information to an inherited class.
*
* @since 2.7.0
* @var array
*/
protected $extra_data = array();
/**
* Set to _data on construct so we can track and reset data if needed.
*
* @since 2.7.0
* @var array
*/
protected $default_data = array();
/**
* Contains a reference to the data store for this class.
*
* @since 2.7.0
* @var object
*/
protected $data_store;
@ -68,28 +84,36 @@ abstract class WC_Data {
/**
* Stores meta in cache for future reads.
* A group must be set to to enable caching.
*
* @since 2.7.0
* @var string
*/
protected $cache_group = '';
/**
* Stores additonal meta data.
*
* @since 2.7.0
* @var array
*/
protected $meta_data = null;
/**
* Default constructor.
*
* @param int|object|array $read ID to load from the DB (optional) or already queried data.
*/
public function __construct( $read = 0 ) {
$this->data = array_merge( $this->data, $this->extra_data );
$this->default_data = $this->data;
}
/**
* Get the data store.
*
* @since 2.7.0
* @since 2.7.0
* @return object
*/
public function get_data_store() {
@ -98,6 +122,8 @@ abstract class WC_Data {
/**
* Returns the unique ID for this object.
*
* @since 2.6.0
* @return int
*/
public function get_id() {
@ -107,6 +133,7 @@ abstract class WC_Data {
/**
* Delete an object, set the ID to 0, and return result.
*
* @since 2.6.0
* @param bool $force_delete
* @return bool result
*/
@ -122,6 +149,7 @@ abstract class WC_Data {
/**
* Save should create or update based on object existance.
*
* @since 2.6.0
* @return int
*/
public function save() {
@ -140,6 +168,8 @@ abstract class WC_Data {
/**
* Change data to JSON format.
*
* @since 2.6.0
* @return string Data in JSON format.
*/
public function __toString() {
@ -148,6 +178,8 @@ abstract class WC_Data {
/**
* Returns all data for this object.
*
* @since 2.6.0
* @return array
*/
public function get_data() {
@ -157,7 +189,7 @@ abstract class WC_Data {
/**
* Returns array of expected data keys for this object.
*
* @since 2.7.0
* @since 2.7.0
* @return array
*/
public function get_data_keys() {
@ -167,7 +199,7 @@ abstract class WC_Data {
/**
* Returns all "extra" data keys for an object (for sub objects like product types).
*
* @since 2.7.0
* @since 2.7.0
* @return array
*/
public function get_extra_data_keys() {
@ -176,6 +208,8 @@ abstract class WC_Data {
/**
* Filter null meta values from array.
*
* @since 2.7.0
* @return bool
*/
protected function filter_null_meta( $meta ) {
@ -184,6 +218,7 @@ abstract class WC_Data {
/**
* Get All Meta Data.
*
* @since 2.6.0
* @return array
*/
@ -194,6 +229,7 @@ abstract class WC_Data {
/**
* Get Meta Data by Key.
*
* @since 2.6.0
* @param string $key
* @param bool $single return first found meta with key, or all with $key
@ -203,7 +239,7 @@ abstract class WC_Data {
public function get_meta( $key = '', $single = true, $context = 'view' ) {
$this->maybe_read_meta_data();
$array_keys = array_keys( wp_list_pluck( $this->get_meta_data(), 'key' ), $key );
$value = '';
$value = $single ? '' : array();
if ( ! empty( $array_keys ) ) {
if ( $single ) {
@ -222,6 +258,7 @@ abstract class WC_Data {
/**
* Set all meta data from array.
*
* @since 2.6.0
* @param array $data Key/Value pairs
*/
@ -243,6 +280,7 @@ abstract class WC_Data {
/**
* Add meta data.
*
* @since 2.6.0
* @param string $key Meta key
* @param string $value Meta value
@ -261,7 +299,8 @@ abstract class WC_Data {
/**
* Update meta data by key or ID, if provided.
* @since 2.6.0
*
* @since 2.6.0
* @param string $key
* @param string $value
* @param int $meta_id
@ -281,6 +320,7 @@ abstract class WC_Data {
/**
* Delete meta data.
*
* @since 2.6.0
* @param array $key Meta key
*/
@ -295,6 +335,7 @@ abstract class WC_Data {
/**
* Delete meta data.
*
* @since 2.6.0
* @param int $mid Meta ID
*/
@ -371,6 +412,7 @@ abstract class WC_Data {
/**
* Update Meta Data in the database.
*
* @since 2.6.0
*/
public function save_meta_data() {
@ -381,6 +423,7 @@ abstract class WC_Data {
if ( is_null( $meta->value ) ) {
if ( ! empty( $meta->id ) ) {
$this->data_store->delete_meta( $this, $meta );
unset( $this->meta_data[ $array_key ] );
}
} elseif ( empty( $meta->id ) ) {
$new_meta_id = $this->data_store->add_meta( $this, $meta );
@ -392,13 +435,14 @@ abstract class WC_Data {
if ( ! empty( $this->cache_group ) ) {
WC_Cache_Helper::incr_cache_prefix( $this->cache_group );
wp_cache_delete( 'object-' . $this->get_id(), $this->cache_group );
}
$this->read_meta_data( true );
}
/**
* Set ID.
*
* @since 2.7.0
* @param int $id
*/
public function set_id( $id ) {
@ -407,6 +451,8 @@ abstract class WC_Data {
/**
* Set all props to default values.
*
* @since 2.7.0
*/
public function set_defaults() {
$this->data = $this->default_data;
@ -416,6 +462,8 @@ abstract class WC_Data {
/**
* Set object read property.
*
* @since 2.7.0
* @param boolean $read
*/
public function set_object_read( $read = true ) {
@ -424,6 +472,8 @@ abstract class WC_Data {
/**
* Get object read property.
*
* @since 2.7.0
* @return boolean
*/
public function get_object_read() {
@ -434,7 +484,8 @@ abstract class WC_Data {
* Set a collection of props in one go, collect any errors, and return the result.
* Only sets using public methods.
*
* @param array $props Key value pairs to set. Key is the prop and should map to a setter function name.
* @since 2.7.0
* @param array $props Key value pairs to set. Key is the prop and should map to a setter function name.
* @return WP_Error|bool
*/
public function set_props( $props, $context = 'set' ) {
@ -499,7 +550,7 @@ abstract class WC_Data {
* @since 2.7.0
*/
public function apply_changes() {
$this->data = array_merge( $this->data, $this->changes );
$this->data = array_replace_recursive( $this->data, $this->changes );
$this->changes = array();
}
@ -510,7 +561,7 @@ abstract class WC_Data {
* @return string
*/
protected function get_hook_prefix() {
return 'woocommerce_get_' . $this->object_type . '_';
return 'woocommerce_' . $this->object_type . '_get_';
}
/**
@ -539,11 +590,15 @@ abstract class WC_Data {
/**
* When invalid data is found, throw an exception unless reading from the DB.
* @param string $error_code Error code.
* @param string $error_message Error message.
*
* @throws WC_Data_Exception
* @since 2.7.0
* @param string $code Error code.
* @param string $message Error message.
* @param int $http_status_code HTTP status code.
* @param array $data Extra error data.
*/
protected function error( $error_code, $error_message ) {
throw new WC_Data_Exception( $error_code, $error_message );
protected function error( $code, $message, $http_status_code = 400, $data = array() ) {
throw new WC_Data_Exception( $code, $message, $http_status_code, $data );
}
}

View File

@ -0,0 +1,92 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* WC_Deprecated_Hooks class maps old actions and filters to new ones. This is the base class for handling those deprecated hooks.
*
* Based on the WCS_Hook_Deprecator class by Prospress.
*
* @since 2.7.0
*/
abstract class WC_Deprecated_Hooks {
/**
* Array of deprecated hooks we need to handle.
*
* @var array
*/
protected $deprecated_hooks = array();
/**
* Constructor.
*/
public function __construct() {
$new_hooks = array_keys( $this->deprecated_hooks );
array_walk( $new_hooks, array( $this, 'hook_in' ) );
}
/**
* Hook into the new hook so we can handle deprecated hooks once fired.
*
* @param string $hook_name
*/
abstract function hook_in( $hook_name );
/**
* Get old hooks to map to new hook.
*
* @param string $new_hook
* @return array
*/
public function get_old_hooks( $new_hook ) {
$old_hooks = isset( $this->deprecated_hooks[ $new_hook ] ) ? $this->deprecated_hooks[ $new_hook ] : array();
$old_hooks = is_array( $old_hooks ) ? $old_hooks : array( $old_hooks );
return $old_hooks;
}
/**
* If the hook is Deprecated, call the old hooks here.
*/
public function maybe_handle_deprecated_hook() {
$new_hook = current_filter();
$old_hooks = $this->get_old_hooks( $new_hook );
$new_callback_args = func_get_args();
$return_value = $new_callback_args[0];
foreach ( $old_hooks as $old_hook ) {
$return_value = $this->handle_deprecated_hook( $new_hook, $old_hook, $new_callback_args, $return_value );
}
return $return_value;
}
/**
* If the old hook is in-use, trigger it.
*
* @param string $new_hook
* @param string $old_hook
* @param array $new_callback_args
* @param mixed $return_value
* @return mixed
*/
abstract function handle_deprecated_hook( $new_hook, $old_hook, $new_callback_args, $return_value );
/**
* Display a deprecated notice for old hooks.
*/
protected function display_notice( $old_hook, $new_hook ) {
_deprecated_function( sprintf( 'The "%s" hook uses out of date data structures and', esc_html( $old_hook ) ), WC_VERSION, esc_html( $new_hook ) );
}
/**
* Fire off a legacy hook with it's args.
*
* @param string $old_hook
* @param array $new_callback_args
* @return mixed
*/
abstract protected function trigger_hook( $old_hook, $new_callback_args );
}

View File

@ -0,0 +1,48 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* Abstract WC Log Handler Class
*
* @version 1.0.0
* @package WooCommerce/Abstracts
* @category Abstract Class
* @author WooThemes
*/
abstract class WC_Log_Handler implements WC_Log_Handler_Interface {
/**
* Formats a timestamp for use in log messages.
*
* @param int $timestamp Log timestamp.
* @return string Formatted time for use in log entry.
*/
protected static function format_time( $timestamp ) {
return date( 'c', $timestamp );
}
/**
* Builds a log entry text from level, timestamp and message.
*
* @param int $timestamp Log timestamp.
* @param string $level emergency|alert|critical|error|warning|notice|info|debug
* @param string $message Log message.
* @param array $context Additional information for log handlers.
*
* @return string Formatted log entry.
*/
protected static function format_entry( $timestamp, $level, $message, $context ) {
$time_string = self::format_time( $timestamp );
$level_string = strtoupper( $level );
$entry = "{$time_string} {$level_string} {$message}";
return apply_filters( 'woocommerce_format_log_entry', $entry, array(
'timestamp' => $timestamp,
'level' => $level,
'message' => $message,
'context' => $context,
) );
}
}

View File

@ -3,7 +3,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
include_once( 'abstract-wc-legacy-order.php' );
include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-order.php' );
/**
* Abstract Order
@ -51,13 +51,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
* @since 2.7.0
* @var array
*/
protected $items = array(
'line_items' => null,
'coupon_lines' => null,
'shipping_lines' => null,
'fee_lines' => null,
'tax_lines' => null,
);
protected $items = array();
/**
* Order items that need deleting are stored here.
@ -73,7 +67,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
* A group must be set to to enable caching.
* @var string
*/
protected $cache_group = 'order';
protected $cache_group = 'orders';
/**
* Which data store to load.
@ -109,11 +103,6 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
$this->set_object_read( true );
}
// Set default status if none were read.
if ( ! $this->get_status() ) {
$this->set_status( apply_filters( 'woocommerce_default_order_status', 'pending' ) );
}
$this->data_store = WC_Data_Store::load( $this->data_store_name );
if ( $this->get_id() > 0 ) {
@ -197,7 +186,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
}
$this->items_to_delete = array();
// Add/save items
// Add/save items.
foreach ( $this->items as $item_group => $items ) {
if ( is_array( $items ) ) {
foreach ( $items as $item_key => $item ) {
@ -207,26 +196,8 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
// If ID changed (new item saved to DB)...
if ( $item_id !== $item_key ) {
$this->items[ $item_group ][ $item_id ] = $item;
unset( $this->items[ $item_group ][ $item_key ] );
// Legacy action handler
switch ( $item_group ) {
case 'fee_lines' :
if ( isset( $item->legacy_fee, $item->legacy_fee_key ) ) {
wc_do_deprecated_action( 'woocommerce_add_order_fee_meta', array( $this->get_id(), $item_id, $item->legacy_fee, $item->legacy_fee_key ), '2.7', 'Use CRUD and woocommerce_checkout_create_order_fee_item action instead.' );
}
break;
case 'shipping_lines' :
if ( isset( $item->legacy_package_key ) ) {
wc_do_deprecated_action( 'woocommerce_add_shipping_order_item', array( $this->get_id(), $item_id, $item->legacy_package_key ), '2.7', 'Use CRUD woocommerce_checkout_create_order_shipping_item action instead.' );
}
break;
case 'line_items' :
if ( isset( $item->legacy_values, $item->legacy_cart_item_key ) ) {
wc_do_deprecated_action( 'woocommerce_add_order_item_meta', array( $item_id, $item->legacy_values, $item->legacy_cart_item_key ), '2.7', 'Use CRUD and woocommerce_checkout_create_order_line_item action instead.' );
}
break;
}
unset( $this->items[ $item_group ][ $item_key ] );
}
}
}
@ -307,7 +278,13 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
* @return string
*/
public function get_status( $context = 'view' ) {
return $this->get_prop( 'status', $context );
$status = $this->get_prop( 'status', $context );
if ( empty( $status ) && 'view' === $context ) {
// In view context, return the default status if no status has been set.
$status = apply_filters( 'woocommerce_default_order_status', 'pending' );
}
return $status;
}
/**
@ -447,6 +424,16 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
return apply_filters( 'woocommerce_order_get_tax_totals', $tax_totals, $this );
}
/**
* Get all valid statuses for this order
*
* @since 2.7.0
* @return array Internal status keys e.g. 'wc-processing'
*/
protected function get_valid_statuses() {
return array_keys( wc_get_order_statuses() );
}
/*
|--------------------------------------------------------------------------
| Setters
@ -466,7 +453,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
* @throws WC_Data_Exception
*/
public function set_parent_id( $value ) {
if ( $value && ! get_post( $value ) ) {
if ( $value && ! wc_get_order( $value ) ) {
$this->error( 'order_invalid_parent_id', __( 'Invalid parent ID', 'woocommerce' ) );
}
$this->set_prop( 'parent_id', absint( $value ) );
@ -479,19 +466,19 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
* @param string $new_status Status to change the order to. No internal wc- prefix is required.
* @return array details of change
*/
public function set_status( $new_status ) {
public function set_status( $new_status ) {
$old_status = $this->get_status();
$new_status = 'wc-' === substr( $new_status, 0, 3 ) ? substr( $new_status, 3 ) : $new_status;
// Only allow valid new status
if ( ! in_array( 'wc-' . $new_status, array_keys( wc_get_order_statuses() ) ) ) {
if ( ! in_array( 'wc-' . $new_status, $this->get_valid_statuses() ) && 'trash' !== $new_status ) {
$new_status = 'pending';
}
$this->set_prop( 'status', $new_status );
// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
if ( $old_status && ! in_array( 'wc-' . $old_status, array_keys( wc_get_order_statuses() ) ) ) {
if ( $old_status && ! in_array( 'wc-' . $old_status, $this->get_valid_statuses() ) && 'trash' !== $old_status ) {
$old_status = 'pending';
}
@ -499,7 +486,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
'from' => $old_status,
'to' => $new_status,
);
}
}
/**
* Set order_version.
@ -642,6 +629,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
/**
* Remove all line items (products, coupons, shipping, taxes) from the order.
*
* @param string $type Order item type. Default null.
*/
public function remove_order_items( $type = null ) {
@ -649,22 +637,17 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
$this->data_store->delete_items( $this, $type );
if ( $group = $this->type_to_group( $type ) ) {
$this->items[ $group ] = null;
unset( $this->items[ $group ] );
}
} else {
$this->data_store->delete_items( $this );
$this->items = array(
'line_items' => null,
'coupon_lines' => null,
'shipping_lines' => null,
'fee_lines' => null,
'tax_lines' => null,
);
$this->items = array();
}
}
/**
* Convert a type to a types group.
*
* @param string $type
* @return string group
*/
@ -681,6 +664,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
/**
* Return an array of items/products within this order.
*
* @param string|array $types Types of line items to get (array or string).
* @return Array of WC_Order_item
*/
@ -690,7 +674,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
foreach ( $types as $type ) {
if ( $group = $this->type_to_group( $type ) ) {
if ( is_null( $this->items[ $group ] ) ) {
if ( ! isset( $this->items[ $group ] ) ) {
$this->items[ $group ] = $this->data_store->read_items( $this, $type );
}
// Don't use array_merge here because keys are numeric
@ -703,6 +687,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
/**
* Return an array of fees within this order.
*
* @return array
*/
public function get_fees() {
@ -711,6 +696,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
/**
* Return an array of taxes within this order.
*
* @return array
*/
public function get_taxes() {
@ -719,6 +705,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
/**
* Return an array of shipping costs within this order.
*
* @return array
*/
public function get_shipping_methods() {
@ -727,6 +714,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
/**
* Gets formatted shipping method title.
*
* @return string
*/
public function get_shipping_method() {
@ -739,6 +727,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
/**
* Get coupon codes only.
*
* @return array
*/
public function get_used_coupons() {
@ -770,6 +759,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
/**
* Get an order item object, based on it's type.
*
* @since 2.7.0
* @param int $item_id
* @return WC_Order_Item
@ -780,6 +770,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
/**
* Get key for where a certain item type is stored in _items.
*
* @since 2.7.0
* @param $item object Order item (product, shipping, fee, coupon, tax)
* @return string
@ -802,6 +793,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
/**
* Remove item from the order.
*
* @param int $item_id
*/
public function remove_item( $item_id ) {
@ -818,6 +810,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
/**
* Adds an order item to this order. The order item will not persist until save.
*
* @since 2.7.0
* @param WC_Order_Item Order item object (product, shipping, fee, coupon, tax)
*/
@ -827,7 +820,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
}
// Make sure existing items are loaded so we can append this new one.
if ( is_null( $this->items[ $items_key ] ) ) {
if ( ! isset( $this->items[ $items_key ] ) ) {
$this->items[ $items_key ] = $this->get_items( $item->get_type() );
}
@ -835,8 +828,8 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
$item->set_order_id( $this->get_id() );
// Append new row with generated temporary ID
if ( $item->get_id() ) {
$this->items[ $items_key ][ $item->get_id() ] = $item;
if ( $item_id = $item->get_id() ) {
$this->items[ $items_key ][ $item_id ] = $item;
} else {
$this->items[ $items_key ][ 'new:' . sizeof( $this->items[ $items_key ] ) ] = $item;
}
@ -845,6 +838,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
/**
* Add a product line item to the order. This is the only line item type with
* it's own method because it saves looking up order amounts (costs are added up for you).
*
* @param \WC_Product $product
* @param int $qty
* @param array $args
@ -890,7 +884,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
$item->set_order_id( $this->get_id() );
$item->save();
$this->add_item( $item );
wc_do_deprecated_action( 'woocommerce_order_add_product', array( $this->get_id(), $item->get_id(), $product, $qty, $args ), '2.7', 'Use woocommerce_new_order_item action instead.' );
wc_do_deprecated_action( 'woocommerce_order_add_product', array( $this->get_id(), $item->get_id(), $product, $qty, $args ), '2.7', 'woocommerce_new_order_item action instead' );
return $item->get_id();
}
@ -1038,11 +1032,10 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
// Inherit tax class from items
if ( 'inherit' === $shipping_tax_class ) {
$tax_rates = array();
$tax_classes = array_merge( array( '' ), WC_Tax::get_tax_classes() );
$tax_classes = array_merge( array( '' ), WC_Tax::get_tax_class_slugs() );
$found_tax_classes = $this->get_items_tax_classes();
foreach ( $tax_classes as $tax_class ) {
$tax_class = sanitize_title( $tax_class );
if ( in_array( $tax_class, $found_tax_classes ) ) {
$tax_rates = WC_Tax::find_shipping_rates( array(
'country' => $args['country'],
@ -1076,6 +1069,8 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
public function update_taxes() {
$cart_taxes = array();
$shipping_taxes = array();
$existing_taxes = $this->get_taxes();
$saved_rate_ids = array();
foreach ( $this->get_items( array( 'line_item', 'fee' ) ) as $item_id => $item ) {
$taxes = $item->get_taxes();
@ -1091,15 +1086,26 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
}
}
// Remove old existing tax rows.
$this->remove_order_items( 'tax' );
foreach ( $existing_taxes as $tax ) {
// Remove taxes which no longer exist for cart/shipping.
if ( ( ! array_key_exists( $tax->get_rate_id(), $cart_taxes ) && ! array_key_exists( $tax->get_rate_id(), $shipping_taxes ) ) || in_array( $tax->get_rate_id(), $saved_rate_ids ) ) {
$this->remove_item( $tax->get_id() );
continue;
}
$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_shipping_tax_total( ! empty( $shipping_taxes[ $tax->get_rate_id() ] ) ? $shipping_taxes[ $tax->get_rate_id() ] : 0 );
$tax->save();
}
// Now merge to keep tax rows.
foreach ( array_keys( $cart_taxes + $shipping_taxes ) as $tax_rate_id ) {
$new_rate_ids = wp_parse_id_list( array_diff( array_keys( $cart_taxes + $shipping_taxes ), $saved_rate_ids ) );
// New taxes.
foreach ( $new_rate_ids as $tax_rate_id ) {
$item = new WC_Order_Item_Tax();
$item->set_rate( $tax_rate_id );
$item->set_tax_total( isset( $cart_taxes[ $tax_rate_id ] ) ? $cart_taxes[ $tax_rate_id ] : 0 );
$item->set_shipping_tax_total( isset( $shipping_taxes[ $tax_rate_id ] ) ? $shipping_taxes[ $tax_rate_id ] : 0 );
$item->set_shipping_tax_total( ! empty( $shipping_taxes[ $tax_rate_id ] ) ? $shipping_taxes[ $tax_rate_id ] : 0 );
$this->add_item( $item );
}
@ -1407,36 +1413,57 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
}
/**
* Get totals for display on pages and in emails.
* Add total row for subtotal.
*
* @param mixed $tax_display
* @return array
* @param array $total_rows
* @param string $tax_display
*/
public function get_order_item_totals( $tax_display = '' ) {
$tax_display = $tax_display ? $tax_display : get_option( 'woocommerce_tax_display_cart' );
$total_rows = array();
protected function add_order_item_totals_subtotal_row( &$total_rows, $tax_display ) {
if ( $subtotal = $this->get_subtotal_to_display( false, $tax_display ) ) {
$total_rows['cart_subtotal'] = array(
'label' => __( 'Subtotal:', 'woocommerce' ),
'value' => $subtotal,
);
}
}
/**
* Add total row for discounts.
*
* @param array $total_rows
* @param string $tax_display
*/
protected function add_order_item_totals_discount_row( &$total_rows, $tax_display ) {
if ( $this->get_total_discount() > 0 ) {
$total_rows['discount'] = array(
'label' => __( 'Discount:', 'woocommerce' ),
'value' => '-' . $this->get_discount_to_display( $tax_display ),
);
}
}
/**
* Add total row for shipping.
*
* @param array $total_rows
* @param string $tax_display
*/
protected function add_order_item_totals_shipping_row( &$total_rows, $tax_display ) {
if ( $this->get_shipping_method() ) {
$total_rows['shipping'] = array(
'label' => __( 'Shipping:', 'woocommerce' ),
'value' => $this->get_shipping_to_display( $tax_display ),
);
}
}
/**
* Add total row for fees.
*
* @param array $total_rows
* @param string $tax_display
*/
protected function add_order_item_totals_fee_rows( &$total_rows, $tax_display ) {
if ( $fees = $this->get_fees() ) {
foreach ( $fees as $id => $fee ) {
if ( apply_filters( 'woocommerce_get_order_item_totals_excl_free_fees', empty( $fee['line_total'] ) && empty( $fee['line_tax'] ), $id ) ) {
@ -1448,50 +1475,64 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
);
}
}
}
/**
* Add total row for taxes.
*
* @param array $total_rows
* @param string $tax_display
*/
protected function add_order_item_totals_tax_rows( &$total_rows, $tax_display ) {
// Tax for tax exclusive prices.
if ( 'excl' === $tax_display ) {
if ( get_option( 'woocommerce_tax_total_display' ) == 'itemized' ) {
if ( 'itemized' === get_option( 'woocommerce_tax_total_display' ) ) {
foreach ( $this->get_tax_totals() as $code => $tax ) {
$total_rows[ sanitize_title( $code ) ] = array(
'label' => $tax->label . ':',
'value' => $tax->formatted_amount,
);
}
} else {
$total_rows['tax'] = array(
'label' => WC()->countries->tax_or_vat() . ':',
'value' => wc_price( $this->get_total_tax(), array( 'currency' => $this->get_currency() ) ),
);
}
}
}
if ( $this->get_total() > 0 && $this->get_payment_method_title() ) {
$total_rows['payment_method'] = array(
'label' => __( 'Payment method:', 'woocommerce' ),
'value' => $this->get_payment_method_title(),
);
}
if ( $refunds = $this->get_refunds() ) {
foreach ( $refunds as $id => $refund ) {
$total_rows[ 'refund_' . $id ] = array(
'label' => $refund->get_reason() ? $refund->get_reason() : __( 'Refund', 'woocommerce' ) . ':',
'value' => wc_price( '-' . $refund->get_amount(), array( 'currency' => $this->get_currency() ) ),
);
}
}
/**
* Add total row for grand total.
*
* @param array $total_rows
* @param string $tax_display
*/
protected function add_order_item_totals_total_row( &$total_rows, $tax_display ) {
$total_rows['order_total'] = array(
'label' => __( 'Total:', 'woocommerce' ),
'value' => $this->get_formatted_order_total( $tax_display ),
);
}
return apply_filters( 'woocommerce_get_order_item_totals', $total_rows, $this );
/**
* Get totals for display on pages and in emails.
*
* @param mixed $tax_display
* @return array
*/
public function get_order_item_totals( $tax_display = '' ) {
$tax_display = $tax_display ? $tax_display : get_option( 'woocommerce_tax_display_cart' );
$total_rows = array();
$this->add_order_item_totals_subtotal_row( $total_rows, $tax_display );
$this->add_order_item_totals_discount_row( $total_rows, $tax_display );
$this->add_order_item_totals_shipping_row( $total_rows, $tax_display );
$this->add_order_item_totals_fee_rows( $total_rows, $tax_display );
$this->add_order_item_totals_tax_rows( $total_rows, $tax_display );
$this->add_order_item_totals_total_row( $total_rows, $tax_display );
return apply_filters( 'woocommerce_get_order_item_totals', $total_rows, $this, $tax_display );
}
/*

View File

@ -1,10 +1,10 @@
<?php
include_once( 'abstract-wc-legacy-payment-token.php' );
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-payment-token.php' );
/**
* WooCommerce Payment Token.
*

View File

@ -7,7 +7,7 @@ if ( ! defined( 'ABSPATH' ) ) {
* Legacy product contains all deprecated methods for this class and can be
* removed in the future.
*/
include_once( 'abstract-wc-legacy-product.php' );
include_once( WC_ABSPATH . 'includes/legacy/abstract-wc-legacy-product.php' );
/**
* Abstract Product Class
@ -129,12 +129,14 @@ class WC_Product extends WC_Abstract_Legacy_Product {
/**
* Get internal type. Should return string and *should be overridden* by child classes.
*
* The product_type property is @deprecated but is used here for BW compat with child classes which may be defining product_type and not have a get_type method.
*
* @since 2.7.0
* @return string
*/
public function get_type() {
// product_type is @deprecated but here for BW compat with child classes.
return $this->product_type;
return isset( $this->product_type ) ? $this->product_type : 'simple';
}
/*
@ -145,23 +147,6 @@ class WC_Product extends WC_Abstract_Legacy_Product {
| Methods for getting data from the product object.
*/
/**
* Get all class data in array format.
* @since 2.7.0
* @return array
*/
public function get_data() {
return array_merge(
array(
'id' => $this->get_id(),
),
$this->data,
array(
'meta_data' => $this->get_meta_data(),
)
);
}
/**
* Get product name.
*
@ -804,7 +789,9 @@ class WC_Product extends WC_Abstract_Legacy_Product {
public function set_sku( $sku ) {
$sku = (string) $sku;
if ( $this->get_object_read() && ! empty( $sku ) && ! wc_product_has_unique_sku( $this->get_id(), $sku ) ) {
$this->error( 'product_invalid_sku', __( 'Invalid or duplicated SKU.', 'woocommerce' ) );
$sku_found = wc_get_product_id_by_sku( $sku );
$this->error( 'product_invalid_sku', __( 'Invalid or duplicated SKU.', 'woocommerce' ), 400, array( 'resource_id' => $sku_found ) );
}
$this->set_prop( 'sku', $sku );
}
@ -901,7 +888,9 @@ class WC_Product extends WC_Abstract_Legacy_Product {
* @param string $class Tax class.
*/
public function set_tax_class( $class ) {
$this->set_prop( 'tax_class', wc_clean( $class ) );
$class = sanitize_title( $class );
$class = 'standard' === $class ? '' : $class;
$this->set_prop( 'tax_class', $class );
}
/**
@ -1097,7 +1086,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
* @param array $term_ids List of terms IDs.
*/
public function set_category_ids( $term_ids ) {
$this->set_prop( 'category_ids', $this->sanitize_term_ids( $term_ids, 'product_cat' ) );
$this->set_prop( 'category_ids', array_unique( array_map( 'intval', $term_ids ) ) );
}
/**
@ -1107,7 +1096,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
* @param array $term_ids List of terms IDs.
*/
public function set_tag_ids( $term_ids ) {
$this->set_prop( 'tag_ids', $this->sanitize_term_ids( $term_ids, 'product_tag' ) );
$this->set_prop( 'tag_ids', array_unique( array_map( 'intval', $term_ids ) ) );
}
/**
@ -1262,31 +1251,6 @@ class WC_Product extends WC_Abstract_Legacy_Product {
|--------------------------------------------------------------------------
*/
/**
* Get term ids from either a list of names, ids, or terms.
*
* @since 2.7.0
* @param array $terms
* @param string $taxonomy
*/
protected function sanitize_term_ids( $terms, $taxonomy ) {
$term_ids = array();
foreach ( $terms as $term ) {
if ( is_object( $term ) ) {
$term_ids[] = $term->term_id;
} elseif ( is_integer( $term ) ) {
$term_ids[] = absint( $term );
} else {
$term_object = get_term_by( 'name', $term, $taxonomy );
if ( $term_object && ! is_wp_error( $term_object ) ) {
$term_ids[] = $term_object->term_id;
}
}
}
return $term_ids;
}
/**
* Ensure properties are set correctly before save.
* @since 2.7.0
@ -1438,23 +1402,25 @@ class WC_Product extends WC_Abstract_Legacy_Product {
/**
* Returns whether or not the product is on sale.
*
* @param string $context What the value is for. Valid values are view and edit.
* @return bool
*/
public function is_on_sale() {
if ( '' !== (string) $this->get_sale_price() && $this->get_regular_price() > $this->get_sale_price() ) {
$onsale = true;
public function is_on_sale( $context = 'view' ) {
if ( '' !== (string) $this->get_sale_price( $context ) && $this->get_regular_price( $context ) > $this->get_sale_price( $context ) ) {
$on_sale = true;
if ( '' !== (string) $this->get_date_on_sale_from() && $this->get_date_on_sale_from() > strtotime( 'NOW', current_time( 'timestamp' ) ) ) {
$onsale = false;
if ( '' !== (string) $this->get_date_on_sale_from( $context ) && $this->get_date_on_sale_from( $context ) > strtotime( 'NOW', current_time( 'timestamp' ) ) ) {
$on_sale = false;
}
if ( '' !== (string) $this->get_date_on_sale_to() && $this->get_date_on_sale_to() < strtotime( 'NOW', current_time( 'timestamp' ) ) ) {
$onsale = false;
if ( '' !== (string) $this->get_date_on_sale_to( $context ) && $this->get_date_on_sale_to( $context ) < strtotime( 'NOW', current_time( 'timestamp' ) ) ) {
$on_sale = false;
}
} else {
$onsale = false;
$on_sale = false;
}
return apply_filters( 'woocommerce_product_is_on_sale', $onsale, $this );
return 'view' === $context ? apply_filters( 'woocommerce_product_is_on_sale', $on_sale, $this ) : $on_sale;
}
/**
@ -1689,6 +1655,26 @@ class WC_Product extends WC_Abstract_Legacy_Product {
return sprintf( '%2$s (%1$s)', $identifier, $this->get_name() );
}
/**
* Get min quantity which can be purchased at once.
*
* @since 2.7.0
* @return int
*/
public function get_min_purchase_quantity() {
return 1;
}
/**
* Get max quantity which can be purchased at once.
*
* @since 2.7.0
* @return int Quantity or -1 if unlimited.
*/
public function get_max_purchase_quantity() {
return $this->is_sold_individually() ? 1 : ( $this->backorders_allowed() || ! $this->get_manage_stock() ? -1 : $this->get_stock_quantity() );
}
/**
* Get the add to url used mainly in loops.
*
@ -1769,7 +1755,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
} else {
return '';
}
return $attribute_object->is_taxonomy() ? implode( ', ', wc_get_object_terms( $this->get_id(), $attribute_object->get_name(), 'name' ) ) : wc_implode_text_attributes( $attribute_object->get_options() );
return $attribute_object->is_taxonomy() ? implode( ', ', wc_get_product_terms( $this->get_id(), $attribute_object->get_name(), array( 'fields' => 'names' ) ) ) : wc_implode_text_attributes( $attribute_object->get_options() );
}
/**
@ -1833,7 +1819,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
public function get_price_suffix( $price = '', $qty = 1 ) {
$html = '';
if ( ( $suffix = get_option( 'woocommerce_price_display_suffix' ) ) && wc_tax_enabled() ) {
if ( ( $suffix = get_option( 'woocommerce_price_display_suffix' ) ) && wc_tax_enabled() && 'taxable' === $this->get_tax_status() ) {
if ( '' === $price ) {
$price = $this->get_price();
}
@ -1841,9 +1827,9 @@ class WC_Product extends WC_Abstract_Legacy_Product {
'{price_including_tax}' => wc_price( wc_get_price_including_tax( $this, array( 'qty' => $qty, 'price' => $price ) ) ),
'{price_excluding_tax}' => wc_price( wc_get_price_excluding_tax( $this, array( 'qty' => $qty, 'price' => $price ) ) ),
);
$html = str_replace( array_keys( $replacements ), array_values( $replacements ), ' <small class ="woocommerce-price-suffix">' . wp_kses_post( $suffix ) . '</small>' );
$html = str_replace( array_keys( $replacements ), array_values( $replacements ), ' <small class="woocommerce-price-suffix">' . wp_kses_post( $suffix ) . '</small>' );
}
return apply_filters( 'woocommerce_get_price_suffix', $html, $this );
return apply_filters( 'woocommerce_get_price_suffix', $html, $this, $price, $qty );
}
/**

View File

@ -168,6 +168,12 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
if ( ! empty( $items['delete'] ) ) {
foreach ( $items['delete'] as $id ) {
$id = (int) $id;
if ( 0 === $id ) {
continue;
}
$_item = new WP_REST_Request( 'DELETE' );
$_item->set_query_params( array( 'id' => $id, 'force' => true ) );
$_response = $this->delete_item( $_item );
@ -353,16 +359,25 @@ abstract class WC_REST_Controller extends WP_REST_Controller {
'description' => __( 'List of created resources.', 'woocommerce' ),
'type' => 'array',
'context' => array( 'view', 'edit' ),
'items' => array(
'type' => 'object',
),
),
'update' => array(
'description' => __( 'List of updated resources.', 'woocommerce' ),
'type' => 'array',
'context' => array( 'view', 'edit' ),
'items' => array(
'type' => 'object',
),
),
'delete' => array(
'description' => __( 'List of delete resources.', 'woocommerce' ),
'type' => 'array',
'context' => array( 'view', 'edit' ),
'items' => array(
'type' => 'integer',
),
),
),
);

View File

@ -0,0 +1,580 @@
<?php
/**
* Abstract Rest CRUD Controler Class
*
* @author Automattic
* @category API
* @package WooCommerce/Abstracts
* @version 2.7.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* WC_REST_CRUD_Controller class.
*
* @extends WC_REST_Posts_Controller
*/
abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v2';
/**
* If object is hierarchical.
*
* @var bool
*/
protected $hierarchical = false;
/**
* Get object.
*
* @param int $id Object ID.
* @return WP_Error|WC_Data
*/
protected function get_object( $id ) {
return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass.", 'woocommerce' ), __METHOD__ ), array( 'status' => 405 ) );
}
/**
* Check if a given request has access to read an item.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|boolean
*/
public function get_item_permissions_check( $request ) {
$object = $this->get_object( (int) $request['id'] );
if ( $object && 0 !== $object->get_id() && ! wc_rest_check_post_permissions( $this->post_type, 'read', $object->get_id() ) ) {
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
}
return true;
}
/**
* Check if a given request has access to update an item.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|boolean
*/
public function update_item_permissions_check( $request ) {
$object = $this->get_object( (int) $request['id'] );
if ( $object && 0 !== $object->get_id() && ! wc_rest_check_post_permissions( $this->post_type, 'edit', $object->get_id() ) ) {
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
}
return true;
}
/**
* Check if a given request has access to delete an item.
*
* @param WP_REST_Request $request Full details about the request.
* @return bool|WP_Error
*/
public function delete_item_permissions_check( $request ) {
$object = $this->get_object( (int) $request['id'] );
if ( $object && 0 !== $object->get_id() && ! wc_rest_check_post_permissions( $this->post_type, 'delete', $object->get_id() ) ) {
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
}
return true;
}
/**
* Get object permalink.
*
* @param int $id Object ID.
* @return string
*/
protected function get_permalink( $object ) {
return '';
}
/**
* Prepares the object for the REST response.
*
* @since 2.7.0
* @param WC_Data $object Object data.
* @param WP_REST_Request $request Request object.
* @return WP_Error|WP_REST_Response Response object on success, or WP_Error object on failure.
*/
protected function prepare_object_for_response( $object, $request ) {
return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass.", 'woocommerce' ), __METHOD__ ), array( 'status' => 405 ) );
}
/**
* Prepares one object for create or update operation.
*
* @since 2.7.0
* @param WP_REST_Request $request Request object.
* @param bool $creating If is creating a new object.
* @return WP_Error|WC_Data The prepared item, or WP_Error object on failure.
*/
protected function prepare_object_for_database( $request, $creating = false ) {
return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass.", 'woocommerce' ), __METHOD__ ), array( 'status' => 405 ) );
}
/**
* Get a single item.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|WP_REST_Response
*/
public function get_item( $request ) {
$object = $this->get_object( (int) $request['id'] );
if ( ! $object || 0 === $object->get_id() ) {
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid ID.', 'woocommerce' ), array( 'status' => 404 ) );
}
$data = $this->prepare_object_for_response( $object, $request );
$response = rest_ensure_response( $data );
if ( $this->public ) {
$response->link_header( 'alternate', $this->get_permalink( $object ), array( 'type' => 'text/html' ) );
}
return $response;
}
/**
* Save an object data.
*
* @since 2.7.0
* @param WP_REST_Request $request Full details about the request.
* @param bool $creating If is creating a new object.
* @return WC_Data|WP_Error
*/
protected function save_object( $request, $creating = false ) {
try {
$object = $this->prepare_object_for_database( $request, $creating );
if ( is_wp_error( $object ) ) {
return $object;
}
$object->save();
return $this->get_object( $object->get_id() );
} catch ( WC_Data_Exception $e ) {
return new WP_Error( $e->getErrorCode(), $e->getMessage(), $e->getErrorData() );
} catch ( WC_REST_Exception $e ) {
return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
}
}
/**
* Create a single item.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|WP_REST_Response
*/
public function create_item( $request ) {
if ( ! empty( $request['id'] ) ) {
/* translators: %s: post type */
return new WP_Error( "woocommerce_rest_{$this->post_type}_exists", sprintf( __( 'Cannot create existing %s.', 'woocommerce' ), $this->post_type ), array( 'status' => 400 ) );
}
$object = $this->save_object( $request, true );
if ( is_wp_error( $object ) ) {
return $object;
}
$this->update_additional_fields_for_object( $object, $request );
/**
* Fires after a single object is created or updated via the REST API.
*
* @param WC_Data $object Inserted object.
* @param WP_REST_Request $request Request object.
* @param boolean $creating True when creating object, false when updating.
*/
do_action( "woocommerce_rest_insert_{$this->post_type}_object", $object, $request, true );
$request->set_param( 'context', 'edit' );
$response = $this->prepare_object_for_response( $object, $request );
$response = rest_ensure_response( $response );
$response->set_status( 201 );
$response->header( 'Location', rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $object->get_id() ) ) );
return $response;
}
/**
* Update a single post.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|WP_REST_Response
*/
public function update_item( $request ) {
$object = $this->get_object( (int) $request['id'] );
if ( ! $object || 0 === $object->get_id() ) {
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid ID.', 'woocommerce' ), array( 'status' => 400 ) );
}
$object = $this->save_object( $request, false );
if ( is_wp_error( $object ) ) {
return $object;
}
$this->update_additional_fields_for_object( $object, $request );
/**
* Fires after a single object is created or updated via the REST API.
*
* @param WC_Data $object Inserted object.
* @param WP_REST_Request $request Request object.
* @param boolean $creating True when creating object, false when updating.
*/
do_action( "woocommerce_rest_insert_{$this->post_type}_object", $object, $request, false );
$request->set_param( 'context', 'edit' );
$response = $this->prepare_object_for_response( $object, $request );
return rest_ensure_response( $response );
}
/**
* Prepare objects query.
*
* @since 2.7.0
* @param WP_REST_Request $request Full details about the request.
* @return array
*/
protected function prepare_objects_query( $request ) {
$args = array();
$args['offset'] = $request['offset'];
$args['order'] = $request['order'];
$args['orderby'] = $request['orderby'];
$args['paged'] = $request['page'];
$args['post__in'] = $request['include'];
$args['post__not_in'] = $request['exclude'];
$args['posts_per_page'] = $request['per_page'];
$args['name'] = $request['slug'];
$args['post_parent__in'] = $request['parent'];
$args['post_parent__not_in'] = $request['parent_exclude'];
$args['s'] = $request['search'];
$args['date_query'] = array();
// Set before into date query. Date query must be specified as an array of an array.
if ( isset( $request['before'] ) ) {
$args['date_query'][0]['before'] = $request['before'];
}
// Set after into date query. Date query must be specified as an array of an array.
if ( isset( $request['after'] ) ) {
$args['date_query'][0]['after'] = $request['after'];
}
// Force the post_type argument, since it's not a user input variable.
$args['post_type'] = $this->post_type;
/**
* Filter the query arguments for a request.
*
* Enables adding extra arguments or setting defaults for a post
* collection request.
*
* @param array $args Key value array of query var to query value.
* @param WP_REST_Request $request The request used.
*/
$args = apply_filters( "woocommerce_rest_{$this->post_type}_object_query", $args, $request );
return $this->prepare_items_query( $args, $request );
}
/**
* Get objects.
*
* @since 2.7.0
* @param array $query_args Query args.
* @return array
*/
protected function get_objects( $query_args ) {
$query = new WP_Query();
$result = $query->query( $query_args );
$total_posts = $query->found_posts;
if ( $total_posts < 1 ) {
// Out-of-bounds, run the query again without LIMIT for total count.
unset( $query_args['paged'] );
$count_query = new WP_Query();
$count_query->query( $query_args );
$total_posts = $count_query->found_posts;
}
return array(
'objects' => array_map( array( $this, 'get_object' ), $result ),
'total' => (int) $total_posts,
'pages' => (int) ceil( $total_posts / (int) $query->query_vars['posts_per_page'] ),
);
}
/**
* Get a collection of posts.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|WP_REST_Response
*/
public function get_items( $request ) {
$query_args = $this->prepare_objects_query( $request );
$query_results = $this->get_objects( $query_args );
$objects = array();
foreach ( $query_results['objects'] as $object ) {
if ( ! wc_rest_check_post_permissions( $this->post_type, 'read', $object->get_id() ) ) {
continue;
}
$data = $this->prepare_object_for_response( $object, $request );
$objects[] = $this->prepare_response_for_collection( $data );
}
$page = (int) $query_args['paged'];
$max_pages = $query_results['pages'];
$response = rest_ensure_response( $objects );
$response->header( 'X-WP-Total', $query_results['total'] );
$response->header( 'X-WP-TotalPages', (int) $max_pages );
$base = add_query_arg( $request->get_query_params(), rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ) );
if ( $page > 1 ) {
$prev_page = $page - 1;
if ( $prev_page > $max_pages ) {
$prev_page = $max_pages;
}
$prev_link = add_query_arg( 'page', $prev_page, $base );
$response->link_header( 'prev', $prev_link );
}
if ( $max_pages > $page ) {
$next_page = $page + 1;
$next_link = add_query_arg( 'page', $next_page, $base );
$response->link_header( 'next', $next_link );
}
return $response;
}
/**
* Delete a single item.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_REST_Response|WP_Error
*/
public function delete_item( $request ) {
$id = (int) $request['id'];
$force = (bool) $request['force'];
$object = $this->get_object( (int) $request['id'] );
$result = false;
if ( ! $object || 0 === $object->get_id() ) {
return new WP_Error( "woocommerce_rest_{$this->post_type}_invalid_id", __( 'Invalid ID.', 'woocommerce' ), array( 'status' => 404 ) );
}
$supports_trash = EMPTY_TRASH_DAYS > 0 && is_callable( array( $object, 'get_status' ) );
/**
* Filter whether an object is trashable.
*
* Return false to disable trash support for the object.
*
* @param boolean $supports_trash Whether the object type support trashing.
* @param WC_Data $object The object being considered for trashing support.
*/
$supports_trash = apply_filters( "woocommerce_rest_{$this->post_type}_object_trashable", $supports_trash, $object );
if ( ! wc_rest_check_post_permissions( $this->post_type, 'delete', $object->get_id() ) ) {
/* translators: %s: post type */
return new WP_Error( "woocommerce_rest_user_cannot_delete_{$this->post_type}", sprintf( __( 'Sorry, you are not allowed to delete %s.', 'woocommerce' ), $this->post_type ), array( 'status' => rest_authorization_required_code() ) );
}
$request->set_param( 'context', 'edit' );
$response = $this->prepare_object_for_response( $object, $request );
// If we're forcing, then delete permanently.
if ( $force ) {
$object->delete( true );
$result = 0 === $object->get_id();
} else {
// If we don't support trashing for this type, error out.
if ( ! $supports_trash ) {
/* translators: %s: post type */
return new WP_Error( 'woocommerce_rest_trash_not_supported', sprintf( __( 'The %s does not support trashing.', 'woocommerce' ), $this->post_type ), array( 'status' => 501 ) );
}
// Otherwise, only trash if we haven't already.
if ( is_callable( array( $object, 'get_status' ) ) ) {
if ( 'trash' === $object->get_status() ) {
/* translators: %s: post type */
return new WP_Error( 'woocommerce_rest_already_trashed', sprintf( __( 'The %s has already been deleted.', 'woocommerce' ), $this->post_type ), array( 'status' => 410 ) );
}
$object->delete();
$result = 'trash' === $object->get_status();
}
}
if ( ! $result ) {
/* translators: %s: post type */
return new WP_Error( 'woocommerce_rest_cannot_delete', sprintf( __( 'The %s cannot be deleted.', 'woocommerce' ), $this->post_type ), array( 'status' => 500 ) );
}
/**
* Fires after a single object is deleted or trashed via the REST API.
*
* @param WC_Data $object The deleted or trashed object.
* @param WP_REST_Response $response The response data.
* @param WP_REST_Request $request The request sent to the API.
*/
do_action( "woocommerce_rest_delete_{$this->post_type}_object", $object, $response, $request );
return $response;
}
/**
* Prepare links for the request.
*
* @param WC_Data $object Object data.
* @param WP_REST_Request $request Request object.
* @return array Links for the given post.
*/
protected function prepare_links( $object, $request ) {
$links = array(
'self' => array(
'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $object->get_id() ) ),
),
'collection' => array(
'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ),
),
);
return $links;
}
/**
* Get the query params for collections of attachments.
*
* @return array
*/
public function get_collection_params() {
$params['context'] = $this->get_context_param();
$params['context']['default'] = 'view';
$params['page'] = array(
'description' => __( 'Current page of the collection.', 'woocommerce' ),
'type' => 'integer',
'default' => 1,
'sanitize_callback' => 'absint',
'validate_callback' => 'rest_validate_request_arg',
'minimum' => 1,
);
$params['per_page'] = array(
'description' => __( 'Maximum number of items to be returned in result set.', 'woocommerce' ),
'type' => 'integer',
'default' => 10,
'minimum' => 1,
'maximum' => 100,
'sanitize_callback' => 'absint',
'validate_callback' => 'rest_validate_request_arg',
);
$params['search'] = array(
'description' => __( 'Limit results to those matching a string.', 'woocommerce' ),
'type' => 'string',
'sanitize_callback' => 'sanitize_text_field',
'validate_callback' => 'rest_validate_request_arg',
);
$params['after'] = array(
'description' => __( 'Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce' ),
'type' => 'string',
'format' => 'date-time',
'validate_callback' => 'rest_validate_request_arg',
);
$params['before'] = array(
'description' => __( 'Limit response to resources published before a given ISO8601 compliant date.', 'woocommerce' ),
'type' => 'string',
'format' => 'date-time',
'validate_callback' => 'rest_validate_request_arg',
);
$params['exclude'] = array(
'description' => __( 'Ensure result set excludes specific IDs.', 'woocommerce' ),
'type' => 'array',
'items' => array(
'type' => 'integer',
),
'default' => array(),
'sanitize_callback' => 'wp_parse_id_list',
);
$params['include'] = array(
'description' => __( 'Limit result set to specific ids.', 'woocommerce' ),
'type' => 'array',
'items' => array(
'type' => 'integer',
),
'default' => array(),
'sanitize_callback' => 'wp_parse_id_list',
);
$params['offset'] = array(
'description' => __( 'Offset the result set by a specific number of items.', 'woocommerce' ),
'type' => 'integer',
'sanitize_callback' => 'absint',
'validate_callback' => 'rest_validate_request_arg',
);
$params['order'] = array(
'description' => __( 'Order sort attribute ascending or descending.', 'woocommerce' ),
'type' => 'string',
'default' => 'desc',
'enum' => array( 'asc', 'desc' ),
'validate_callback' => 'rest_validate_request_arg',
);
$params['orderby'] = array(
'description' => __( 'Sort collection by object attribute.', 'woocommerce' ),
'type' => 'string',
'default' => 'date',
'enum' => array(
'date',
'id',
'include',
'title',
'slug',
),
'validate_callback' => 'rest_validate_request_arg',
);
if ( $this->hierarchical ) {
$params['parent'] = array(
'description' => __( 'Limit result set to those of particular parent IDs.', 'woocommerce' ),
'type' => 'array',
'items' => array(
'type' => 'integer',
),
'sanitize_callback' => 'wp_parse_id_list',
'default' => array(),
);
$params['parent_exclude'] = array(
'description' => __( 'Limit result set to all items except those of a particular parent ID.', 'woocommerce' ),
'type' => 'array',
'items' => array(
'type' => 'integer',
),
'sanitize_callback' => 'wp_parse_id_list',
'default' => array(),
);
}
return $params;
}
}

View File

@ -93,7 +93,7 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
* @return WP_Error|boolean
*/
public function update_item_permissions_check( $request ) {
$post = get_post( $request['id'] );
$post = get_post( (int) $request['id'] );
if ( $post && ! wc_rest_check_post_permissions( $this->post_type, 'edit', $post->ID ) ) {
return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
@ -109,7 +109,7 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
* @return bool|WP_Error
*/
public function delete_item_permissions_check( $request ) {
$post = get_post( $request['id'] );
$post = get_post( (int) $request['id'] );
if ( $post && ! wc_rest_check_post_permissions( $this->post_type, 'delete', $post->ID ) ) {
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
@ -324,9 +324,11 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
$args['date_query'][0]['after'] = $request['after'];
}
if ( is_array( $request['filter'] ) ) {
$args = array_merge( $args, $request['filter'] );
unset( $args['filter'] );
if ( 'wc/v1' === $this->namespace ) {
if ( is_array( $request['filter'] ) ) {
$args = array_merge( $args, $request['filter'] );
unset( $args['filter'] );
}
}
// Force the post_type argument, since it's not a user input variable.
@ -625,16 +627,22 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
'validate_callback' => 'rest_validate_request_arg',
);
$params['exclude'] = array(
'description' => __( 'Ensure result set excludes specific IDs.', 'woocommerce' ),
'type' => 'array',
'default' => array(),
'sanitize_callback' => 'wp_parse_id_list',
'description' => __( 'Ensure result set excludes specific IDs.', 'woocommerce' ),
'type' => 'array',
'items' => array(
'type' => 'integer',
),
'default' => array(),
'sanitize_callback' => 'wp_parse_id_list',
);
$params['include'] = array(
'description' => __( 'Limit result set to specific ids.', 'woocommerce' ),
'type' => 'array',
'default' => array(),
'sanitize_callback' => 'wp_parse_id_list',
'description' => __( 'Limit result set to specific ids.', 'woocommerce' ),
'type' => 'array',
'items' => array(
'type' => 'integer',
),
'default' => array(),
'sanitize_callback' => 'wp_parse_id_list',
);
$params['offset'] = array(
'description' => __( 'Offset the result set by a specific number of items.', 'woocommerce' ),
@ -664,24 +672,34 @@ abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
);
$post_type_obj = get_post_type_object( $this->post_type );
if ( isset( $post_type_obj->hierarchical ) && $post_type_obj->hierarchical ) {
$params['parent'] = array(
'description' => __( 'Limit result set to those of particular parent IDs.', 'woocommerce' ),
'type' => 'array',
'items' => array(
'type' => 'integer',
),
'sanitize_callback' => 'wp_parse_id_list',
'default' => array(),
);
$params['parent_exclude'] = array(
'description' => __( 'Limit result set to all items except those of a particular parent ID.', 'woocommerce' ),
'type' => 'array',
'items' => array(
'type' => 'integer',
),
'sanitize_callback' => 'wp_parse_id_list',
'default' => array(),
);
}
$params['filter'] = array(
'description' => __( 'Use WP Query arguments to modify the response; private query vars require appropriate authorization.', 'woocommerce' ),
);
if ( 'wc/v1' === $this->namespace ) {
$params['filter'] = array(
'type' => 'object',
'description' => __( 'Use WP Query arguments to modify the response; private query vars require appropriate authorization.', 'woocommerce' ),
);
}
return $params;
}

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