From 189aa666553dbff7e09fe210ac64186fc5b8fd45 Mon Sep 17 00:00:00 2001 From: Caleb Stauffer Date: Fri, 3 Nov 2017 11:37:00 -0400 Subject: [PATCH 001/170] add action for webhook status change --- includes/class-wc-webhook.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/includes/class-wc-webhook.php b/includes/class-wc-webhook.php index 3ad693ac1dc..eec990be73c 100644 --- a/includes/class-wc-webhook.php +++ b/includes/class-wc-webhook.php @@ -773,7 +773,12 @@ class WC_Webhook { break; } + $prev_post_status = $this->get_status(); + $wpdb->update( $wpdb->posts, array( 'post_status' => $post_status ), array( 'ID' => $this->id ) ); + + do_action( 'woocommerce_webhook_updated_status', $this->id, $post_status, $prev_post_status ); + clean_post_cache( $this->id ); } From c312cc35b19709752908039963df9a0b8d905ace Mon Sep 17 00:00:00 2001 From: claudiulodro Date: Tue, 14 Nov 2017 13:40:03 -0800 Subject: [PATCH 002/170] Add new onbackorder stock status --- includes/abstracts/abstract-wc-product.php | 8 +++++++- includes/wc-product-functions.php | 5 +++-- tests/unit-tests/product/data.php | 16 ++++++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/includes/abstracts/abstract-wc-product.php b/includes/abstracts/abstract-wc-product.php index ff70857907a..5ef486fff7d 100644 --- a/includes/abstracts/abstract-wc-product.php +++ b/includes/abstracts/abstract-wc-product.php @@ -946,7 +946,13 @@ class WC_Product extends WC_Abstract_Legacy_Product { * @param string $status New status. */ public function set_stock_status( $status = '' ) { - $this->set_prop( 'stock_status', 'outofstock' === $status ? 'outofstock' : 'instock' ); + $valid_statuses = array_keys( wc_get_product_stock_status_options() ); + + if ( in_array( $status, $valid_statuses, true ) ) { + $this->set_prop( 'stock_status', $status ); + } else { + $this->set_prop( 'stock_status', 'instock' ); + } } /** diff --git a/includes/wc-product-functions.php b/includes/wc-product-functions.php index a440220b6d5..5add166fb8c 100644 --- a/includes/wc-product-functions.php +++ b/includes/wc-product-functions.php @@ -793,8 +793,9 @@ function wc_get_product_tax_class_options() { */ function wc_get_product_stock_status_options() { return array( - 'instock' => __( 'In stock', 'woocommerce' ), - 'outofstock' => __( 'Out of stock', 'woocommerce' ), + 'instock' => __( 'In stock', 'woocommerce' ), + 'outofstock' => __( 'Out of stock', 'woocommerce' ), + 'onbackorder' => __( 'On backorder', 'woocommerce' ), ); } diff --git a/tests/unit-tests/product/data.php b/tests/unit-tests/product/data.php index a281dab7515..f49fb7b3dda 100644 --- a/tests/unit-tests/product/data.php +++ b/tests/unit-tests/product/data.php @@ -79,6 +79,22 @@ class WC_Tests_Product_Data extends WC_Unit_Test_Case { $this->assertEquals( $image_id[0], $product->get_image_id() ); } + /** + * Test the onbackorder stock status. + * + * @since 3.3.0 + */ + public function test_product_stock_status() { + $product = new WC_Product(); + + $product->set_stock_status( 'onbackorder' ); + $this->assertEquals( 'onbackorder', $product->get_stock_status() ); + + $product->save(); + $product = new WC_Product( $product->get_id() ); + $this->assertEquals( 'onbackorder', $product->get_stock_status() ); + } + /** * Test product term setters and getters * @since 3.0.0 From cf7bc61b99bad199fc069aef4ca3aefff308f8d5 Mon Sep 17 00:00:00 2001 From: claudiulodro Date: Tue, 14 Nov 2017 13:49:22 -0800 Subject: [PATCH 003/170] Better code --- includes/abstracts/abstract-wc-product.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/abstracts/abstract-wc-product.php b/includes/abstracts/abstract-wc-product.php index 5ef486fff7d..a63ee92cce3 100644 --- a/includes/abstracts/abstract-wc-product.php +++ b/includes/abstracts/abstract-wc-product.php @@ -946,9 +946,9 @@ class WC_Product extends WC_Abstract_Legacy_Product { * @param string $status New status. */ public function set_stock_status( $status = '' ) { - $valid_statuses = array_keys( wc_get_product_stock_status_options() ); + $valid_statuses = wc_get_product_stock_status_options(); - if ( in_array( $status, $valid_statuses, true ) ) { + if ( $status && isset( $valid_statuses[ $status ] ) ) { $this->set_prop( 'stock_status', $status ); } else { $this->set_prop( 'stock_status', 'instock' ); From dbf6db9373b4fccb0a85c426b8e26b003248bcbb Mon Sep 17 00:00:00 2001 From: claudiulodro Date: Tue, 14 Nov 2017 13:56:56 -0800 Subject: [PATCH 004/170] Show backordered items in admin menu --- includes/admin/class-wc-admin-post-types.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/includes/admin/class-wc-admin-post-types.php b/includes/admin/class-wc-admin-post-types.php index 1d1f8a2b946..9c1894e2fa7 100644 --- a/includes/admin/class-wc-admin-post-types.php +++ b/includes/admin/class-wc-admin-post-types.php @@ -453,6 +453,8 @@ class WC_Admin_Post_Types { case 'is_in_stock': if ( $the_product->is_in_stock() ) { $stock_html = '' . __( 'In stock', 'woocommerce' ) . ''; + } elseif ( $the_product->is_on_backorder() ) { + $stock_html = '' . __( 'On backorder', 'woocommerce' ) . ''; } else { $stock_html = '' . __( 'Out of stock', 'woocommerce' ) . ''; } From 30509598361e77bc75d9a2f4456b9c3de7503b2d Mon Sep 17 00:00:00 2001 From: claudiulodro Date: Tue, 14 Nov 2017 14:18:03 -0800 Subject: [PATCH 005/170] Variations stock status --- .../meta-boxes/views/html-product-data-variations.php | 1 + includes/class-wc-ajax.php | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/includes/admin/meta-boxes/views/html-product-data-variations.php b/includes/admin/meta-boxes/views/html-product-data-variations.php index 7875780c160..e7edf78e253 100644 --- a/includes/admin/meta-boxes/views/html-product-data-variations.php +++ b/includes/admin/meta-boxes/views/html-product-data-variations.php @@ -65,6 +65,7 @@ if ( ! defined( 'ABSPATH' ) ) { + diff --git a/includes/class-wc-ajax.php b/includes/class-wc-ajax.php index f04e4004e22..28da5e68b6f 100644 --- a/includes/class-wc-ajax.php +++ b/includes/class-wc-ajax.php @@ -1918,6 +1918,17 @@ class WC_AJAX { self::variation_bulk_set( $variations, 'stock_status', 'outofstock' ); } + /** + * Bulk action - Set Stock Status as On Backorder. + * @access private + * @used-by bulk_edit_variations + * @param array $variations + * @param array $data + */ + private static function variation_bulk_action_variable_stock_status_onbackorder( $variations, $data ) { + self::variation_bulk_set( $variations, 'stock_status', 'onbackorder' ); + } + /** * Bulk action - Set Stock. * @access private From db117d634473cb962d1a4ac3b96b46c600669e37 Mon Sep 17 00:00:00 2001 From: claudiulodro Date: Tue, 14 Nov 2017 14:54:11 -0800 Subject: [PATCH 006/170] Backordered products should count as in stock --- includes/abstracts/abstract-wc-product.php | 2 +- includes/admin/reports/class-wc-report-stock.php | 2 ++ tests/unit-tests/product/data.php | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/includes/abstracts/abstract-wc-product.php b/includes/abstracts/abstract-wc-product.php index a63ee92cce3..f29266b54bb 100644 --- a/includes/abstracts/abstract-wc-product.php +++ b/includes/abstracts/abstract-wc-product.php @@ -1497,7 +1497,7 @@ class WC_Product extends WC_Abstract_Legacy_Product { * @return bool */ public function is_in_stock() { - return apply_filters( 'woocommerce_product_is_in_stock', 'instock' === $this->get_stock_status(), $this ); + return apply_filters( 'woocommerce_product_is_in_stock', 'instock' === $this->get_stock_status() || 'onbackorder' === $this->get_stock_status(), $this ); } /** diff --git a/includes/admin/reports/class-wc-report-stock.php b/includes/admin/reports/class-wc-report-stock.php index 882e8ac29c0..bfc1fc09979 100644 --- a/includes/admin/reports/class-wc-report-stock.php +++ b/includes/admin/reports/class-wc-report-stock.php @@ -110,6 +110,8 @@ class WC_Report_Stock extends WP_List_Table { case 'stock_status' : if ( $product->is_in_stock() ) { $stock_html = '' . __( 'In stock', 'woocommerce' ) . ''; + } elseif ( $product->is_on_backorder() ) { + $stock_html = '' . __( 'On backorder', 'woocommerce' ) . ''; } else { $stock_html = '' . __( 'Out of stock', 'woocommerce' ) . ''; } diff --git a/tests/unit-tests/product/data.php b/tests/unit-tests/product/data.php index f49fb7b3dda..a681bea9a45 100644 --- a/tests/unit-tests/product/data.php +++ b/tests/unit-tests/product/data.php @@ -84,7 +84,7 @@ class WC_Tests_Product_Data extends WC_Unit_Test_Case { * * @since 3.3.0 */ - public function test_product_stock_status() { + public function test_product_backorder_stock_status() { $product = new WC_Product(); $product->set_stock_status( 'onbackorder' ); From 68e23911ba347f47721cdb9578a76991efb17e2f Mon Sep 17 00:00:00 2001 From: claudiulodro Date: Wed, 15 Nov 2017 10:48:39 -0800 Subject: [PATCH 007/170] Automatically transition stock statuses --- includes/abstracts/abstract-wc-product.php | 6 ++- tests/unit-tests/product/data.php | 55 +++++++++++++++++++++- 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/includes/abstracts/abstract-wc-product.php b/includes/abstracts/abstract-wc-product.php index f29266b54bb..3e9a1fb8979 100644 --- a/includes/abstracts/abstract-wc-product.php +++ b/includes/abstracts/abstract-wc-product.php @@ -1307,6 +1307,10 @@ class WC_Product extends WC_Abstract_Legacy_Product { } elseif ( $this->get_stock_quantity() <= get_option( 'woocommerce_notify_no_stock_amount' ) && 'no' === $this->get_backorders() ) { $this->set_stock_status( 'outofstock' ); + // If we are stock managing, backorders are allowed, and we don't have stock, force on backorder status. + } elseif ( $this->get_stock_quantity() <= 0 && 'no' !== $this->get_backorders() ) { + $this->set_stock_status( 'onbackorder' ); + // If the stock level is changing and we do now have enough, force in stock status. } elseif ( $this->get_stock_quantity() > get_option( 'woocommerce_notify_no_stock_amount' ) && array_key_exists( 'stock_quantity', $this->get_changes() ) ) { $this->set_stock_status( 'instock' ); @@ -1564,7 +1568,7 @@ class WC_Product extends WC_Abstract_Legacy_Product { * @return bool */ public function is_on_backorder( $qty_in_cart = 0 ) { - return $this->managing_stock() && $this->backorders_allowed() && ( $this->get_stock_quantity() - $qty_in_cart ) < 0 ? true : false; + return 'onbackorder' === $this->get_stock_status(); } /** diff --git a/tests/unit-tests/product/data.php b/tests/unit-tests/product/data.php index a681bea9a45..83f57cc76b7 100644 --- a/tests/unit-tests/product/data.php +++ b/tests/unit-tests/product/data.php @@ -86,7 +86,6 @@ class WC_Tests_Product_Data extends WC_Unit_Test_Case { */ public function test_product_backorder_stock_status() { $product = new WC_Product(); - $product->set_stock_status( 'onbackorder' ); $this->assertEquals( 'onbackorder', $product->get_stock_status() ); @@ -95,6 +94,60 @@ class WC_Tests_Product_Data extends WC_Unit_Test_Case { $this->assertEquals( 'onbackorder', $product->get_stock_status() ); } + /** + * Test the automatic stock status changing when products are managing stock. + * + * @since 3.3.0 + */ + public function test_product_auto_stock_status() { + $product = new WC_Product(); + + // Product should not have quantity and stock status should not be updated automatically if not managing stock. + $product->set_manage_stock( false ); + $product->set_stock_quantity( 5 ); + $product->set_stock_status( 'instock' ); + $product->save(); + $this->assertEquals( '', $product->get_stock_quantity() ); + $this->assertEquals( 'instock', $product->get_stock_status() ); + $product->set_stock_status( 'outofstock' ); + $product->save(); + $this->assertEquals( 'outofstock', $product->get_stock_status() ); + + $product->set_manage_stock( true ); + + // Product should be out of stock if managing orders, no backorders allowed, and quantity too low. + $product->set_stock_quantity( 0 ); + $product->set_stock_status( 'instock' ); + $product->set_backorders( 'no' ); + $product->save(); + $this->assertEquals( 0, $product->get_stock_quantity() ); + $this->assertEquals( 'outofstock', $product->get_stock_status() ); + + // Product should be on backorder if managing orders, backorders allowed, and quantity too low. + $product->set_stock_quantity( 0 ); + $product->set_stock_status( 'instock' ); + $product->set_backorders( 'yes' ); + $product->save(); + $this->assertEquals( 0, $product->get_stock_quantity() ); + $this->assertEquals( 'onbackorder', $product->get_stock_status() ); + + // Product should go to in stock if backordered and inventory increases. + $product->set_stock_quantity( 5 ); + $product->set_stock_status( 'onbackorder' ); + $product->set_backorders( 'notify' ); + $product->save(); + $this->assertEquals( 5, $product->get_stock_quantity() ); + $this->assertEquals( 'instock', $product->get_stock_status() ); + + // Product should go to in stock if out of stock and inventory increases. + $product->set_stock_quantity( 3 ); + $product->set_stock_status( 'outofstock' ); + $product->set_backorders( 'no' ); + $product->save(); + $this->assertEquals( 3, $product->get_stock_quantity() ); + $this->assertEquals( 'instock', $product->get_stock_status() ); + } + /** * Test product term setters and getters * @since 3.0.0 From be6f9d68bcd9f793fc4894e697d4b47a09d2dfad Mon Sep 17 00:00:00 2001 From: claudiulodro Date: Wed, 15 Nov 2017 12:08:19 -0800 Subject: [PATCH 008/170] Automatic transitions for variables --- includes/abstracts/abstract-wc-product.php | 6 +-- includes/class-wc-product-variable.php | 16 +++--- tests/unit-tests/product/data.php | 2 +- tests/unit-tests/product/product-variable.php | 51 +++++++++++++++++++ 4 files changed, 63 insertions(+), 12 deletions(-) diff --git a/includes/abstracts/abstract-wc-product.php b/includes/abstracts/abstract-wc-product.php index 3e9a1fb8979..e7cb82a07ad 100644 --- a/includes/abstracts/abstract-wc-product.php +++ b/includes/abstracts/abstract-wc-product.php @@ -1304,15 +1304,15 @@ class WC_Product extends WC_Abstract_Legacy_Product { $this->set_backorders( 'no' ); // If we are stock managing and we don't have stock, force out of stock status. - } elseif ( $this->get_stock_quantity() <= get_option( 'woocommerce_notify_no_stock_amount' ) && 'no' === $this->get_backorders() ) { + } elseif ( $this->get_stock_quantity() <= get_option( 'woocommerce_notify_no_stock_amount', 0 ) && 'no' === $this->get_backorders() ) { $this->set_stock_status( 'outofstock' ); // If we are stock managing, backorders are allowed, and we don't have stock, force on backorder status. - } elseif ( $this->get_stock_quantity() <= 0 && 'no' !== $this->get_backorders() ) { + } elseif ( $this->get_stock_quantity() <= get_option( 'woocommerce_notify_no_stock_amount', 0 ) && 'no' !== $this->get_backorders() ) { $this->set_stock_status( 'onbackorder' ); // If the stock level is changing and we do now have enough, force in stock status. - } elseif ( $this->get_stock_quantity() > get_option( 'woocommerce_notify_no_stock_amount' ) && array_key_exists( 'stock_quantity', $this->get_changes() ) ) { + } elseif ( $this->get_stock_quantity() > get_option( 'woocommerce_notify_no_stock_amount', 0 ) && array_key_exists( 'stock_quantity', $this->get_changes() ) ) { $this->set_stock_status( 'instock' ); } } diff --git a/includes/class-wc-product-variable.php b/includes/class-wc-product-variable.php index f372f4318e8..13114e0c045 100644 --- a/includes/class-wc-product-variable.php +++ b/includes/class-wc-product-variable.php @@ -367,19 +367,19 @@ class WC_Product_Variable extends WC_Product { $this->set_backorders( 'no' ); $this->set_stock_status( $this->child_is_in_stock() ? 'instock' : 'outofstock' ); - // If backorders are enabled, always in stock. - } elseif ( 'no' !== $this->get_backorders() ) { - $this->set_stock_status( 'instock' ); + // If we are stock managing, backorders are allowed, and we don't have stock, force on backorder status. + } elseif ( $this->get_stock_quantity() <= get_option( 'woocommerce_notify_no_stock_amount', 0 ) && 'no' !== $this->get_backorders() ) { + $this->set_stock_status( 'onbackorder' ); - // If we are stock managing and we don't have stock, force out of stock status. - } elseif ( $this->get_stock_quantity() <= get_option( 'woocommerce_notify_no_stock_amount' ) ) { + // If we are stock managing and we don't have stock, force out of stock status. + } elseif ( $this->get_stock_quantity() <= get_option( 'woocommerce_notify_no_stock_amount', 0 ) && 'no' === $this->get_backorders() ) { $this->set_stock_status( 'outofstock' ); - // If the stock level is changing and we do now have enough, force in stock status. - } elseif ( $this->get_stock_quantity() > get_option( 'woocommerce_notify_no_stock_amount' ) && array_key_exists( 'stock_quantity', $this->get_changes() ) ) { + // If the stock level is changing and we do now have enough, force in stock status. + } elseif ( $this->get_stock_quantity() > get_option( 'woocommerce_notify_no_stock_amount', 0 ) && array_key_exists( 'stock_quantity', $this->get_changes() ) ) { $this->set_stock_status( 'instock' ); - // Otherwise revert to status the children have. + // Otherwise revert to status the children have. } else { $this->set_stock_status( $this->child_is_in_stock() ? 'instock' : 'outofstock' ); } diff --git a/tests/unit-tests/product/data.php b/tests/unit-tests/product/data.php index 83f57cc76b7..c8a724adf90 100644 --- a/tests/unit-tests/product/data.php +++ b/tests/unit-tests/product/data.php @@ -95,7 +95,7 @@ class WC_Tests_Product_Data extends WC_Unit_Test_Case { } /** - * Test the automatic stock status changing when products are managing stock. + * Test the automatic stock status transitions done on product save. * * @since 3.3.0 */ diff --git a/tests/unit-tests/product/product-variable.php b/tests/unit-tests/product/product-variable.php index 2ec6ec15b95..be3cec3cfe5 100644 --- a/tests/unit-tests/product/product-variable.php +++ b/tests/unit-tests/product/product-variable.php @@ -20,4 +20,55 @@ class WC_Tests_Product_Variable extends WC_Unit_Test_Case { $this->assertArrayHasKey( 'price', $prices ); $this->assertTrue( $product_id > 0 ); } + + /** + * Test the automatic stock status transitions done on variable product save. + * + * @since 3.3.0 + */ + public function test_variable_product_auto_stock_status() { + $product = new WC_Product_Variable(); + + // Product should not have quantity and stock status should be based on children stock status if not managing stock. + $product->set_manage_stock( false ); + $product->set_stock_quantity( 5 ); + $product->set_stock_status( 'instock' ); + $product->save(); + $this->assertEquals( '', $product->get_stock_quantity() ); + $this->assertEquals( 'outofstock', $product->get_stock_status() ); + + $product->set_manage_stock( true ); + + // Product should be out of stock if managing orders, no backorders allowed, and quantity too low. + $product->set_stock_quantity( 0 ); + $product->set_stock_status( 'instock' ); + $product->set_backorders( 'no' ); + $product->save(); + $this->assertEquals( 0, $product->get_stock_quantity() ); + $this->assertEquals( 'outofstock', $product->get_stock_status() ); + + // Product should be on backorder if managing orders, backorders allowed, and quantity too low. + $product->set_stock_quantity( 0 ); + $product->set_stock_status( 'instock' ); + $product->set_backorders( 'yes' ); + $product->save(); + $this->assertEquals( 0, $product->get_stock_quantity() ); + $this->assertEquals( 'onbackorder', $product->get_stock_status() ); + + // Product should go to in stock if backordered and inventory increases. + $product->set_stock_quantity( 5 ); + $product->set_stock_status( 'onbackorder' ); + $product->set_backorders( 'notify' ); + $product->save(); + $this->assertEquals( 5, $product->get_stock_quantity() ); + $this->assertEquals( 'instock', $product->get_stock_status() ); + + // Product should go to in stock if out of stock and inventory increases. + $product->set_stock_quantity( 3 ); + $product->set_stock_status( 'outofstock' ); + $product->set_backorders( 'no' ); + $product->save(); + $this->assertEquals( 3, $product->get_stock_quantity() ); + $this->assertEquals( 'instock', $product->get_stock_status() ); + } } From bb7f1b127374b543da3be567398126fc6fba6f13 Mon Sep 17 00:00:00 2001 From: claudiulodro Date: Wed, 15 Nov 2017 13:04:24 -0800 Subject: [PATCH 009/170] Logic tweaks --- includes/abstracts/abstract-wc-product.php | 2 +- includes/admin/class-wc-admin-post-types.php | 6 +++--- includes/admin/reports/class-wc-report-stock.php | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/includes/abstracts/abstract-wc-product.php b/includes/abstracts/abstract-wc-product.php index e7cb82a07ad..0fa1793fafe 100644 --- a/includes/abstracts/abstract-wc-product.php +++ b/includes/abstracts/abstract-wc-product.php @@ -1501,7 +1501,7 @@ class WC_Product extends WC_Abstract_Legacy_Product { * @return bool */ public function is_in_stock() { - return apply_filters( 'woocommerce_product_is_in_stock', 'instock' === $this->get_stock_status() || 'onbackorder' === $this->get_stock_status(), $this ); + return apply_filters( 'woocommerce_product_is_in_stock', 'outofstock' !== $this->get_stock_status(), $this ); } /** diff --git a/includes/admin/class-wc-admin-post-types.php b/includes/admin/class-wc-admin-post-types.php index 9c1894e2fa7..ea9ac7ade28 100644 --- a/includes/admin/class-wc-admin-post-types.php +++ b/includes/admin/class-wc-admin-post-types.php @@ -451,10 +451,10 @@ class WC_Admin_Post_Types { echo ''; break; case 'is_in_stock': - if ( $the_product->is_in_stock() ) { - $stock_html = '' . __( 'In stock', 'woocommerce' ) . ''; - } elseif ( $the_product->is_on_backorder() ) { + if ( $the_product->is_on_backorder() ) { $stock_html = '' . __( 'On backorder', 'woocommerce' ) . ''; + } elseif ( $the_product->is_in_stock() ) { + $stock_html = '' . __( 'In stock', 'woocommerce' ) . ''; } else { $stock_html = '' . __( 'Out of stock', 'woocommerce' ) . ''; } diff --git a/includes/admin/reports/class-wc-report-stock.php b/includes/admin/reports/class-wc-report-stock.php index bfc1fc09979..24fde0df24c 100644 --- a/includes/admin/reports/class-wc-report-stock.php +++ b/includes/admin/reports/class-wc-report-stock.php @@ -108,10 +108,10 @@ class WC_Report_Stock extends WP_List_Table { break; case 'stock_status' : - if ( $product->is_in_stock() ) { - $stock_html = '' . __( 'In stock', 'woocommerce' ) . ''; - } elseif ( $product->is_on_backorder() ) { + if ( $product->is_on_backorder() ) { $stock_html = '' . __( 'On backorder', 'woocommerce' ) . ''; + } elseif ( $product->is_in_stock() ) { + $stock_html = '' . __( 'In stock', 'woocommerce' ) . ''; } else { $stock_html = '' . __( 'Out of stock', 'woocommerce' ) . ''; } From 4ef2152881a4e001fa438ffb80642982ec66d114 Mon Sep 17 00:00:00 2001 From: claudiulodro Date: Wed, 15 Nov 2017 14:10:06 -0800 Subject: [PATCH 010/170] Hide/set fields depending on whether managing stock --- assets/js/admin/meta-boxes-order.min.js | 2 +- assets/js/admin/meta-boxes-product.js | 2 + assets/js/admin/meta-boxes-product.min.js | 2 +- assets/js/admin/quick-edit.js | 12 ++- assets/js/admin/quick-edit.min.js | 2 +- assets/js/admin/settings.min.js | 2 +- assets/js/frontend/cart.js | 4 +- assets/js/frontend/cart.min.js | 2 +- assets/js/frontend/lost-password.min.js | 2 +- .../frontend/password-strength-meter.min.js | 2 +- .../views/html-product-data-inventory.php | 2 +- .../admin/views/html-quick-edit-product.php | 73 ++++++++++--------- 12 files changed, 57 insertions(+), 50 deletions(-) diff --git a/assets/js/admin/meta-boxes-order.min.js b/assets/js/admin/meta-boxes-order.min.js index e419f397738..1bac279267d 100644 --- a/assets/js/admin/meta-boxes-order.min.js +++ b/assets/js/admin/meta-boxes-order.min.js @@ -1 +1 @@ -jQuery(function(e){var o={states:null,init:function(){"undefined"!=typeof woocommerce_admin_meta_boxes_order&&"undefined"!=typeof woocommerce_admin_meta_boxes_order.countries&&(this.states=e.parseJSON(woocommerce_admin_meta_boxes_order.countries.replace(/"/g,'"'))),e(".js_field-country").selectWoo().change(this.change_country),e(".js_field-country").trigger("change",[!0]),e(document.body).on("change","select.js_field-state",this.change_state),e("#woocommerce-order-actions input, #woocommerce-order-actions a").click(function(){window.onbeforeunload=""}),e("a.edit_address").click(this.edit_address),e("a.billing-same-as-shipping").on("click",this.copy_billing_to_shipping),e("a.load_customer_billing").on("click",this.load_billing),e("a.load_customer_shipping").on("click",this.load_shipping),e("#customer_user").on("change",this.change_customer_user)},change_country:function(t,i){if(void 0===i&&(i=!1),null!==o.states){var a=e(this),n=a.val(),r=a.parents("div.edit_address").find(":input.js_field-state"),c=r.parent(),d=r.attr("name"),_=r.attr("id"),m=a.data("woocommerce.stickState-"+n)?a.data("woocommerce.stickState-"+n):r.val(),s=r.attr("placeholder");if(i&&a.data("woocommerce.stickState-"+n,m),c.show().find(".select2-container").remove(),e.isEmptyObject(o.states[n]))r.replaceWith('');else{var l=e(''),u=o.states[n];l.append(e('")),e.each(u,function(o){l.append(e('"))}),l.val(m),r.replaceWith(l),l.show().selectWoo().hide().change()}e(document.body).trigger("contry-change.woocommerce",[n,e(this).closest("div")]),e(document.body).trigger("country-change.woocommerce",[n,e(this).closest("div")])}},change_state:function(){var o=e(this),t=o.val(),i=o.parents("div.edit_address").find(":input.js_field-country"),a=i.val();i.data("woocommerce.stickState-"+a,t)},init_tiptip:function(){e("#tiptip_holder").removeAttr("style"),e("#tiptip_arrow").removeAttr("style"),e(".tips").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200})},edit_address:function(o){o.preventDefault();var t=e(this),i=t.closest(".order_data_column"),a=i.find("div.edit_address"),n=i.find("div.address"),r=a.find(".js_field-country"),c=a.find(".js_field-state");n.hide(),t.parent().find("a").toggle(),r.val()||r.val(woocommerce_admin_meta_boxes_order.default_country).change(),c.val()||c.val(woocommerce_admin_meta_boxes_order.default_state).change(),a.show()},change_customer_user:function(){e("#_billing_country").val()||(e("a.edit_address").click(),o.load_billing(!0),o.load_shipping(!0))},load_billing:function(o){if(!0===o||window.confirm(woocommerce_admin_meta_boxes.load_billing)){var t=e("#customer_user").val();if(!t)return window.alert(woocommerce_admin_meta_boxes.no_customer_selected),!1;var i={user_id:t,action:"woocommerce_get_customer_details",security:woocommerce_admin_meta_boxes.get_customer_details_nonce};e(this).closest("div.edit_address").block({message:null,overlayCSS:{background:"#fff",opacity:.6}}),e.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:i,type:"POST",success:function(o){o&&o.billing&&e.each(o.billing,function(o,t){e(":input#_billing_"+o).val(t).change()}),e("div.edit_address").unblock()}})}return!1},load_shipping:function(o){if(!0===o||window.confirm(woocommerce_admin_meta_boxes.load_shipping)){var t=e("#customer_user").val();if(!t)return window.alert(woocommerce_admin_meta_boxes.no_customer_selected),!1;var i={user_id:t,action:"woocommerce_get_customer_details",security:woocommerce_admin_meta_boxes.get_customer_details_nonce};e(this).closest("div.edit_address").block({message:null,overlayCSS:{background:"#fff",opacity:.6}}),e.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:i,type:"POST",success:function(o){o&&o.billing&&e.each(o.shipping,function(o,t){e(":input#_shipping_"+o).val(t).change()}),e("div.edit_address").unblock()}})}return!1},copy_billing_to_shipping:function(){return window.confirm(woocommerce_admin_meta_boxes.copy_billing)&&e('.order_data_column :input[name^="_billing_"]').each(function(){var o=e(this).attr("name");o=o.replace("_billing_","_shipping_"),e(":input#"+o).val(e(this).val()).change()}),!1}},t={init:function(){this.stupidtable.init(),e("#woocommerce-order-items").on("click","button.add-line-item",this.add_line_item).on("click","button.add-coupon",this.add_coupon).on("click","a.remove-coupon",this.remove_coupon).on("click","button.refund-items",this.refund_items).on("click",".cancel-action",this.cancel).on("click","button.add-order-item",this.add_item).on("click","button.add-order-fee",this.add_fee).on("click","button.add-order-shipping",this.add_shipping).on("click","button.add-order-tax",this.add_tax).on("click","button.save-action",this.save_line_items).on("click","a.delete-order-tax",this.delete_tax).on("click","button.calculate-action",this.recalculate).on("click","a.edit-order-item",this.edit_item).on("click","a.delete-order-item",this.delete_item).on("click","tr.item, tr.fee, tr.shipping, tr.refund",this.select_row).on("click","tr.item :input, tr.fee :input, tr.shipping :input, tr.refund :input, tr.item a, tr.fee a, tr.shipping a, tr.refund a",this.select_row_child).on("click","button.bulk-delete-items",this.bulk_actions.do_delete).on("click","button.bulk-increase-stock",this.bulk_actions.do_increase_stock).on("click","button.bulk-decrease-stock",this.bulk_actions.do_reduce_stock).on("click",".delete_refund",this.refunds.delete_refund).on("click","button.do-api-refund, button.do-manual-refund",this.refunds.do_refund).on("change",".refund input.refund_line_total, .refund input.refund_line_tax",this.refunds.input_changed).on("change keyup",".wc-order-refund-items #refund_amount",this.refunds.amount_changed).on("change","input.refund_order_item_qty",this.refunds.refund_quantity_changed).on("change","input.quantity",this.quantity_changed).on("keyup change",".split-input :input",function(){var o=e(this).parent().prev().find(":input");o&&(""===o.val()||o.is(".match-total"))&&o.val(e(this).val()).addClass("match-total")}).on("keyup",".split-input :input",function(){e(this).removeClass("match-total")}).on("click","button.add_order_item_meta",this.item_meta.add).on("click","button.remove_order_item_meta",this.item_meta.remove),e(document.body).on("wc_backbone_modal_loaded",this.backbone.init).on("wc_backbone_modal_response",this.backbone.response)},block:function(){e("#woocommerce-order-items").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},unblock:function(){e("#woocommerce-order-items").unblock()},reload_items:function(){var i={order_id:woocommerce_admin_meta_boxes.post_id,action:"woocommerce_load_order_items",security:woocommerce_admin_meta_boxes.order_item_nonce};t.block(),e.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:i,type:"POST",success:function(i){e("#woocommerce-order-items").find(".inside").empty(),e("#woocommerce-order-items").find(".inside").append(i),o.init_tiptip(),t.unblock(),t.stupidtable.init()}})},quantity_changed:function(){var o=e(this).closest("tr.item"),t=e(this).val(),i=e(this).attr("data-qty"),a=e("input.line_total",o),n=e("input.line_subtotal",o),r=accounting.unformat(a.attr("data-total"),woocommerce_admin.mon_decimal_point)/i;a.val(parseFloat(accounting.formatNumber(r*t,woocommerce_admin_meta_boxes.rounding_precision,"")).toString().replace(".",woocommerce_admin.mon_decimal_point));var c=accounting.unformat(n.attr("data-subtotal"),woocommerce_admin.mon_decimal_point)/i;n.val(parseFloat(accounting.formatNumber(c*t,woocommerce_admin_meta_boxes.rounding_precision,"")).toString().replace(".",woocommerce_admin.mon_decimal_point)),e("input.line_tax",o).each(function(){var a=e(this),n=a.data("tax_id"),r=accounting.unformat(a.attr("data-total_tax"),woocommerce_admin.mon_decimal_point)/i,c=e('input.line_subtotal_tax[data-tax_id="'+n+'"]',o),d=accounting.unformat(c.attr("data-subtotal_tax"),woocommerce_admin.mon_decimal_point)/i;00?e("#restock_refunded_items").closest("tr").show():(e("#restock_refunded_items").closest("tr").hide(),e(".woocommerce_order_items input.refund_order_item_qty").each(function(){e(this).val()>0&&e("#restock_refunded_items").closest("tr").show()})),e(this).trigger("refund_quantity_changed")}},item_meta:{add:function(){var o=e(this).closest("tr.item, tr.shipping"),t=o.find("tbody.meta_items"),i=t.find("tr").length+1,a='';return t.append(a),!1},remove:function(){if(window.confirm(woocommerce_admin_meta_boxes.remove_item_meta)){var o=e(this).closest("tr");o.find(":input").val(""),o.hide()}return!1}},select_row:function(){var o=!1;o=e(this).is("tr")?e(this):e(this).closest("tr");var t=e(this).closest("table");o.is(".selected")?o.removeClass("selected"):o.addClass("selected");var i=t.find("tr.selected");if(i.length){e("div.wc-order-item-bulk-edit").slideDown();var a=!1;i.each(function(){e(this).is("tr.item")&&(a=!0)}),a?e(".bulk-increase-stock, .bulk-decrease-stock").show():e(".bulk-increase-stock, .bulk-decrease-stock").hide()}else e("div.wc-order-item-bulk-edit").slideUp()},select_row_child:function(e){e.stopPropagation()},bulk_actions:{do_delete:function(o){o.preventDefault();var i=e("table.woocommerce_order_items").find("tr.selected");if(i.length&&window.confirm(woocommerce_admin_meta_boxes.remove_item_notice)){t.block();var a=[],n=[],r=[];e.map(i,function(o){var t=e(o);t.is(".refund")?n.push(parseInt(e(t).data("order_refund_id"),10)):a.push(parseInt(e(t).data("order_item_id"),10))}),a.length&&r.push(e.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:{order_id:woocommerce_admin_meta_boxes.post_id,order_item_ids:a,action:"woocommerce_remove_order_item",security:woocommerce_admin_meta_boxes.order_item_nonce},type:"POST"})),n.length&&r.push(e.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:{action:"woocommerce_delete_refund",refund_id:n,security:woocommerce_admin_meta_boxes.order_item_nonce},type:"POST"})),r?e.when.apply(e,r).done(function(){t.reload_items(),t.unblock()}):t.unblock()}},do_increase_stock:function(o){o.preventDefault(),t.block();var i=e("table.woocommerce_order_items").find("tr.selected"),a={},n=e.map(i,function(o){return parseInt(e(o).data("order_item_id"),10)});i.each(function(){e(this).find("input.quantity").length&&(a[e(this).attr("data-order_item_id")]=e(this).find("input.quantity").val())});var r={order_id:woocommerce_admin_meta_boxes.post_id,order_item_ids:n,order_item_qty:a,action:"woocommerce_increase_order_item_stock",security:woocommerce_admin_meta_boxes.order_item_nonce};e.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:r,type:"POST",success:function(e){window.alert(e),t.unblock()}})},do_reduce_stock:function(o){o.preventDefault(),t.block();var i=e("table.woocommerce_order_items").find("tr.selected"),a={},n=e.map(i,function(o){return parseInt(e(o).data("order_item_id"),10)});i.each(function(){e(this).find("input.quantity").length&&(a[e(this).attr("data-order_item_id")]=e(this).find("input.quantity").val())});var r={order_id:woocommerce_admin_meta_boxes.post_id,order_item_ids:n,order_item_qty:a,action:"woocommerce_reduce_order_item_stock",security:woocommerce_admin_meta_boxes.order_item_nonce};e.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:r,type:"POST",success:function(e){window.alert(e),t.unblock()}})}},backbone:{init:function(o,t){"wc-modal-add-products"===t&&(e(document.body).trigger("wc-enhanced-select-init"),e("#add_item_id").selectWoo("open").selectWoo("focus"))},response:function(e,o,i){if("wc-modal-add-tax"===o){var a=i.add_order_tax,n="";i.manual_tax_rate_id&&(n=i.manual_tax_rate_id),t.backbone.add_tax(a,n)}"wc-modal-add-products"===o&&t.backbone.add_item(i.add_order_items)},add_item:function(i){if(i){t.block();var a={action:"woocommerce_add_order_item",item_to_add:i,dataType:"json",order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.order_item_nonce,data:e("#wc-backbone-modal-dialog form").serialize()};"true"===e("button.cancel-action").attr("data-reload")&&(a.items=e("table.woocommerce_order_items :input[name], .wc-order-totals-items :input[name]").serialize()),e.post(woocommerce_admin_meta_boxes.ajax_url,a,function(i){i.success?(e("#woocommerce-order-items").find(".inside").empty(),e("#woocommerce-order-items").find(".inside").append(i.data.html),o.init_tiptip(),t.stupidtable.init()):window.alert(i.data.error),t.unblock()})}},add_tax:function(i,a){if(a&&(i=a),!i)return!1;var n=e(".order-tax-id").map(function(){return e(this).val()}).get();if(-1===e.inArray(i,n)){t.block();var r={action:"woocommerce_add_order_tax",rate_id:i,order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.order_item_nonce};e.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:r,dataType:"json",type:"POST",success:function(i){i.success?(e("#woocommerce-order-items").find(".inside").empty(),e("#woocommerce-order-items").find(".inside").append(i.data.html),o.init_tiptip(),t.stupidtable.init()):window.alert(i.data.error),t.unblock()}})}else window.alert(woocommerce_admin_meta_boxes.i18n_tax_rate_already_exists)}},stupidtable:{init:function(){e(".woocommerce_order_items").stupidtable(),e(".woocommerce_order_items").on("aftertablesort",this.add_arrows)},add_arrows:function(o,t){var i=e(this).find("th"),a="asc"===t.direction?"↑":"↓",n=t.column;i.find(".wc-arrow").remove(),i.eq(n).append(''+a+"")}}},i={init:function(){e("#woocommerce-order-notes").on("click","button.add_note",this.add_order_note).on("click","a.delete_note",this.delete_order_note)},add_order_note:function(){if(e("textarea#add_order_note").val()){e("#woocommerce-order-notes").block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var o={action:"woocommerce_add_order_note",post_id:woocommerce_admin_meta_boxes.post_id,note:e("textarea#add_order_note").val(),note_type:e("select#order_note_type").val(),security:woocommerce_admin_meta_boxes.add_order_note_nonce};return e.post(woocommerce_admin_meta_boxes.ajax_url,o,function(o){e("ul.order_notes").prepend(o),e("#woocommerce-order-notes").unblock(),e("#add_order_note").val("")}),!1}},delete_order_note:function(){if(window.confirm(woocommerce_admin_meta_boxes.i18n_delete_note)){var o=e(this).closest("li.note");e(o).block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var t={action:"woocommerce_delete_order_note",note_id:e(o).attr("rel"),security:woocommerce_admin_meta_boxes.delete_order_note_nonce};e.post(woocommerce_admin_meta_boxes.ajax_url,t,function(){e(o).remove()})}return!1}},a={init:function(){e(".order_download_permissions").on("click","button.grant_access",this.grant_access).on("click","button.revoke_access",this.revoke_access)},grant_access:function(){var o=e("#grant_access_id").val();if(o){e(".order_download_permissions").block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var t={action:"woocommerce_grant_access_to_download",product_ids:o,loop:e(".order_download_permissions .wc-metabox").length,order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.grant_access_nonce};return e.post(woocommerce_admin_meta_boxes.ajax_url,t,function(o){o?e(".order_download_permissions .wc-metaboxes").append(o):window.alert(woocommerce_admin_meta_boxes.i18n_download_permission_fail),e(document.body).trigger("wc-init-datepickers"),e("#grant_access_id").val("").change(),e(".order_download_permissions").unblock()}),!1}},revoke_access:function(){if(window.confirm(woocommerce_admin_meta_boxes.i18n_permission_revoke)){var o=e(this).parent().parent(),t=e(this).attr("rel").split(",")[0],i=e(this).attr("rel").split(",")[1],a=e(this).data("permission_id");if(t>0){e(o).block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var n={action:"woocommerce_revoke_access_to_download",product_id:t,download_id:i,permission_id:a,order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.revoke_access_nonce};e.post(woocommerce_admin_meta_boxes.ajax_url,n,function(){e(o).fadeOut("300",function(){e(o).remove()})})}else e(o).fadeOut("300",function(){e(o).remove()})}return!1}};o.init(),t.init(),i.init(),a.init()}); \ No newline at end of file +jQuery(function(e){var o={states:null,init:function(){"undefined"!=typeof woocommerce_admin_meta_boxes_order&&"undefined"!=typeof woocommerce_admin_meta_boxes_order.countries&&(this.states=e.parseJSON(woocommerce_admin_meta_boxes_order.countries.replace(/"/g,'"'))),e(".js_field-country").selectWoo().change(this.change_country),e(".js_field-country").trigger("change",[!0]),e(document.body).on("change","select.js_field-state",this.change_state),e("#woocommerce-order-actions input, #woocommerce-order-actions a").click(function(){window.onbeforeunload=""}),e("a.edit_address").click(this.edit_address),e("a.billing-same-as-shipping").on("click",this.copy_billing_to_shipping),e("a.load_customer_billing").on("click",this.load_billing),e("a.load_customer_shipping").on("click",this.load_shipping),e("#customer_user").on("change",this.change_customer_user)},change_country:function(t,i){if(void 0===i&&(i=!1),null!==o.states){var a=e(this),n=a.val(),r=a.parents("div.edit_address").find(":input.js_field-state"),c=r.parent(),d=r.attr("name"),_=r.attr("id"),m=a.data("woocommerce.stickState-"+n)?a.data("woocommerce.stickState-"+n):r.val(),s=r.attr("placeholder");if(i&&a.data("woocommerce.stickState-"+n,m),c.show().find(".select2-container").remove(),e.isEmptyObject(o.states[n]))r.replaceWith('');else{var l=e(''),u=o.states[n];l.append(e('")),e.each(u,function(o){l.append(e('"))}),l.val(m),r.replaceWith(l),l.show().selectWoo().hide().change()}e(document.body).trigger("contry-change.woocommerce",[n,e(this).closest("div")]),e(document.body).trigger("country-change.woocommerce",[n,e(this).closest("div")])}},change_state:function(){var o=e(this),t=o.val(),i=o.parents("div.edit_address").find(":input.js_field-country"),a=i.val();i.data("woocommerce.stickState-"+a,t)},init_tiptip:function(){e("#tiptip_holder").removeAttr("style"),e("#tiptip_arrow").removeAttr("style"),e(".tips").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200})},edit_address:function(o){o.preventDefault();var t=e(this),i=t.closest(".order_data_column"),a=i.find("div.edit_address"),n=i.find("div.address"),r=a.find(".js_field-country"),c=a.find(".js_field-state");n.hide(),t.parent().find("a").toggle(),r.val()||r.val(woocommerce_admin_meta_boxes_order.default_country).change(),c.val()||c.val(woocommerce_admin_meta_boxes_order.default_state).change(),a.show()},change_customer_user:function(){e("#_billing_country").val()||(e("a.edit_address").click(),o.load_billing(!0),o.load_shipping(!0))},load_billing:function(o){if(!0===o||window.confirm(woocommerce_admin_meta_boxes.load_billing)){var t=e("#customer_user").val();if(!t)return window.alert(woocommerce_admin_meta_boxes.no_customer_selected),!1;var i={user_id:t,action:"woocommerce_get_customer_details",security:woocommerce_admin_meta_boxes.get_customer_details_nonce};e(this).closest("div.edit_address").block({message:null,overlayCSS:{background:"#fff",opacity:.6}}),e.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:i,type:"POST",success:function(o){o&&o.billing&&e.each(o.billing,function(o,t){e(":input#_billing_"+o).val(t).change()}),e("div.edit_address").unblock()}})}return!1},load_shipping:function(o){if(!0===o||window.confirm(woocommerce_admin_meta_boxes.load_shipping)){var t=e("#customer_user").val();if(!t)return window.alert(woocommerce_admin_meta_boxes.no_customer_selected),!1;var i={user_id:t,action:"woocommerce_get_customer_details",security:woocommerce_admin_meta_boxes.get_customer_details_nonce};e(this).closest("div.edit_address").block({message:null,overlayCSS:{background:"#fff",opacity:.6}}),e.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:i,type:"POST",success:function(o){o&&o.billing&&e.each(o.shipping,function(o,t){e(":input#_shipping_"+o).val(t).change()}),e("div.edit_address").unblock()}})}return!1},copy_billing_to_shipping:function(){return window.confirm(woocommerce_admin_meta_boxes.copy_billing)&&e('.order_data_column :input[name^="_billing_"]').each(function(){var o=e(this).attr("name");o=o.replace("_billing_","_shipping_"),e(":input#"+o).val(e(this).val()).change()}),!1}},t={init:function(){this.stupidtable.init(),e("#woocommerce-order-items").on("click","button.add-line-item",this.add_line_item).on("click","button.add-coupon",this.add_coupon).on("click","a.remove-coupon",this.remove_coupon).on("click","button.refund-items",this.refund_items).on("click",".cancel-action",this.cancel).on("click","button.add-order-item",this.add_item).on("click","button.add-order-fee",this.add_fee).on("click","button.add-order-shipping",this.add_shipping).on("click","button.add-order-tax",this.add_tax).on("click","button.save-action",this.save_line_items).on("click","a.delete-order-tax",this.delete_tax).on("click","button.calculate-action",this.recalculate).on("click","a.edit-order-item",this.edit_item).on("click","a.delete-order-item",this.delete_item).on("click","tr.item, tr.fee, tr.shipping, tr.refund",this.select_row).on("click","tr.item :input, tr.fee :input, tr.shipping :input, tr.refund :input, tr.item a, tr.fee a, tr.shipping a, tr.refund a",this.select_row_child).on("click","button.bulk-delete-items",this.bulk_actions.do_delete).on("click","button.bulk-increase-stock",this.bulk_actions.do_increase_stock).on("click","button.bulk-decrease-stock",this.bulk_actions.do_reduce_stock).on("click",".delete_refund",this.refunds.delete_refund).on("click","button.do-api-refund, button.do-manual-refund",this.refunds.do_refund).on("change",".refund input.refund_line_total, .refund input.refund_line_tax",this.refunds.input_changed).on("change keyup",".wc-order-refund-items #refund_amount",this.refunds.amount_changed).on("change","input.refund_order_item_qty",this.refunds.refund_quantity_changed).on("change","input.quantity",this.quantity_changed).on("keyup change",".split-input :input",function(){var o=e(this).parent().prev().find(":input");o&&(""===o.val()||o.is(".match-total"))&&o.val(e(this).val()).addClass("match-total")}).on("keyup",".split-input :input",function(){e(this).removeClass("match-total")}).on("click","button.add_order_item_meta",this.item_meta.add).on("click","button.remove_order_item_meta",this.item_meta.remove),e(document.body).on("wc_backbone_modal_loaded",this.backbone.init).on("wc_backbone_modal_response",this.backbone.response)},block:function(){e("#woocommerce-order-items").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},unblock:function(){e("#woocommerce-order-items").unblock()},reload_items:function(){var i={order_id:woocommerce_admin_meta_boxes.post_id,action:"woocommerce_load_order_items",security:woocommerce_admin_meta_boxes.order_item_nonce};t.block(),e.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:i,type:"POST",success:function(i){e("#woocommerce-order-items").find(".inside").empty(),e("#woocommerce-order-items").find(".inside").append(i),o.init_tiptip(),t.unblock(),t.stupidtable.init()}})},quantity_changed:function(){var o=e(this).closest("tr.item"),t=e(this).val(),i=e(this).attr("data-qty"),a=e("input.line_total",o),n=e("input.line_subtotal",o),r=accounting.unformat(a.attr("data-total"),woocommerce_admin.mon_decimal_point)/i;a.val(parseFloat(accounting.formatNumber(r*t,woocommerce_admin_meta_boxes.rounding_precision,"")).toString().replace(".",woocommerce_admin.mon_decimal_point));var c=accounting.unformat(n.attr("data-subtotal"),woocommerce_admin.mon_decimal_point)/i;n.val(parseFloat(accounting.formatNumber(c*t,woocommerce_admin_meta_boxes.rounding_precision,"")).toString().replace(".",woocommerce_admin.mon_decimal_point)),e("input.line_tax",o).each(function(){var a=e(this),n=a.data("tax_id"),r=accounting.unformat(a.attr("data-total_tax"),woocommerce_admin.mon_decimal_point)/i,c=e('input.line_subtotal_tax[data-tax_id="'+n+'"]',o),d=accounting.unformat(c.attr("data-subtotal_tax"),woocommerce_admin.mon_decimal_point)/i;00?e("#restock_refunded_items").closest("tr").show():(e("#restock_refunded_items").closest("tr").hide(),e(".woocommerce_order_items input.refund_order_item_qty").each(function(){e(this).val()>0&&e("#restock_refunded_items").closest("tr").show()})),e(this).trigger("refund_quantity_changed")}},item_meta:{add:function(){var o=e(this).closest("tr.item, tr.shipping"),t=o.find("tbody.meta_items"),i=t.find("tr").length+1,a='';return t.append(a),!1},remove:function(){if(window.confirm(woocommerce_admin_meta_boxes.remove_item_meta)){var o=e(this).closest("tr");o.find(":input").val(""),o.hide()}return!1}},select_row:function(){var o=!1;o=e(this).is("tr")?e(this):e(this).closest("tr");var t=e(this).closest("table");o.is(".selected")?o.removeClass("selected"):o.addClass("selected");var i=t.find("tr.selected");if(i.length){e("div.wc-order-item-bulk-edit").slideDown();var a=!1;i.each(function(){e(this).is("tr.item")&&(a=!0)}),a?e(".bulk-increase-stock, .bulk-decrease-stock").show():e(".bulk-increase-stock, .bulk-decrease-stock").hide()}else e("div.wc-order-item-bulk-edit").slideUp()},select_row_child:function(e){e.stopPropagation()},bulk_actions:{do_delete:function(o){o.preventDefault();var i=e("table.woocommerce_order_items").find("tr.selected");if(i.length&&window.confirm(woocommerce_admin_meta_boxes.remove_item_notice)){t.block();var a=[],n=[],r=[];e.map(i,function(o){var t=e(o);t.is(".refund")?n.push(parseInt(e(t).data("order_refund_id"),10)):a.push(parseInt(e(t).data("order_item_id"),10))}),a.length&&r.push(e.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:{order_id:woocommerce_admin_meta_boxes.post_id,order_item_ids:a,action:"woocommerce_remove_order_item",security:woocommerce_admin_meta_boxes.order_item_nonce},type:"POST"})),n.length&&r.push(e.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:{action:"woocommerce_delete_refund",refund_id:n,security:woocommerce_admin_meta_boxes.order_item_nonce},type:"POST"})),r?e.when.apply(e,r).done(function(){t.reload_items(),t.unblock()}):t.unblock()}},do_increase_stock:function(o){o.preventDefault(),t.block();var i=e("table.woocommerce_order_items").find("tr.selected"),a={},n=e.map(i,function(o){return parseInt(e(o).data("order_item_id"),10)});i.each(function(){e(this).find("input.quantity").length&&(a[e(this).attr("data-order_item_id")]=e(this).find("input.quantity").val())});var r={order_id:woocommerce_admin_meta_boxes.post_id,order_item_ids:n,order_item_qty:a,action:"woocommerce_increase_order_item_stock",security:woocommerce_admin_meta_boxes.order_item_nonce};e.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:r,type:"POST",success:function(e){window.alert(e),t.unblock()}})},do_reduce_stock:function(o){o.preventDefault(),t.block();var i=e("table.woocommerce_order_items").find("tr.selected"),a={},n=e.map(i,function(o){return parseInt(e(o).data("order_item_id"),10)});i.each(function(){e(this).find("input.quantity").length&&(a[e(this).attr("data-order_item_id")]=e(this).find("input.quantity").val())});var r={order_id:woocommerce_admin_meta_boxes.post_id,order_item_ids:n,order_item_qty:a,action:"woocommerce_reduce_order_item_stock",security:woocommerce_admin_meta_boxes.order_item_nonce};e.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:r,type:"POST",success:function(e){window.alert(e),t.unblock()}})}},backbone:{init:function(o,t){"wc-modal-add-products"===t&&(e(document.body).trigger("wc-enhanced-select-init"),e("#add_item_id").selectWoo("open").selectWoo("focus"))},response:function(e,o,i){if("wc-modal-add-tax"===o){var a=i.add_order_tax,n="";i.manual_tax_rate_id&&(n=i.manual_tax_rate_id),t.backbone.add_tax(a,n)}"wc-modal-add-products"===o&&t.backbone.add_item(i.add_order_items)},add_item:function(i){if(i){t.block();var a={action:"woocommerce_add_order_item",item_to_add:i,dataType:"json",order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.order_item_nonce,data:e("#wc-backbone-modal-dialog form").serialize()};"true"===e("button.cancel-action").attr("data-reload")&&(a.items=e("table.woocommerce_order_items :input[name], .wc-order-totals-items :input[name]").serialize()),e.post(woocommerce_admin_meta_boxes.ajax_url,a,function(i){i.success?(e("#woocommerce-order-items").find(".inside").empty(),e("#woocommerce-order-items").find(".inside").append(i.data.html),o.init_tiptip(),t.stupidtable.init()):window.alert(i.data.error),t.unblock()})}},add_tax:function(i,a){if(a&&(i=a),!i)return!1;var n=e(".order-tax-id").map(function(){return e(this).val()}).get();if(-1===e.inArray(i,n)){t.block();var r={action:"woocommerce_add_order_tax",rate_id:i,order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.order_item_nonce};e.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:r,dataType:"json",type:"POST",success:function(i){i.success?(e("#woocommerce-order-items").find(".inside").empty(),e("#woocommerce-order-items").find(".inside").append(i.data.html),o.init_tiptip(),t.stupidtable.init()):window.alert(i.data.error),t.unblock()}})}else window.alert(woocommerce_admin_meta_boxes.i18n_tax_rate_already_exists)}},stupidtable:{init:function(){e(".woocommerce_order_items").stupidtable(),e(".woocommerce_order_items").on("aftertablesort",this.add_arrows)},add_arrows:function(o,t){var i=e(this).find("th"),a="asc"===t.direction?"↑":"↓",n=t.column;i.find(".wc-arrow").remove(),i.eq(n).append(''+a+"")}}},i={init:function(){e("#woocommerce-order-notes").on("click","button.add_note",this.add_order_note).on("click","a.delete_note",this.delete_order_note)},add_order_note:function(){if(e("textarea#add_order_note").val()){e("#woocommerce-order-notes").block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var o={action:"woocommerce_add_order_note",post_id:woocommerce_admin_meta_boxes.post_id,note:e("textarea#add_order_note").val(),note_type:e("select#order_note_type").val(),security:woocommerce_admin_meta_boxes.add_order_note_nonce};return e.post(woocommerce_admin_meta_boxes.ajax_url,o,function(o){e("ul.order_notes").prepend(o),e("#woocommerce-order-notes").unblock(),e("#add_order_note").val("")}),!1}},delete_order_note:function(){if(window.confirm(woocommerce_admin_meta_boxes.i18n_delete_note)){var o=e(this).closest("li.note");e(o).block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var t={action:"woocommerce_delete_order_note",note_id:e(o).attr("rel"),security:woocommerce_admin_meta_boxes.delete_order_note_nonce};e.post(woocommerce_admin_meta_boxes.ajax_url,t,function(){e(o).remove()})}return!1}},a={init:function(){e(".order_download_permissions").on("click","button.grant_access",this.grant_access).on("click","button.revoke_access",this.revoke_access)},grant_access:function(){var o=e("#grant_access_id").val();if(o){e(".order_download_permissions").block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var t={action:"woocommerce_grant_access_to_download",product_ids:o,loop:e(".order_download_permissions .wc-metabox").length,order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.grant_access_nonce};return e.post(woocommerce_admin_meta_boxes.ajax_url,t,function(o){o?e(".order_download_permissions .wc-metaboxes").append(o):window.alert(woocommerce_admin_meta_boxes.i18n_download_permission_fail),e(document.body).trigger("wc-init-datepickers"),e("#grant_access_id").val("").change(),e(".order_download_permissions").unblock()}),!1}},revoke_access:function(){if(window.confirm(woocommerce_admin_meta_boxes.i18n_permission_revoke)){var o=e(this).parent().parent(),t=e(this).attr("rel").split(",")[0],i=e(this).attr("rel").split(",")[1],a=e(this).data("permission_id");if(t>0){e(o).block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var n={action:"woocommerce_revoke_access_to_download",product_id:t,download_id:i,permission_id:a,order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.revoke_access_nonce};e.post(woocommerce_admin_meta_boxes.ajax_url,n,function(){e(o).fadeOut("300",function(){e(o).remove()})})}else e(o).fadeOut("300",function(){e(o).remove()})}return!1}};o.init(),t.init(),i.init(),a.init()}); \ No newline at end of file diff --git a/assets/js/admin/meta-boxes-product.js b/assets/js/admin/meta-boxes-product.js index 7707a66c723..19738652fd3 100644 --- a/assets/js/admin/meta-boxes-product.js +++ b/assets/js/admin/meta-boxes-product.js @@ -232,8 +232,10 @@ jQuery( function( $ ) { $( 'input#_manage_stock' ).change( function() { if ( $( this ).is( ':checked' ) ) { $( 'div.stock_fields' ).show(); + $( 'p.stock_status_field' ).hide(); } else { $( 'div.stock_fields' ).hide(); + $( 'p.stock_status_field' ).show(); } }).change(); diff --git a/assets/js/admin/meta-boxes-product.min.js b/assets/js/admin/meta-boxes-product.min.js index 55074c0cd58..c5d34654168 100644 --- a/assets/js/admin/meta-boxes-product.min.js +++ b/assets/js/admin/meta-boxes-product.min.js @@ -1 +1 @@ -jQuery(function(t){function e(){var e=t("select#product-type").val(),i=t("input#_virtual:checked").length,o=t("input#_downloadable:checked").length,a=".hide_if_downloadable, .hide_if_virtual",c=".show_if_downloadable, .show_if_virtual";t.each(woocommerce_admin_meta_boxes.product_types,function(t,e){a=a+", .hide_if_"+e,c=c+", .show_if_"+e}),t(a).show(),t(c).hide(),o&&t(".show_if_downloadable").show(),i&&t(".show_if_virtual").show(),t(".show_if_"+e).show(),o&&t(".hide_if_downloadable").hide(),i&&t(".hide_if_virtual").hide(),t(".hide_if_"+e).hide(),t("input#_manage_stock").change(),t(".woocommerce_options_panel").each(function(){var e=t(this).children(".options_group");if(0!==e.length&&e.filter(function(){return"none"===t(this).css("display")}).length===e.length){var i=t(this).prop("id");t(".product_data_tabs").find('li a[href="#'+i+'"]').parent().hide()}})}function i(e){var i=t(e).next().is(".hasDatepicker")?"minDate":"maxDate",o="minDate"===i?t(e).next():t(e).prev(),a=t(e).datepicker("getDate");t(o).datepicker("option",i,a),t(e).change()}function o(){t(".product_attributes .woocommerce_attribute").each(function(e,i){t(".attribute_position",i).val(parseInt(t(i).index(".product_attributes .woocommerce_attribute"),10))})}t(function(){t('[id$="-all"] > ul.categorychecklist').each(function(){var e=t(this),i=e.find(":checked").first();if(i.length){var o=e.find("input").position().top,a=i.position().top;e.closest(".tabs-panel").scrollTop(a-o+5)}})}),t("#upsell_product_data").bind("keypress",function(t){if(13===t.keyCode)return!1}),t(".type_box").appendTo("#woocommerce-product-data .hndle span"),t(function(){t("#woocommerce-product-data").find(".hndle").unbind("click.postboxes"),t("#woocommerce-product-data").on("click",".hndle",function(e){t(e.target).filter("input, option, label, select").length||t("#woocommerce-product-data").toggleClass("closed")})}),t("#catalog-visibility").find(".edit-catalog-visibility").click(function(){return t("#catalog-visibility-select").is(":hidden")&&(t("#catalog-visibility-select").slideDown("fast"),t(this).hide()),!1}),t("#catalog-visibility").find(".save-post-visibility").click(function(){t("#catalog-visibility-select").slideUp("fast"),t("#catalog-visibility").find(".edit-catalog-visibility").show();var e=t("input[name=_visibility]:checked").attr("data-label");return t("input[name=_featured]").is(":checked")&&(e=e+", "+woocommerce_admin_meta_boxes.featured_label,t("input[name=_featured]").attr("checked","checked")),t("#catalog-visibility-display").text(e),!1}),t("#catalog-visibility").find(".cancel-post-visibility").click(function(){t("#catalog-visibility-select").slideUp("fast"),t("#catalog-visibility").find(".edit-catalog-visibility").show();var e=t("#current_visibility").val(),i=t("#current_featured").val();t("input[name=_visibility]").removeAttr("checked"),t("input[name=_visibility][value="+e+"]").attr("checked","checked");var o=t("input[name=_visibility]:checked").attr("data-label");return"yes"===i?(o=o+", "+woocommerce_admin_meta_boxes.featured_label,t("input[name=_featured]").attr("checked","checked")):t("input[name=_featured]").removeAttr("checked"),t("#catalog-visibility-display").text(o),!1}),t("select#product-type").change(function(){var i=t(this).val();"variable"===i?(t("input#_manage_stock").change(),t("input#_downloadable").prop("checked",!1),t("input#_virtual").removeAttr("checked")):"grouped"===i?(t("input#_downloadable").prop("checked",!1),t("input#_virtual").removeAttr("checked")):"external"===i&&(t("input#_downloadable").prop("checked",!1),t("input#_virtual").removeAttr("checked")),e(),t("ul.wc-tabs li:visible").eq(0).find("a").click(),t(document.body).trigger("woocommerce-product-type-change",i,t(this))}).change(),t("input#_downloadable, input#_virtual").change(function(){e()}),t(".sale_price_dates_fields").each(function(){var e=t(this),i=!1,o=e.closest("div, table");e.find("input").each(function(){""!==t(this).val()&&(i=!0)}),i?(o.find(".sale_schedule").hide(),o.find(".sale_price_dates_fields").show()):(o.find(".sale_schedule").show(),o.find(".sale_price_dates_fields").hide())}),t("#woocommerce-product-data").on("click",".sale_schedule",function(){var e=t(this).closest("div, table");return t(this).hide(),e.find(".cancel_sale_schedule").show(),e.find(".sale_price_dates_fields").show(),!1}),t("#woocommerce-product-data").on("click",".cancel_sale_schedule",function(){var e=t(this).closest("div, table");return t(this).hide(),e.find(".sale_schedule").show(),e.find(".sale_price_dates_fields").hide(),e.find(".sale_price_dates_fields").find("input").val(""),!1}),t("#woocommerce-product-data").on("click",".downloadable_files a.insert",function(){return t(this).closest(".downloadable_files").find("tbody").append(t(this).data("row")),!1}),t("#woocommerce-product-data").on("click",".downloadable_files a.delete",function(){return t(this).closest("tr").remove(),!1}),t("input#_manage_stock").change(function(){t(this).is(":checked")?t("div.stock_fields").show():t("div.stock_fields").hide()}).change(),t(".sale_price_dates_fields").each(function(){t(this).find("input").datepicker({defaultDate:"",dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:!0,onSelect:function(){i(t(this))}}),t(this).find("input").each(function(){i(t(this))})});var a=t(".product_attributes").find(".woocommerce_attribute").get();a.sort(function(e,i){var o=parseInt(t(e).attr("rel"),10),a=parseInt(t(i).attr("rel"),10);return oa?1:0}),t(a).each(function(e,i){t(".product_attributes").append(i)}),t(".product_attributes .woocommerce_attribute").each(function(e,i){"none"!==t(i).css("display")&&t(i).is(".taxonomy")&&t("select.attribute_taxonomy").find('option[value="'+t(i).data("taxonomy")+'"]').attr("disabled","disabled")}),t("button.add_attribute").on("click",function(){var e=t(".product_attributes .woocommerce_attribute").length,i=t("select.attribute_taxonomy").val(),a=t(this).closest("#product_attributes"),c=a.find(".product_attributes"),n=t("select#product-type").val(),r={action:"woocommerce_add_attribute",taxonomy:i,i:e,security:woocommerce_admin_meta_boxes.add_attribute_nonce};return a.block({message:null,overlayCSS:{background:"#fff",opacity:.6}}),t.post(woocommerce_admin_meta_boxes.ajax_url,r,function(e){c.append(e),"variable"!==n&&c.find(".enable_variation").hide(),t(document.body).trigger("wc-enhanced-select-init"),o(),a.unblock(),t(document.body).trigger("woocommerce_added_attribute")}),i&&(t("select.attribute_taxonomy").find('option[value="'+i+'"]').attr("disabled","disabled"),t("select.attribute_taxonomy").val("")),!1}),t(".product_attributes").on("blur","input.attribute_name",function(){t(this).closest(".woocommerce_attribute").find("strong.attribute_name").text(t(this).val())}),t(".product_attributes").on("click","button.select_all_attributes",function(){return t(this).closest("td").find("select option").attr("selected","selected"),t(this).closest("td").find("select").change(),!1}),t(".product_attributes").on("click","button.select_no_attributes",function(){return t(this).closest("td").find("select option").removeAttr("selected"),t(this).closest("td").find("select").change(),!1}),t(".product_attributes").on("click",".remove_row",function(){if(window.confirm(woocommerce_admin_meta_boxes.remove_attribute)){var e=t(this).parent().parent();e.is(".taxonomy")?(e.find("select, input[type=text]").val(""),e.hide(),t("select.attribute_taxonomy").find('option[value="'+e.data("taxonomy")+'"]').removeAttr("disabled")):(e.find("select, input[type=text]").val(""),e.hide(),o())}return!1}),t(".product_attributes").sortable({items:".woocommerce_attribute",cursor:"move",axis:"y",handle:"h3",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65,placeholder:"wc-metabox-sortable-placeholder",start:function(t,e){e.item.css("background-color","#f6f6f6")},stop:function(t,e){e.item.removeAttr("style"),o()}}),t(".product_attributes").on("click","button.add_new_attribute",function(){t(".product_attributes").block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var e=t(this).closest(".woocommerce_attribute"),i=e.data("taxonomy"),o=window.prompt(woocommerce_admin_meta_boxes.new_attribute_prompt);if(o){var a={action:"woocommerce_add_new_attribute",taxonomy:i,term:o,security:woocommerce_admin_meta_boxes.add_attribute_nonce};t.post(woocommerce_admin_meta_boxes.ajax_url,a,function(i){i.error?window.alert(i.error):i.slug&&(e.find("select.attribute_values").append('"),e.find("select.attribute_values").change()),t(".product_attributes").unblock()})}else t(".product_attributes").unblock();return!1}),t(".save_attributes").on("click",function(){t("#woocommerce-product-data").block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var e={post_id:woocommerce_admin_meta_boxes.post_id,product_type:t("#product-type").val(),data:t(".product_attributes").find("input, select, textarea").serialize(),action:"woocommerce_save_attributes",security:woocommerce_admin_meta_boxes.save_attributes_nonce};t.post(woocommerce_admin_meta_boxes.ajax_url,e,function(){var e=window.location.toString();e=e.replace("post-new.php?","post.php?post="+woocommerce_admin_meta_boxes.post_id+"&action=edit&"),t("#variable_product_options").load(e+" #variable_product_options_inner",function(){t("#variable_product_options").trigger("reload")})})});var c,n;t(document.body).on("click",".upload_file_button",function(e){var i=t(this);if(n=i.closest("tr").find("td.file_url input"),e.preventDefault(),c)c.open();else{var o=[new wp.media.controller.Library({library:wp.media.query(),multiple:!0,title:i.data("choose"),priority:20,filterable:"uploaded"})];(c=wp.media.frames.downloadable_file=wp.media({title:i.data("choose"),library:{type:""},button:{text:i.data("update")},multiple:!0,states:o})).on("select",function(){var t="";c.state().get("selection").map(function(e){(e=e.toJSON()).url&&(t=e.url)}),n.val(t).change()}),c.on("ready",function(){c.uploader.options.uploader.params={type:"downloadable_product"}}),c.open()}}),t(".downloadable_files tbody").sortable({items:"tr",cursor:"move",axis:"y",handle:"td.sort",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65});var r,l=t("#product_image_gallery"),d=t("#product_images_container").find("ul.product_images");t(".add_product_images").on("click","a",function(e){var i=t(this);e.preventDefault(),r?r.open():((r=wp.media.frames.product_gallery=wp.media({title:i.data("choose"),button:{text:i.data("update")},states:[new wp.media.controller.Library({title:i.data("choose"),filterable:"all",multiple:!0})]})).on("select",function(){var t=r.state().get("selection"),e=l.val();t.map(function(t){if((t=t.toJSON()).id){e=e?e+","+t.id:t.id;var o=t.sizes&&t.sizes.thumbnail?t.sizes.thumbnail.url:t.url;d.append('
  • ")}}),l.val(e)}),r.open())}),d.sortable({items:"li.image",cursor:"move",scrollSensitivity:40,forcePlaceholderSize:!0,forceHelperSize:!1,helper:"clone",opacity:.65,placeholder:"wc-metabox-sortable-placeholder",start:function(t,e){e.item.css("background-color","#f6f6f6")},stop:function(t,e){e.item.removeAttr("style")},update:function(){var e="";t("#product_images_container").find("ul li.image").css("cursor","default").each(function(){var i=t(this).attr("data-attachment_id");e=e+i+","}),l.val(e)}}),t("#product_images_container").on("click","a.delete",function(){t(this).closest("li.image").remove();var e="";return t("#product_images_container").find("ul li.image").css("cursor","default").each(function(){var i=t(this).attr("data-attachment_id");e=e+i+","}),l.val(e),t("#tiptip_holder").removeAttr("style"),t("#tiptip_arrow").removeAttr("style"),!1})}); \ No newline at end of file +jQuery(function(t){function e(){var e=t("select#product-type").val(),i=t("input#_virtual:checked").length,o=t("input#_downloadable:checked").length,a=".hide_if_downloadable, .hide_if_virtual",c=".show_if_downloadable, .show_if_virtual";t.each(woocommerce_admin_meta_boxes.product_types,function(t,e){a=a+", .hide_if_"+e,c=c+", .show_if_"+e}),t(a).show(),t(c).hide(),o&&t(".show_if_downloadable").show(),i&&t(".show_if_virtual").show(),t(".show_if_"+e).show(),o&&t(".hide_if_downloadable").hide(),i&&t(".hide_if_virtual").hide(),t(".hide_if_"+e).hide(),t("input#_manage_stock").change(),t(".woocommerce_options_panel").each(function(){var e=t(this).children(".options_group");if(0!==e.length&&e.filter(function(){return"none"===t(this).css("display")}).length===e.length){var i=t(this).prop("id");t(".product_data_tabs").find('li a[href="#'+i+'"]').parent().hide()}})}function i(e){var i=t(e).next().is(".hasDatepicker")?"minDate":"maxDate",o="minDate"===i?t(e).next():t(e).prev(),a=t(e).datepicker("getDate");t(o).datepicker("option",i,a),t(e).change()}function o(){t(".product_attributes .woocommerce_attribute").each(function(e,i){t(".attribute_position",i).val(parseInt(t(i).index(".product_attributes .woocommerce_attribute"),10))})}t(function(){t('[id$="-all"] > ul.categorychecklist').each(function(){var e=t(this),i=e.find(":checked").first();if(i.length){var o=e.find("input").position().top,a=i.position().top;e.closest(".tabs-panel").scrollTop(a-o+5)}})}),t("#upsell_product_data").bind("keypress",function(t){if(13===t.keyCode)return!1}),t(".type_box").appendTo("#woocommerce-product-data .hndle span"),t(function(){t("#woocommerce-product-data").find(".hndle").unbind("click.postboxes"),t("#woocommerce-product-data").on("click",".hndle",function(e){t(e.target).filter("input, option, label, select").length||t("#woocommerce-product-data").toggleClass("closed")})}),t("#catalog-visibility").find(".edit-catalog-visibility").click(function(){return t("#catalog-visibility-select").is(":hidden")&&(t("#catalog-visibility-select").slideDown("fast"),t(this).hide()),!1}),t("#catalog-visibility").find(".save-post-visibility").click(function(){t("#catalog-visibility-select").slideUp("fast"),t("#catalog-visibility").find(".edit-catalog-visibility").show();var e=t("input[name=_visibility]:checked").attr("data-label");return t("input[name=_featured]").is(":checked")&&(e=e+", "+woocommerce_admin_meta_boxes.featured_label,t("input[name=_featured]").attr("checked","checked")),t("#catalog-visibility-display").text(e),!1}),t("#catalog-visibility").find(".cancel-post-visibility").click(function(){t("#catalog-visibility-select").slideUp("fast"),t("#catalog-visibility").find(".edit-catalog-visibility").show();var e=t("#current_visibility").val(),i=t("#current_featured").val();t("input[name=_visibility]").removeAttr("checked"),t("input[name=_visibility][value="+e+"]").attr("checked","checked");var o=t("input[name=_visibility]:checked").attr("data-label");return"yes"===i?(o=o+", "+woocommerce_admin_meta_boxes.featured_label,t("input[name=_featured]").attr("checked","checked")):t("input[name=_featured]").removeAttr("checked"),t("#catalog-visibility-display").text(o),!1}),t("select#product-type").change(function(){var i=t(this).val();"variable"===i?(t("input#_manage_stock").change(),t("input#_downloadable").prop("checked",!1),t("input#_virtual").removeAttr("checked")):"grouped"===i?(t("input#_downloadable").prop("checked",!1),t("input#_virtual").removeAttr("checked")):"external"===i&&(t("input#_downloadable").prop("checked",!1),t("input#_virtual").removeAttr("checked")),e(),t("ul.wc-tabs li:visible").eq(0).find("a").click(),t(document.body).trigger("woocommerce-product-type-change",i,t(this))}).change(),t("input#_downloadable, input#_virtual").change(function(){e()}),t(".sale_price_dates_fields").each(function(){var e=t(this),i=!1,o=e.closest("div, table");e.find("input").each(function(){""!==t(this).val()&&(i=!0)}),i?(o.find(".sale_schedule").hide(),o.find(".sale_price_dates_fields").show()):(o.find(".sale_schedule").show(),o.find(".sale_price_dates_fields").hide())}),t("#woocommerce-product-data").on("click",".sale_schedule",function(){var e=t(this).closest("div, table");return t(this).hide(),e.find(".cancel_sale_schedule").show(),e.find(".sale_price_dates_fields").show(),!1}),t("#woocommerce-product-data").on("click",".cancel_sale_schedule",function(){var e=t(this).closest("div, table");return t(this).hide(),e.find(".sale_schedule").show(),e.find(".sale_price_dates_fields").hide(),e.find(".sale_price_dates_fields").find("input").val(""),!1}),t("#woocommerce-product-data").on("click",".downloadable_files a.insert",function(){return t(this).closest(".downloadable_files").find("tbody").append(t(this).data("row")),!1}),t("#woocommerce-product-data").on("click",".downloadable_files a.delete",function(){return t(this).closest("tr").remove(),!1}),t("input#_manage_stock").change(function(){t(this).is(":checked")?(t("div.stock_fields").show(),t("p.stock_status_field").hide()):(t("div.stock_fields").hide(),t("p.stock_status_field").show())}).change(),t(".sale_price_dates_fields").each(function(){t(this).find("input").datepicker({defaultDate:"",dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:!0,onSelect:function(){i(t(this))}}),t(this).find("input").each(function(){i(t(this))})});var a=t(".product_attributes").find(".woocommerce_attribute").get();a.sort(function(e,i){var o=parseInt(t(e).attr("rel"),10),a=parseInt(t(i).attr("rel"),10);return oa?1:0}),t(a).each(function(e,i){t(".product_attributes").append(i)}),t(".product_attributes .woocommerce_attribute").each(function(e,i){"none"!==t(i).css("display")&&t(i).is(".taxonomy")&&t("select.attribute_taxonomy").find('option[value="'+t(i).data("taxonomy")+'"]').attr("disabled","disabled")}),t("button.add_attribute").on("click",function(){var e=t(".product_attributes .woocommerce_attribute").length,i=t("select.attribute_taxonomy").val(),a=t(this).closest("#product_attributes"),c=a.find(".product_attributes"),n=t("select#product-type").val(),r={action:"woocommerce_add_attribute",taxonomy:i,i:e,security:woocommerce_admin_meta_boxes.add_attribute_nonce};return a.block({message:null,overlayCSS:{background:"#fff",opacity:.6}}),t.post(woocommerce_admin_meta_boxes.ajax_url,r,function(e){c.append(e),"variable"!==n&&c.find(".enable_variation").hide(),t(document.body).trigger("wc-enhanced-select-init"),o(),a.unblock(),t(document.body).trigger("woocommerce_added_attribute")}),i&&(t("select.attribute_taxonomy").find('option[value="'+i+'"]').attr("disabled","disabled"),t("select.attribute_taxonomy").val("")),!1}),t(".product_attributes").on("blur","input.attribute_name",function(){t(this).closest(".woocommerce_attribute").find("strong.attribute_name").text(t(this).val())}),t(".product_attributes").on("click","button.select_all_attributes",function(){return t(this).closest("td").find("select option").attr("selected","selected"),t(this).closest("td").find("select").change(),!1}),t(".product_attributes").on("click","button.select_no_attributes",function(){return t(this).closest("td").find("select option").removeAttr("selected"),t(this).closest("td").find("select").change(),!1}),t(".product_attributes").on("click",".remove_row",function(){if(window.confirm(woocommerce_admin_meta_boxes.remove_attribute)){var e=t(this).parent().parent();e.is(".taxonomy")?(e.find("select, input[type=text]").val(""),e.hide(),t("select.attribute_taxonomy").find('option[value="'+e.data("taxonomy")+'"]').removeAttr("disabled")):(e.find("select, input[type=text]").val(""),e.hide(),o())}return!1}),t(".product_attributes").sortable({items:".woocommerce_attribute",cursor:"move",axis:"y",handle:"h3",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65,placeholder:"wc-metabox-sortable-placeholder",start:function(t,e){e.item.css("background-color","#f6f6f6")},stop:function(t,e){e.item.removeAttr("style"),o()}}),t(".product_attributes").on("click","button.add_new_attribute",function(){t(".product_attributes").block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var e=t(this).closest(".woocommerce_attribute"),i=e.data("taxonomy"),o=window.prompt(woocommerce_admin_meta_boxes.new_attribute_prompt);if(o){var a={action:"woocommerce_add_new_attribute",taxonomy:i,term:o,security:woocommerce_admin_meta_boxes.add_attribute_nonce};t.post(woocommerce_admin_meta_boxes.ajax_url,a,function(i){i.error?window.alert(i.error):i.slug&&(e.find("select.attribute_values").append('"),e.find("select.attribute_values").change()),t(".product_attributes").unblock()})}else t(".product_attributes").unblock();return!1}),t(".save_attributes").on("click",function(){t("#woocommerce-product-data").block({message:null,overlayCSS:{background:"#fff",opacity:.6}});var e={post_id:woocommerce_admin_meta_boxes.post_id,product_type:t("#product-type").val(),data:t(".product_attributes").find("input, select, textarea").serialize(),action:"woocommerce_save_attributes",security:woocommerce_admin_meta_boxes.save_attributes_nonce};t.post(woocommerce_admin_meta_boxes.ajax_url,e,function(){var e=window.location.toString();e=e.replace("post-new.php?","post.php?post="+woocommerce_admin_meta_boxes.post_id+"&action=edit&"),t("#variable_product_options").load(e+" #variable_product_options_inner",function(){t("#variable_product_options").trigger("reload")})})});var c,n;t(document.body).on("click",".upload_file_button",function(e){var i=t(this);if(n=i.closest("tr").find("td.file_url input"),e.preventDefault(),c)c.open();else{var o=[new wp.media.controller.Library({library:wp.media.query(),multiple:!0,title:i.data("choose"),priority:20,filterable:"uploaded"})];(c=wp.media.frames.downloadable_file=wp.media({title:i.data("choose"),library:{type:""},button:{text:i.data("update")},multiple:!0,states:o})).on("select",function(){var t="";c.state().get("selection").map(function(e){(e=e.toJSON()).url&&(t=e.url)}),n.val(t).change()}),c.on("ready",function(){c.uploader.options.uploader.params={type:"downloadable_product"}}),c.open()}}),t(".downloadable_files tbody").sortable({items:"tr",cursor:"move",axis:"y",handle:"td.sort",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65});var r,l=t("#product_image_gallery"),s=t("#product_images_container").find("ul.product_images");t(".add_product_images").on("click","a",function(e){var i=t(this);e.preventDefault(),r?r.open():((r=wp.media.frames.product_gallery=wp.media({title:i.data("choose"),button:{text:i.data("update")},states:[new wp.media.controller.Library({title:i.data("choose"),filterable:"all",multiple:!0})]})).on("select",function(){var t=r.state().get("selection"),e=l.val();t.map(function(t){if((t=t.toJSON()).id){e=e?e+","+t.id:t.id;var o=t.sizes&&t.sizes.thumbnail?t.sizes.thumbnail.url:t.url;s.append('
  • ")}}),l.val(e)}),r.open())}),s.sortable({items:"li.image",cursor:"move",scrollSensitivity:40,forcePlaceholderSize:!0,forceHelperSize:!1,helper:"clone",opacity:.65,placeholder:"wc-metabox-sortable-placeholder",start:function(t,e){e.item.css("background-color","#f6f6f6")},stop:function(t,e){e.item.removeAttr("style")},update:function(){var e="";t("#product_images_container").find("ul li.image").css("cursor","default").each(function(){var i=t(this).attr("data-attachment_id");e=e+i+","}),l.val(e)}}),t("#product_images_container").on("click","a.delete",function(){t(this).closest("li.image").remove();var e="";return t("#product_images_container").find("ul li.image").css("cursor","default").each(function(){var i=t(this).attr("data-attachment_id");e=e+i+","}),l.val(e),t("#tiptip_holder").removeAttr("style"),t("#tiptip_arrow").removeAttr("style"),!1})}); \ No newline at end of file diff --git a/assets/js/admin/quick-edit.js b/assets/js/admin/quick-edit.js index c8fea5e38cd..b125e5c9fc1 100644 --- a/assets/js/admin/quick-edit.js +++ b/assets/js/admin/quick-edit.js @@ -60,10 +60,12 @@ jQuery(function( $ ) { } if ( 'yes' === manage_stock ) { - $( '.stock_qty_field', '.inline-edit-row' ).show().removeAttr( 'style' ); + $( '.stock_qty_field, .backorder_field', '.inline-edit-row' ).show().removeAttr( 'style' ); + $( '.stock_status_field' ).hide(); $( 'input[name="_manage_stock"]', '.inline-edit-row' ).attr( 'checked', 'checked' ); } else { - $( '.stock_qty_field', '.inline-edit-row' ).hide(); + $( '.stock_qty_field, .backorder_field', '.inline-edit-row' ).hide(); + $( '.stock_status_field' ).show().removeAttr( 'style' ); $( 'input[name="_manage_stock"]', '.inline-edit-row' ).removeAttr( 'checked' ); } @@ -96,9 +98,11 @@ jQuery(function( $ ) { $( '#the-list' ).on( 'change', '.inline-edit-row input[name="_manage_stock"]', function() { if ( $( this ).is( ':checked' ) ) { - $( '.stock_qty_field', '.inline-edit-row' ).show().removeAttr( 'style' ); + $( '.stock_qty_field, .backorder_field', '.inline-edit-row' ).show().removeAttr( 'style' ); + $( '.stock_status_field' ).hide(); } else { - $( '.stock_qty_field', '.inline-edit-row' ).hide(); + $( '.stock_qty_field, .backorder_field', '.inline-edit-row' ).hide(); + $( '.stock_status_field' ).show().removeAttr( 'style' ); } }); diff --git a/assets/js/admin/quick-edit.min.js b/assets/js/admin/quick-edit.min.js index e9f47e3b04d..1809047f3b6 100644 --- a/assets/js/admin/quick-edit.min.js +++ b/assets/js/admin/quick-edit.min.js @@ -1 +1 @@ -jQuery(function(e){e("#the-list").on("click",".editinline",function(){inlineEditPost.revert();var t=e(this).closest("tr").attr("id");t=t.replace("post-","");var i=e("#woocommerce_inline_"+t),n=i.find(".sku").text(),o=i.find(".regular_price").text(),l=i.find(".sale_price ").text(),d=i.find(".weight").text(),s=i.find(".length").text(),c=i.find(".width").text(),a=i.find(".height").text(),r=i.find(".shipping_class").text(),_=i.find(".visibility").text(),m=i.find(".stock_status").text(),p=i.find(".stock").text(),u=i.find(".featured").text(),w=i.find(".manage_stock").text(),h=i.find(".menu_order").text(),f=i.find(".tax_status").text(),v=i.find(".tax_class").text(),k=i.find(".backorders").text(),x=o.replace(".",woocommerce_admin.mon_decimal_point),g=l.replace(".",woocommerce_admin.mon_decimal_point);e('input[name="_sku"]',".inline-edit-row").val(n),e('input[name="_regular_price"]',".inline-edit-row").val(x),e('input[name="_sale_price"]',".inline-edit-row").val(g),e('input[name="_weight"]',".inline-edit-row").val(d),e('input[name="_length"]',".inline-edit-row").val(s),e('input[name="_width"]',".inline-edit-row").val(c),e('input[name="_height"]',".inline-edit-row").val(a),e('select[name="_shipping_class"] option:selected',".inline-edit-row").attr("selected",!1).change(),e('select[name="_shipping_class"] option[value="'+r+'"]').attr("selected","selected").change(),e('input[name="_stock"]',".inline-edit-row").val(p),e('input[name="menu_order"]',".inline-edit-row").val(h),e('select[name="_tax_status"] option, select[name="_tax_class"] option, select[name="_visibility"] option, select[name="_stock_status"] option, select[name="_backorders"] option').removeAttr("selected"),e('select[name="_tax_status"] option[value="'+f+'"]',".inline-edit-row").attr("selected","selected"),e('select[name="_tax_class"] option[value="'+v+'"]',".inline-edit-row").attr("selected","selected"),e('select[name="_visibility"] option[value="'+_+'"]',".inline-edit-row").attr("selected","selected"),e('select[name="_stock_status"] option[value="'+m+'"]',".inline-edit-row").attr("selected","selected"),e('select[name="_backorders"] option[value="'+k+'"]',".inline-edit-row").attr("selected","selected"),"yes"===u?e('input[name="_featured"]',".inline-edit-row").attr("checked","checked"):e('input[name="_featured"]',".inline-edit-row").removeAttr("checked"),"yes"===w?(e(".stock_qty_field",".inline-edit-row").show().removeAttr("style"),e('input[name="_manage_stock"]',".inline-edit-row").attr("checked","checked")):(e(".stock_qty_field",".inline-edit-row").hide(),e('input[name="_manage_stock"]',".inline-edit-row").removeAttr("checked"));var y=i.find(".product_type").text(),b=i.find(".product_is_virtual").text();"simple"===y||"external"===y?e(".price_fields",".inline-edit-row").show().removeAttr("style"):e(".price_fields",".inline-edit-row").hide(),"yes"===b?e(".dimension_fields",".inline-edit-row").hide():e(".dimension_fields",".inline-edit-row").show().removeAttr("style"),"grouped"===y?e(".stock_fields",".inline-edit-row").hide():e(".stock_fields",".inline-edit-row").show().removeAttr("style"),e('input[name="comment_status"]').parent().find(".checkbox-title").text(woocommerce_quick_edit.strings.allow_reviews)}),e("#the-list").on("change",'.inline-edit-row input[name="_manage_stock"]',function(){e(this).is(":checked")?e(".stock_qty_field",".inline-edit-row").show().removeAttr("style"):e(".stock_qty_field",".inline-edit-row").hide()}),e("#wpbody").on("click","#doaction, #doaction2",function(){e("input.text",".inline-edit-row").val(""),e("#woocommerce-fields").find("select").prop("selectedIndex",0),e("#woocommerce-fields-bulk").find(".inline-edit-group .change-input").hide()}),e("#wpbody").on("change","#woocommerce-fields-bulk .inline-edit-group .change_to",function(){00&&n(s,t(".cart-empty").closest(".woocommerce"))}else t(".woocommerce-checkout").length&&t(document.body).trigger("update_checkout"),t(".woocommerce-cart-form").replaceWith(i),t(".woocommerce-cart-form").find('input[name="update_cart"]').prop("disabled",!0),s.length>0&&n(s),a(r);t(document.body).trigger("updated_wc_div")}else window.location.href=window.location.href},a=function(e){t(".cart_totals").replaceWith(e),t(document.body).trigger("updated_cart_totals")},n=function(e,o){o||(o=t(".woocommerce-cart-form")),o.before(e)},s={init:function(e){this.cart=e,this.toggle_shipping=this.toggle_shipping.bind(this),this.shipping_method_selected=this.shipping_method_selected.bind(this),this.shipping_calculator_submit=this.shipping_calculator_submit.bind(this),t(document).on("click",".shipping-calculator-button",this.toggle_shipping),t(document).on("change","select.shipping_method, input[name^=shipping_method]",this.shipping_method_selected),t(document).on("submit","form.woocommerce-shipping-calculator",this.shipping_calculator_submit),t(".shipping-calculator-form").hide()},toggle_shipping:function(){return t(".shipping-calculator-form").slideToggle("slow"),t(document.body).trigger("country_to_state_changed"),!1},shipping_method_selected:function(o){var r=o.currentTarget,n={};t("select.shipping_method, input[name^=shipping_method][type=radio]:checked, input[name^=shipping_method][type=hidden]").each(function(){n[t(r).data("index")]=t(r).val()}),c(t("div.cart_totals"));var s={security:wc_cart_params.update_shipping_method_nonce,shipping_method:n};t.ajax({type:"post",url:e("update_shipping_method"),data:s,dataType:"html",success:function(t){a(t)},complete:function(){i(t("div.cart_totals")),t(document.body).trigger("updated_shipping_method")}})},shipping_calculator_submit:function(e){e.preventDefault();var o=t(e.currentTarget);c(t("div.cart_totals")),c(o),t("").attr("type","hidden").attr("name","calc_shipping").attr("value","x").appendTo(o),t.ajax({type:o.attr("method"),url:o.attr("action"),data:o.serialize(),dataType:"html",success:function(t){r(t)},complete:function(){i(o),i(t("div.cart_totals"))}})}},p={init:function(){this.update_cart_totals=this.update_cart_totals.bind(this),this.input_keypress=this.input_keypress.bind(this),this.cart_submit=this.cart_submit.bind(this),this.submit_click=this.submit_click.bind(this),this.apply_coupon=this.apply_coupon.bind(this),this.remove_coupon_clicked=this.remove_coupon_clicked.bind(this),this.quantity_update=this.quantity_update.bind(this),this.item_remove_clicked=this.item_remove_clicked.bind(this),this.item_restore_clicked=this.item_restore_clicked.bind(this),this.update_cart=this.update_cart.bind(this),t(document).on("wc_update_cart",function(){p.update_cart.apply(p,[].slice.call(arguments,1))}),t(document).on("click",".woocommerce-cart-form input[type=submit]",this.submit_click),t(document).on("keypress",".woocommerce-cart-form input[type=number]",this.input_keypress),t(document).on("submit",".woocommerce-cart-form",this.cart_submit),t(document).on("click","a.woocommerce-remove-coupon",this.remove_coupon_clicked),t(document).on("click",".woocommerce-cart-form .product-remove > a",this.item_remove_clicked),t(document).on("click",".woocommerce-cart .restore-item",this.item_restore_clicked),t(document).on("change input",".woocommerce-cart-form .cart_item :input",this.input_changed),t('.woocommerce-cart-form input[name="update_cart"]').prop("disabled",!0)},input_changed:function(){t('.woocommerce-cart-form input[name="update_cart"]').prop("disabled",!1)},update_cart:function(e){var o=t(".woocommerce-cart-form");c(o),c(t("div.cart_totals")),t.ajax({type:o.attr("method"),url:o.attr("action"),data:o.serialize(),dataType:"html",success:function(t){r(t,e)},complete:function(){i(o),i(t("div.cart_totals"))}})},update_cart_totals:function(){c(t("div.cart_totals")),t.ajax({url:e("get_cart_totals"),dataType:"html",success:function(t){a(t)},complete:function(){i(t("div.cart_totals"))}})},input_keypress:function(t){13===t.keyCode&&(t.preventDefault(),this.cart_submit(t))},cart_submit:function(e){var c=t(document.activeElement),i=t("input[type=submit][clicked=true]"),r=t(e.currentTarget);if(r.is("form")||(r=t(e.currentTarget).parents("form")),0!==r.find(".woocommerce-cart-form__contents").length)return!o(r)&&void(i.is('input[name="update_cart"]')||c.is("input.qty")?(e.preventDefault(),this.quantity_update(r)):(i.is('input[name="apply_coupon"]')||c.is("#coupon_code"))&&(e.preventDefault(),this.apply_coupon(r)))},submit_click:function(e){t("input[type=submit]",t(e.target).parents("form")).removeAttr("clicked"),t(e.target).attr("clicked","true")},apply_coupon:function(o){c(o);var r=this,a=t("#coupon_code"),s=a.val(),p={security:wc_cart_params.apply_coupon_nonce,coupon_code:s};t.ajax({type:"POST",url:e("apply_coupon"),data:p,dataType:"html",success:function(e){t(".woocommerce-error, .woocommerce-message, .woocommerce-info").remove(),n(e),t(document.body).trigger("applied_coupon",[s])},complete:function(){i(o),a.val(""),r.update_cart(!0)}})},remove_coupon_clicked:function(o){o.preventDefault();var r=this,a=t(o.currentTarget).closest(".cart_totals"),s=t(o.currentTarget).attr("data-coupon");c(a);var p={security:wc_cart_params.remove_coupon_nonce,coupon:s};t.ajax({type:"POST",url:e("remove_coupon"),data:p,dataType:"html",success:function(e){t(".woocommerce-error, .woocommerce-message, .woocommerce-info").remove(),n(e),t(document.body).trigger("removed_coupon",[s]),i(a)},complete:function(){r.update_cart(!0)}})},quantity_update:function(e){c(e),c(t("div.cart_totals")),t("").attr("type","hidden").attr("name","update_cart").attr("value","Update Cart").appendTo(e),t.ajax({type:e.attr("method"),url:e.attr("action"),data:e.serialize(),dataType:"html",success:function(t){r(t)},complete:function(){i(e),i(t("div.cart_totals"))}})},item_remove_clicked:function(e){e.preventDefault();var o=t(e.currentTarget),a=o.parents("form");c(a),c(t("div.cart_totals")),t.ajax({type:"GET",url:o.attr("href"),dataType:"html",success:function(t){r(t)},complete:function(){i(a),i(t("div.cart_totals"))}})},item_restore_clicked:function(e){e.preventDefault();var o=t(e.currentTarget),a=t("form.woocommerce-cart-form");c(a),c(t("div.cart_totals")),t.ajax({type:"GET",url:o.attr("href"),dataType:"html",success:function(t){r(t)},complete:function(){i(a),i(t("div.cart_totals"))}})}};s.init(p),p.init()}); \ No newline at end of file +jQuery(function(t){if("undefined"==typeof wc_cart_params)return!1;var e=function(t){return wc_cart_params.wc_ajax_url.toString().replace("%%endpoint%%",t)},o=function(t){return t.is(".processing")||t.parents(".processing").length},c=function(t){o(t)||t.addClass("processing").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},i=function(t){t.removeClass("processing").unblock()},r=function(e,o){var c=t.parseHTML(e),i=t(".woocommerce-cart-form",c),r=t(".cart_totals",c),s=t(".woocommerce-error, .woocommerce-message, .woocommerce-info",c);if(0!==t(".woocommerce-cart-form").length){if(o||t(".woocommerce-error, .woocommerce-message, .woocommerce-info").remove(),0===i.length){if(t(".woocommerce-checkout").length)return void(window.location.href=window.location.href);var p=t(".cart-empty",c).closest(".woocommerce");t(".woocommerce-cart-form__contents").closest(".woocommerce").replaceWith(p),s.length>0&&n(s,t(".cart-empty").closest(".woocommerce"))}else t(".woocommerce-checkout").length&&t(document.body).trigger("update_checkout"),t(".woocommerce-cart-form").replaceWith(i),t(".woocommerce-cart-form").find('input[name="update_cart"]').prop("disabled",!0),s.length>0&&n(s),a(r);t(document.body).trigger("updated_wc_div")}else window.location.href=window.location.href},a=function(e){t(".cart_totals").replaceWith(e),t(document.body).trigger("updated_cart_totals")},n=function(e,o){o||(o=t(".woocommerce-cart-form")),o.before(e)},s={init:function(e){this.cart=e,this.toggle_shipping=this.toggle_shipping.bind(this),this.shipping_method_selected=this.shipping_method_selected.bind(this),this.shipping_calculator_submit=this.shipping_calculator_submit.bind(this),t(document).on("click",".shipping-calculator-button",this.toggle_shipping),t(document).on("change","select.shipping_method, input[name^=shipping_method]",this.shipping_method_selected),t(document).on("submit","form.woocommerce-shipping-calculator",this.shipping_calculator_submit),t(".shipping-calculator-form").hide()},toggle_shipping:function(){return t(".shipping-calculator-form").slideToggle("slow"),t(document.body).trigger("country_to_state_changed"),!1},shipping_method_selected:function(){var o={};t("select.shipping_method, input[name^=shipping_method][type=radio]:checked, input[name^=shipping_method][type=hidden]").each(function(){o[t(this).data("index")]=t(this).val()}),c(t("div.cart_totals"));var r={security:wc_cart_params.update_shipping_method_nonce,shipping_method:o};t.ajax({type:"post",url:e("update_shipping_method"),data:r,dataType:"html",success:function(t){a(t)},complete:function(){i(t("div.cart_totals")),t(document.body).trigger("updated_shipping_method")}})},shipping_calculator_submit:function(e){e.preventDefault();var o=t(e.currentTarget);c(t("div.cart_totals")),c(o),t("").attr("type","hidden").attr("name","calc_shipping").attr("value","x").appendTo(o),t.ajax({type:o.attr("method"),url:o.attr("action"),data:o.serialize(),dataType:"html",success:function(t){r(t)},complete:function(){i(o),i(t("div.cart_totals"))}})}},p={init:function(){this.update_cart_totals=this.update_cart_totals.bind(this),this.input_keypress=this.input_keypress.bind(this),this.cart_submit=this.cart_submit.bind(this),this.submit_click=this.submit_click.bind(this),this.apply_coupon=this.apply_coupon.bind(this),this.remove_coupon_clicked=this.remove_coupon_clicked.bind(this),this.quantity_update=this.quantity_update.bind(this),this.item_remove_clicked=this.item_remove_clicked.bind(this),this.item_restore_clicked=this.item_restore_clicked.bind(this),this.update_cart=this.update_cart.bind(this),t(document).on("wc_update_cart",function(){p.update_cart.apply(p,[].slice.call(arguments,1))}),t(document).on("click",".woocommerce-cart-form input[type=submit]",this.submit_click),t(document).on("keypress",".woocommerce-cart-form input[type=number]",this.input_keypress),t(document).on("submit",".woocommerce-cart-form",this.cart_submit),t(document).on("click","a.woocommerce-remove-coupon",this.remove_coupon_clicked),t(document).on("click",".woocommerce-cart-form .product-remove > a",this.item_remove_clicked),t(document).on("click",".woocommerce-cart .restore-item",this.item_restore_clicked),t(document).on("change input",".woocommerce-cart-form .cart_item :input",this.input_changed),t('.woocommerce-cart-form input[name="update_cart"]').prop("disabled",!0)},input_changed:function(){t('.woocommerce-cart-form input[name="update_cart"]').prop("disabled",!1)},update_cart:function(e){var o=t(".woocommerce-cart-form");c(o),c(t("div.cart_totals")),t.ajax({type:o.attr("method"),url:o.attr("action"),data:o.serialize(),dataType:"html",success:function(t){r(t,e)},complete:function(){i(o),i(t("div.cart_totals"))}})},update_cart_totals:function(){c(t("div.cart_totals")),t.ajax({url:e("get_cart_totals"),dataType:"html",success:function(t){a(t)},complete:function(){i(t("div.cart_totals"))}})},input_keypress:function(t){13===t.keyCode&&(t.preventDefault(),this.cart_submit(t))},cart_submit:function(e){var c=t(document.activeElement),i=t("input[type=submit][clicked=true]"),r=t(e.currentTarget);if(r.is("form")||(r=t(e.currentTarget).parents("form")),0!==r.find(".woocommerce-cart-form__contents").length)return!o(r)&&void(i.is('input[name="update_cart"]')||c.is("input.qty")?(e.preventDefault(),this.quantity_update(r)):(i.is('input[name="apply_coupon"]')||c.is("#coupon_code"))&&(e.preventDefault(),this.apply_coupon(r)))},submit_click:function(e){t("input[type=submit]",t(e.target).parents("form")).removeAttr("clicked"),t(e.target).attr("clicked","true")},apply_coupon:function(o){c(o);var r=this,a=t("#coupon_code"),s=a.val(),p={security:wc_cart_params.apply_coupon_nonce,coupon_code:s};t.ajax({type:"POST",url:e("apply_coupon"),data:p,dataType:"html",success:function(e){t(".woocommerce-error, .woocommerce-message, .woocommerce-info").remove(),n(e),t(document.body).trigger("applied_coupon",[s])},complete:function(){i(o),a.val(""),r.update_cart(!0)}})},remove_coupon_clicked:function(o){o.preventDefault();var r=this,a=t(o.currentTarget).closest(".cart_totals"),s=t(o.currentTarget).attr("data-coupon");c(a);var p={security:wc_cart_params.remove_coupon_nonce,coupon:s};t.ajax({type:"POST",url:e("remove_coupon"),data:p,dataType:"html",success:function(e){t(".woocommerce-error, .woocommerce-message, .woocommerce-info").remove(),n(e),t(document.body).trigger("removed_coupon",[s]),i(a)},complete:function(){r.update_cart(!0)}})},quantity_update:function(e){c(e),c(t("div.cart_totals")),t("").attr("type","hidden").attr("name","update_cart").attr("value","Update Cart").appendTo(e),t.ajax({type:e.attr("method"),url:e.attr("action"),data:e.serialize(),dataType:"html",success:function(t){r(t)},complete:function(){i(e),i(t("div.cart_totals"))}})},item_remove_clicked:function(e){e.preventDefault();var o=t(e.currentTarget),a=o.parents("form");c(a),c(t("div.cart_totals")),t.ajax({type:"GET",url:o.attr("href"),dataType:"html",success:function(t){r(t)},complete:function(){i(a),i(t("div.cart_totals"))}})},item_restore_clicked:function(e){e.preventDefault();var o=t(e.currentTarget),a=t("form.woocommerce-cart-form");c(a),c(t("div.cart_totals")),t.ajax({type:"GET",url:o.attr("href"),dataType:"html",success:function(t){r(t)},complete:function(){i(a),i(t("div.cart_totals"))}})}};s.init(p),p.init()}); \ No newline at end of file diff --git a/assets/js/frontend/lost-password.min.js b/assets/js/frontend/lost-password.min.js index 201056c23ff..9b013e965d0 100644 --- a/assets/js/frontend/lost-password.min.js +++ b/assets/js/frontend/lost-password.min.js @@ -1 +1 @@ -jQuery(function(t){t(".lost_reset_password").on("submit",function(){t('input[type="submit"]',this).attr("disabled","disabled")})}); \ No newline at end of file +jQuery(function(t){t(".lost_reset_password").on("submit",function(){t('button[type="submit"]',this).attr("disabled","disabled")})}); \ No newline at end of file diff --git a/assets/js/frontend/password-strength-meter.min.js b/assets/js/frontend/password-strength-meter.min.js index c0f73aac5bb..25e6995fa7d 100644 --- a/assets/js/frontend/password-strength-meter.min.js +++ b/assets/js/frontend/password-strength-meter.min.js @@ -1 +1 @@ -!function(s){"use strict";var r={init:function(){s(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),s("form.checkout #createaccount").change()},strengthMeter:function(){var e=s("form.register, form.checkout, form.edit-account, form.lost_reset_password"),t=s('input[type="submit"]',e),a=s("#reg_password, #account_password, #password_1",e),o=1,d=a.val();r.includeMeter(e,a),o=r.checkPasswordStrength(e,a),d.length>0&&o'),s(document.body).trigger("wc-password-strength-added"))},checkPasswordStrength:function(s,r){var e=s.find(".woocommerce-password-strength"),t=s.find(".woocommerce-password-hint"),a=''+wc_password_strength_meter_params.i18n_password_hint+"",o=wp.passwordStrength.meter(r.val(),wp.passwordStrength.userInputBlacklist()),d="";switch(e.removeClass("short bad good strong"),t.remove(),o0&&a'),s(document.body).trigger("wc-password-strength-added"))},checkPasswordStrength:function(s,r){var e=s.find(".woocommerce-password-strength"),t=s.find(".woocommerce-password-hint"),o=''+wc_password_strength_meter_params.i18n_password_hint+"",a=wp.passwordStrength.meter(r.val(),wp.passwordStrength.userInputBlacklist()),d="";switch(e.removeClass("short bad good strong"),t.remove(),a '_stock_status', 'value' => $product_object->get_stock_status( 'edit' ), - 'wrapper_class' => 'hide_if_variable hide_if_external', + 'wrapper_class' => 'stock_status_field hide_if_variable hide_if_external', 'label' => __( 'Stock status', 'woocommerce' ), 'options' => wc_get_product_stock_status_options(), 'desc_tip' => true, diff --git a/includes/admin/views/html-quick-edit-product.php b/includes/admin/views/html-quick-edit-product.php index 8e7144a5066..92a7f6d8f86 100644 --- a/includes/admin/views/html-quick-edit-product.php +++ b/includes/admin/views/html-quick-edit-product.php @@ -120,7 +120,7 @@ if ( ! defined( 'ABSPATH' ) ) { -