Commit 465441ccd4 for woocommerce
commit 465441ccd48481dca0de69d5cee5bc582b6258da
Author: Deepak Lalwani <deepak.lalwani81@gmail.com>
Date: Tue Jan 20 15:49:29 2026 +0530
Add default stock amount function and filter (#62678)
diff --git a/plugins/woocommerce/changelog/39180-add-default-stock-amount-filter b/plugins/woocommerce/changelog/39180-add-default-stock-amount-filter
new file mode 100644
index 0000000000..bdadcf73be
--- /dev/null
+++ b/plugins/woocommerce/changelog/39180-add-default-stock-amount-filter
@@ -0,0 +1,4 @@
+Significance: minor
+Type: enhancement
+
+Introduced a new filter `woocommerce_product_stock_default_amount` to allow change of the default stock amount.
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 7dc31fc918..32e1d64ba1 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
@@ -66,10 +66,19 @@ if ( ! defined( 'ABSPATH' ) ) {
echo '<div class="stock_fields show_if_simple show_if_variable">';
+ /**
+ * Filters product default stock amount.
+ *
+ * @since 10.6.0
+ *
+ * @param int $default_stock_amount Default stock amount. Default is 1.
+ */
+ $default_stock_amount = apply_filters( 'woocommerce_product_stock_default_amount', 1 );
+
woocommerce_wp_text_input(
array(
'id' => '_stock',
- 'value' => wc_stock_amount( $product_object->get_stock_quantity( 'edit' ) ?? 1 ),
+ 'value' => wc_stock_amount( $product_object->get_stock_quantity( 'edit' ) ?? $default_stock_amount ),
'label' => __( 'Quantity', 'woocommerce' ),
'desc_tip' => true,
'description' => __( 'Stock quantity. If this is a variable product this value will be used to control stock for all variations, unless you define stock at variation level.', 'woocommerce' ),