Allow decimal stock quantity via REST API

The WooCommerce default is to validate stock quantity as integer, however some users find it useful to override this to allow any float quantity, eg: 
```php
remove_filter('woocommerce_stock_amount', 'intval');
add_filter( 'woocommerce_stock_amount', 'floatval' );
```

Currently the API forces stock quantities to integer, this change will allow decimal quantities.
This commit is contained in:
Paul Kilmurray 2015-06-19 12:07:10 +08:00
parent 92c048c9ff
commit 3538d02ca9
1 changed files with 2 additions and 2 deletions

View File

@ -646,7 +646,7 @@ class WC_API_Products extends WC_API_Resource {
'tax_status' => $product->get_tax_status(),
'tax_class' => $product->get_tax_class(),
'managing_stock' => $product->managing_stock(),
'stock_quantity' => (int) $product->get_stock_quantity(),
'stock_quantity' => $product->get_stock_quantity(),
'in_stock' => $product->is_in_stock(),
'backorders_allowed' => $product->backorders_allowed(),
'backordered' => $product->is_on_backorder(),
@ -728,7 +728,7 @@ class WC_API_Products extends WC_API_Resource {
'tax_status' => $variation->get_tax_status(),
'tax_class' => $variation->get_tax_class(),
'managing_stock' => $variation->managing_stock(),
'stock_quantity' => (int) $variation->get_stock_quantity(),
'stock_quantity' => $variation->get_stock_quantity(),
'in_stock' => $variation->is_in_stock(),
'backordered' => $variation->is_on_backorder(),
'purchaseable' => $variation->is_purchasable(),