Filter get_stock_quantity method for WooCommerce products

PHOTO EMBED

Tue May 31 2022 19:36:45 GMT+0000 (Coordinated Universal Time)

Saved by @lancerunsite #wordpress #php #stock #quantity #filter

add_filter( 'woocommerce_product_get_stock_quantity' ,'custom_get_stock_quantity', 10, 2 );
add_filter( 'woocommerce_product_variation_get_stock_quantity' ,'custom_get_stock_quantity', 10, 2 );
function custom_get_stock_quantity( $value, $product ) {
    $value = 15; // <== Just for testing
    return $value;
}
content_copyCOPY

https://stackoverflow.com/questions/47611251/any-way-to-overwrite-get-stock-quantity-in-my-functions-php