diff --git a/plugins/woocommerce/changelog/dev-37118_convert_allow_backorders_into_radio_buttons b/plugins/woocommerce/changelog/dev-37118_convert_allow_backorders_into_radio_buttons new file mode 100644 index 000000000000..07aaf1b29adb --- /dev/null +++ b/plugins/woocommerce/changelog/dev-37118_convert_allow_backorders_into_radio_buttons @@ -0,0 +1,4 @@ +Significance: minor +Type: dev + +Convert "Allow backorders?" into radio buttons diff --git a/plugins/woocommerce/includes/admin/meta-boxes/views/html-product-data-inventory.php b/plugins/woocommerce/includes/admin/meta-boxes/views/html-product-data-inventory.php index 1e0b358ad7d4..ac2c944da2cd 100644 --- a/plugins/woocommerce/includes/admin/meta-boxes/views/html-product-data-inventory.php +++ b/plugins/woocommerce/includes/admin/meta-boxes/views/html-product-data-inventory.php @@ -64,17 +64,28 @@ echo ''; - woocommerce_wp_select( - array( - 'id' => '_backorders', - 'value' => $product_object->get_backorders( 'edit' ), - 'label' => __( 'Allow backorders?', 'woocommerce' ), - 'options' => wc_get_product_backorder_options(), - 'desc_tip' => true, - 'description' => __( 'If managing stock, this controls whether or not backorders are allowed. If enabled, stock quantity can go below 0.', 'woocommerce' ), - ) + $backorder_args = array( + 'id' => '_backorders', + 'value' => $product_object->get_backorders( 'edit' ), + 'label' => __( 'Allow backorders?', 'woocommerce' ), + 'options' => wc_get_product_backorder_options(), + 'desc_tip' => true, + 'description' => __( 'If managing stock, this controls whether or not backorders are allowed. If enabled, stock quantity can go below 0.', 'woocommerce' ), ); + /** + * Allow 3rd parties to control whether "Allow backorder?" option will use radio buttons or a select. + * + * @since 7.6.0 + * + * @param bool If false, "Allow backorders?" will be shown as a select. Default: it will use radio buttons. + */ + if ( apply_filters( 'woocommerce_product_allow_backorder_use_radio', true ) ) { + woocommerce_wp_radio( $backorder_args ); + } else { + woocommerce_wp_select( $backorder_args ); + } + woocommerce_wp_text_input( array( 'id' => '_low_stock_amount', @@ -115,14 +126,16 @@ } - $stock_status_options = wc_get_product_stock_status_options(); - $stock_status_count = count( $stock_status_options ); - $common_stock_status_args = array( + $stock_status_options = wc_get_product_stock_status_options(); + $stock_status_count = count( $stock_status_options ); + $stock_status_args = array( 'id' => '_stock_status', 'value' => $product_object->get_stock_status( 'edit' ), 'wrapper_class' => 'stock_status_field hide_if_variable hide_if_external hide_if_grouped', 'label' => __( 'Stock status', 'woocommerce' ), 'options' => $stock_status_options, + 'desc_tip' => true, + 'description' => __( 'Controls whether or not the product is listed as "in stock" or "out of stock" on the frontend.', 'woocommerce' ), ); /** @@ -133,13 +146,9 @@ * @param bool If false, the "Stock status" will be shown as a select. Default: it will use radio buttons. */ if ( apply_filters( 'woocommerce_product_stock_status_use_radio', $stock_status_count <= 3 && $stock_status_count >= 1 ) ) { - woocommerce_wp_radio( $common_stock_status_args ); + woocommerce_wp_radio( $stock_status_args ); } else { - $select_input_args = array( - 'desc_tip' => true, - 'description' => __( 'Controls whether or not the product is listed as "in stock" or "out of stock" on the frontend.', 'woocommerce' ), - ); - woocommerce_wp_select( array_merge( $common_stock_status_args, $select_input_args ) ); + woocommerce_wp_select( $stock_status_args ); } do_action( 'woocommerce_product_options_stock_status' );