Merge pull request #21447 from woocommerce/fix/21392
Allow saving 0 as stock value when using quick edit
This commit is contained in:
commit
8b7ccf84ec
|
@ -2,8 +2,6 @@
|
|||
/**
|
||||
* Post Types Admin
|
||||
*
|
||||
* @author Automattic
|
||||
* @category Admin
|
||||
* @package WooCommerce/admin
|
||||
* @version 3.3.0
|
||||
*/
|
||||
|
@ -120,6 +118,7 @@ class WC_Admin_Post_Types {
|
|||
|
||||
$messages['product'] = array(
|
||||
0 => '', // Unused. Messages start at index 1.
|
||||
/* translators: %s: Product view URL. */
|
||||
1 => sprintf( __( 'Product updated. <a href="%s">View Product</a>', 'woocommerce' ), esc_url( get_permalink( $post->ID ) ) ),
|
||||
2 => __( 'Custom field updated.', 'woocommerce' ),
|
||||
3 => __( 'Custom field deleted.', 'woocommerce' ),
|
||||
|
@ -405,7 +404,7 @@ class WC_Admin_Post_Types {
|
|||
$manage_stock = ! empty( $_REQUEST['_manage_stock'] ) && 'grouped' !== $product->get_type() ? 'yes' : 'no'; // WPCS: input var ok, sanitization ok.
|
||||
$backorders = ! empty( $_REQUEST['_backorders'] ) ? wc_clean( $_REQUEST['_backorders'] ) : 'no'; // WPCS: input var ok, sanitization ok.
|
||||
$stock_status = ! empty( $_REQUEST['_stock_status'] ) ? wc_clean( $_REQUEST['_stock_status'] ) : 'instock'; // WPCS: input var ok, sanitization ok.
|
||||
$stock_amount = 'yes' === $manage_stock && ! empty( $_REQUEST['_stock'] ) ? wc_stock_amount( $_REQUEST['_stock'] ) : ''; // WPCS: input var ok, sanitization ok.
|
||||
$stock_amount = 'yes' === $manage_stock && isset( $_REQUEST['_stock'] ) && is_numeric( wp_unslash( $_REQUEST['_stock'] ) ) ? wc_stock_amount( wp_unslash( $_REQUEST['_stock'] ) ) : ''; // WPCS: input var ok, sanitization ok.
|
||||
|
||||
$product->set_manage_stock( $manage_stock );
|
||||
$product->set_backorders( $backorders );
|
||||
|
@ -823,14 +822,14 @@ class WC_Admin_Post_Types {
|
|||
* When editing the shop page, we should hide templates.
|
||||
*
|
||||
* @param array $page_templates Templates array.
|
||||
* @param string $class Classname.
|
||||
* @param string $theme Classname.
|
||||
* @param WP_Post $post The current post object.
|
||||
* @return array
|
||||
*/
|
||||
public function hide_cpt_archive_templates( $page_templates, $theme, $post ) {
|
||||
$shop_page_id = wc_get_page_id( 'shop' );
|
||||
|
||||
if ( $post && $shop_page_id === absint( $post->ID ) ) {
|
||||
if ( $post && absint( $post->ID ) === $shop_page_id ) {
|
||||
$page_templates = array();
|
||||
}
|
||||
|
||||
|
@ -845,8 +844,9 @@ class WC_Admin_Post_Types {
|
|||
public function show_cpt_archive_notice( $post ) {
|
||||
$shop_page_id = wc_get_page_id( 'shop' );
|
||||
|
||||
if ( $post && $shop_page_id === absint( $post->ID ) ) {
|
||||
if ( $post && absint( $post->ID ) === $shop_page_id ) {
|
||||
echo '<div class="notice notice-info">';
|
||||
/* translators: %s: URL to read more about the shop page. */
|
||||
echo '<p>' . sprintf( wp_kses_post( __( 'This is the WooCommerce shop page. The shop page is a special archive that lists your products. <a href="%s">You can read more about this here</a>.', 'woocommerce' ) ), 'https://docs.woocommerce.com/document/woocommerce-pages/#section-4' ) . '</p>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue