Skip to content

Commit 2df1cdc

Browse files
committed
v1.5.0
1 parent d8f9976 commit 2df1cdc

File tree

5 files changed

+36
-6
lines changed

5 files changed

+36
-6
lines changed

includes/Products.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public function __construct() {
4545
if ( \is_bool( $allow_decimal_quantities ) && $allow_decimal_quantities ) {
4646
remove_filter( 'woocommerce_stock_amount', 'intval' );
4747
add_filter( 'woocommerce_stock_amount', 'floatval' );
48+
add_action( 'woocommerce_before_product_object_save', array( $this, 'save_decimal_quantities' ) );
4849
}
4950
}
5051

@@ -199,4 +200,33 @@ public function store_api_prevent_pos_only_add_to_cart( WC_Product $product ) {
199200
);
200201
}
201202
}
203+
204+
/**
205+
* Save decimal quantities for products and variations.
206+
*
207+
* @param WC_Product $product Product.
208+
*/
209+
public function save_decimal_quantities( WC_Product $product ) {
210+
if ( ! $product->get_manage_stock() ) {
211+
$product->set_stock_status( 'instock' );
212+
return;
213+
}
214+
215+
$stock_quantity = $product->get_stock_quantity();
216+
$stock_notification_threshold = absint( get_option( 'woocommerce_notify_no_stock_amount', 0 ) );
217+
218+
// Adjust the condition to consider stock quantities between 0 and 1 as instock if greater than 0.
219+
$stock_is_above_notification_threshold = ( $stock_quantity > 0 && $stock_quantity > $stock_notification_threshold );
220+
$backorders_are_allowed = ( 'no' !== $product->get_backorders() );
221+
222+
if ( $stock_is_above_notification_threshold ) {
223+
$new_stock_status = 'instock';
224+
} elseif ( $backorders_are_allowed ) {
225+
$new_stock_status = 'onbackorder';
226+
} else {
227+
$new_stock_status = 'outofstock';
228+
}
229+
230+
$product->set_stock_status( $new_stock_status );
231+
}
202232
}

includes/Templates/Frontend.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function head(): void {
8686
public function footer(): void {
8787
$development = isset( $_ENV['DEVELOPMENT'] ) && $_ENV['DEVELOPMENT'];
8888
$user = wp_get_current_user();
89-
$github_url = 'https://cdn.jsdelivr.net/gh/wcpos/web-bundle@1.4/';
89+
$github_url = 'https://cdn.jsdelivr.net/gh/wcpos/web-bundle@1.5/';
9090
$auth_service = Auth::instance();
9191
$stores = array_map(
9292
function ( $store ) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@wcpos/woocommerce-pos",
3-
"version": "1.4.16",
3+
"version": "1.5.0",
44
"description": "A simple front-end for taking WooCommerce orders at the Point of Sale.",
55
"main": "index.js",
66
"workspaces": {

readme.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ There is more information on our website at [https://wcpos.com](https://wcpos.co
7878

7979
== Changelog ==
8080

81-
= 1.5.0 - 2024/04/XX =
82-
81+
= 1.5.0 - 2024/06/02 =
82+
* Coming...
8383

8484
= 1.4.16 - 2024/03/28 =
8585
* Fix: nonce check failing for Guest orders when checking out with the desktop application

woocommerce-pos.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: WooCommerce POS
44
* Plugin URI: https://wordpress.org/plugins/woocommerce-pos/
55
* Description: A simple front-end for taking WooCommerce orders at the Point of Sale. Requires <a href="http://wordpress.org/plugins/woocommerce/">WooCommerce</a>.
6-
* Version: 1.4.16
6+
* Version: 1.5.0
77
* Author: kilbot
88
* Author URI: http://wcpos.com
99
* Text Domain: woocommerce-pos
@@ -26,7 +26,7 @@
2626
namespace WCPOS\WooCommercePOS;
2727

2828
// Define plugin constants.
29-
const VERSION = '1.4.16';
29+
const VERSION = '1.5.0';
3030
const PLUGIN_NAME = 'woocommerce-pos';
3131
const SHORT_NAME = 'wcpos';
3232
\define( __NAMESPACE__ . '\PLUGIN_FILE', plugin_basename( __FILE__ ) ); // 'woocommerce-pos/woocommerce-pos.php'

0 commit comments

Comments
 (0)