Merge commit

This commit is contained in:
Jonathan Belcher 2018-11-06 15:57:00 -05:00
commit 3d543b9ff2
7 changed files with 718 additions and 66 deletions

21
.eslintignore Normal file
View File

@ -0,0 +1,21 @@
*.min.js
/assets/js/accounting/**
/assets/js/flexslider/**
/assets/js/jquery-blockui/**
/assets/js/jquery-cookie/**
/assets/js/jquery-flot/**
/assets/js/jquery-payment/**
/assets/js/jquery-qrcode/**
/assets/js/jquery-serializejson/**
/assets/js/jquery-tiptip/**
/assets/js/jquery-ui-touch-punch/**
/assets/js/js-cookie/**
/assets/js/photoswipe/**
/assets/js/prettyPhoto/**
/assets/js/round/**
/assets/js/select2/**
/assets/js/selectWoo/**
/assets/js/stupidtable/**
/assets/js/zeroclipboard/**
/assets/js/zoom/**

18
.eslintrc Normal file
View File

@ -0,0 +1,18 @@
{
"root": true,
"env": {
"browser": true,
"node": true
},
"globals": {
"wp": true,
"wpApiSettings": true,
"wcSettings": true
},
"rules": {
"camelcase": 0,
"indent": 0,
"max-len": [ 2, { "code": 140 } ],
"no-console": 1
}
}

View File

@ -848,6 +848,7 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
$exclude_term_ids = array();
$outofstock_join = '';
$outofstock_where = '';
$non_published_where = '';
$product_visibility_term_ids = wc_get_product_visibility_term_ids();
if ( 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ) && $product_visibility_term_ids['outofstock'] ) {
@ -859,6 +860,17 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
$outofstock_where = ' AND exclude_join.object_id IS NULL';
}
// Fetch a list of non-published parent products and exlude them, quicker than joining in the main query below.
$non_published_products = $wpdb->get_col(
"SELECT post.ID as id FROM `$wpdb->posts` AS post
WHERE post.post_type = 'product'
AND post.post_parent = 0
AND post.post_status != 'publish'"
);
if ( 0 < count( $non_published_products ) ) {
$non_published_where = ' AND post.post_parent NOT IN ( ' . implode( ',', $non_published_products ) . ')';
}
return $wpdb->get_results(
// phpcs:disable WordPress.WP.PreparedSQL.NotPrepared
$wpdb->prepare(
@ -874,6 +886,7 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
AND CAST( meta.meta_value AS CHAR ) != ''
AND CAST( meta.meta_value AS DECIMAL( 10, %d ) ) = CAST( meta2.meta_value AS DECIMAL( 10, %d ) )
$outofstock_where
$non_published_where
GROUP BY post.ID",
$decimals,
$decimals

View File

@ -1523,6 +1523,15 @@ function wc_shipping_zone_method_order_uasort_comparison( $a, $b ) {
* @return int
*/
function wc_checkout_fields_uasort_comparison( $a, $b ) {
/*
* We are not guaranteed to get a priority
* setting. So don't compare if they don't
* exist.
*/
if ( ! isset( $a['priority'], $b['priority'] ) ) {
return 0;
}
return wc_uasort_comparison( $a['priority'], $b['priority'] );
}

709
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -12,6 +12,7 @@
"scripts": {
"build": "grunt",
"build-watch": "grunt watch",
"lint:js": "eslint assets/js --ext=js",
"test": "cross-env NODE_CONFIG_DIR='./tests/e2e-tests/config' BABEL_ENV=commonjs mocha \"tests/e2e-tests\" --require babel-register --recursive",
"test:grep": "cross-env NODE_CONFIG_DIR='./tests/e2e-tests/config' BABEL_ENV=commonjs mocha \"tests/e2e-tests\" --require babel-register --grep ",
"test:single": "cross-env NODE_CONFIG_DIR='./tests/e2e-tests/config' BABEL_ENV=commonjs mocha --require babel-register"
@ -29,6 +30,9 @@
"chromedriver": "^2.40.0",
"config": "^1.24.0",
"cross-env": "^5.1.6",
"eslint": "5.8.0",
"eslint-config-wpcalypso": "4.0.1",
"eslint-plugin-wpcalypso": "4.0.2",
"grunt": "^1.0.3",
"grunt-checktextdomain": "~1.0.1",
"grunt-contrib-clean": "~1.1.0",

View File

@ -495,12 +495,22 @@ class WC_Tests_Product_Data_Store extends WC_Unit_Test_Case {
$future_sale_product->set_price( $future_sale_product->get_regular_price() );
$future_sale_product->save();
$variable_draft_product = WC_Helper_Product::create_variation_product();
$variable_draft_product->set_status( 'draft' );
$variable_draft_product->save();
$children = $variable_draft_product->get_children();
$variable_draft_product_child = wc_get_product( $children[0] );
$variable_draft_product_child->set_sale_price( 8 );
$variable_draft_product_child->save();
$sale_products = $product_store->get_on_sale_products();
$sale_product_ids = wp_list_pluck( $sale_products, 'id' );
$this->assertContains( $sale_product->get_id(), $sale_product_ids );
$this->assertNotContains( $not_sale_product->get_id(), $sale_product_ids );
$this->assertNotContains( $future_sale_product->get_id(), $sale_product_ids );
$this->assertNotContains( $variable_draft_product->get_id(), $sale_product_ids );
$this->assertNotContains( $variable_draft_product_child->get_id(), $sale_product_ids );
}
public function test_generate_product_title() {