10000 wc_get_low_stock_amount() returns a string if not set at product level · Issue #29525 · woocommerce/woocommerce · GitHub
[go: up one dir, main page]

Skip to content
wc_get_low_stock_amount() returns a string if not set at product level #29525
@helgatheviking

Description

@helgatheviking

Prerequisites (mark completed items with an [x]):

  • I have have carried out troubleshooting steps and I believe I have found a bug.
  • I have searched for similar bugs in both open and closed issues and cannot find a duplicate.

Describe the bug
When the low stock amount is pulled from the global settings via $low_stock_amount = get_option( 'woocommerce_notify_low_stock_amount', 2 );

the value returned is a string and not an integer like the doc-block suggests.

Expected behavior
Always return an integer.

Actual behavior
A clear and concise description of what actually happens. Please be as descriptive as possible;

Steps to reproduce the bug (We need to be able to reproduce the bug in order to fix it.)
Steps to reproduce the bug:

  1. Go to product data metabox

  2. select "manage stock" checkbox

  3. leave "low stock" threshold empty/null
    image

  4. Add snippet:

function kia_test_low_stock_amount() {
	global $product;
	var_dump( wc_get_low_stock_amount( $product ) );
}
add_action( 'woocommerce_before_add_to_cart', 'kia_test_low_stock_amount' );
  1. Visit product page.

  2. See the threshold is a string
    image

  3. Optionally, you can edit the product's low-stock threshold, save, and refresh the page to confirm it's an integer when set at the product-level.

Metadata

Metadata

Assignees

Labels

BugThe issue is a confirmed bug.Product/Inventory ManagementIssues related to product or product page.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0