Skip to content

Commit 39f8c1a

Browse files
committed
3.0.2
1 parent 0b1f9ee commit 39f8c1a

File tree

9 files changed

+79
-17
lines changed

9 files changed

+79
-17
lines changed

src/css/admin-style.css

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,18 @@
2323
#stock-locations-for-woocommerce_tab_stock_locations_alert {
2424
padding-left:11px;
2525
padding-top:11px;
26-
color:orange;
26+
color:#4200FF;
27+
font-size:14px;
28+
}
29+
#stock-locations-for-woocommerce_tab_stock_locations_alert > a {
30+
color:#900;
2731
}
2832
#stock-locations-for-woocommerce_tab_stock_locations_alert:before {
29-
font-family: Font Awesome\ 5 Free;
30-
content: '\f071';
33+
content: '\26A0';
3134
font-weight: 900;
35+
font-size:20px;
3236
margin-right: 6px;
37+
color:#900;
3338
}
3439
table thead tr #stock_at_locations {
3540
width: 17ch;
@@ -704,7 +709,6 @@ input:checked + .slider:before {
704709
}
705710
.slw-location-disabled input.wc_input_stock {
706711
background-color: #ddd;
707-
text-decoration: line-through;
708712
}
709713
.slw_edit_stocks{
710714
color: #4200FF;

src/inc/functions-api.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
if(!empty($_GET)){
1616

1717
$received = sanitize_slw_data($_GET);
18+
19+
if ( empty( $slw_api_valid_keys ) || ! is_array( $slw_api_valid_keys ) ) {
20+
$slw_api_valid_keys = [];
21+
}
1822
foreach($received as $k=>$v){
1923
if(array_key_exists($k, $slw_api_valid_keys)){
2024
$data[$k] = $v;

src/inc/functions.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1486,7 +1486,8 @@ function slw_fix_outofstock_terms($product_ids) {
14861486

14871487

14881488
function slw_update_product_stock_status($product_id=0, $stock_qty=0){
1489-
1489+
//wc_slw_logger('debug', $product_id.' - '.$stock_qty);
1490+
//return;
14901491
//slw_location_status
14911492
/*$debug_backtrace = debug_backtrace();
14921493

src/readme.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,17 @@ On settings page you can define a number. If location stock value will be less t
169169

170170

171171
== Changelog ==
172+
= 3.0.2 =
173+
* Fixed: Only enabled/active stock locations will contribute in total stock value but it would still be editable. [Thanks to @josephkallinit][21/10/2025]
174+
* Fixed: Prevented potential PHP error when `$slw_api_valid_keys` is null during API validation. [Thanks to Tushar Tajane][21/10/2025]
175+
* New: Order notes can be turned off from the settings. [Thanks to Rob Wood][21/10/2025]
176+
* Fixed: Incorrect price range display for variable products when location-based stock prices are higher than variation base prices. The location price now overrides confusing WooCommerce default range formatting.
177+
* Improved: Sale price logic now fully respects location-based pricing — ensuring both range and sale indicators are hidden when local price is higher. [21/10/2025]
178+
179+
= 3.0.1 =
180+
* Added: Conditional CSS injection for WooCommerce Blocks to hide sale and del elements when location price exceeds the base or sale price.
181+
* Improved: Price hiding logic refactored for better compatibility across all product types (simple, variable, grouped). [20/10/2025]
182+
172183
= 3.0.0 =
173184
* Improved: When a product is on sale and stock-location-based pricing is active, the base price is treated as the original (crossed) price, and the location price is shown as the current price. If the location price is higher than the base/sale price, the base/sale price will be hidden. [Thanks to Armando Moreira][19/10/2025]
174185

src/src/classes/class-slw-order-item.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ public function restore_order_items_locations_stock( $order ){
134134
if( empty($order) || ! is_object($order) ) return;
135135

136136

137+
global $slw_proceed_order_note;
137138

138139
$wc_order_stock_reduced = $order->get_meta( '_slw_order_stock_reduced' );
139140

@@ -172,9 +173,14 @@ public function restore_order_items_locations_stock( $order ){
172173
wc_delete_order_item_meta( $item_id, '_slw_data' );
173174

174175
// add order note
175-
$order->add_order_note(
176-
sprintf( __('The stock in the location %1$s was restored in %2$d for the product %3$s', 'stock-locations-for-woocommerce'), $location->name, $slw_data[$location_id]['quantity_subtracted'], $product->get_name() )
177-
);
176+
177+
178+
179+
if($slw_proceed_order_note){
180+
$order->add_order_note(
181+
sprintf( __('The stock in the location %1$s was restored in %2$d for the product %3$s', 'stock-locations-for-woocommerce'), $location->name, $slw_data[$location_id]['quantity_subtracted'], $product->get_name() )
182+
);
183+
}
178184
}
179185
}
180186

@@ -638,6 +644,9 @@ public function include_location_data_in_formatted_item_meta( $formatted_meta, $
638644

639645
$proceed = ( isset($this->plugin_settings['include_location_data_in_formatted_item_meta']) && $this->plugin_settings['include_location_data_in_formatted_item_meta'] == 'yes' );
640646

647+
648+
649+
641650
$proceed = (
642651

643652
($receipt_in_progress && is_checkout() && isset($this->plugin_settings['general_display_settings']) && isset($this->plugin_settings['general_display_settings']['order_received_page']) && $this->plugin_settings['general_display_settings']['order_received_page'] == 'on' )

src/src/classes/class-slw-settings.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,15 @@ public function register_settings()
282282
'slw_setting_setting_section',
283283
array('class'=>'include_location_data_in_formatted_item_meta')
284284
);
285+
286+
add_settings_field(
287+
'turn_order_notes_off_from_this_plugin',
288+
__('Turn order notes off from this plugin', 'stock-locations-for-woocommerce'),
289+
array( $this, 'turn_order_notes_off_from_this_plugin_callback' ),
290+
'slw-setting-admin',
291+
'slw_setting_setting_section',
292+
array('class'=>'turn_order_notes_off_from_this_plugin')
293+
);
285294

286295
add_settings_field(
287296
'location_email_notifications',
@@ -397,6 +406,9 @@ public function option_setting_sanitize( $input )
397406
if ( isset( $input['include_location_data_in_formatted_item_meta'] ) ) {
398407
$sanitary_values['include_location_data_in_formatted_item_meta'] = $input['include_location_data_in_formatted_item_meta'];
399408
}
409+
if ( isset( $input['turn_order_notes_off_from_this_plugin'] ) ) {
410+
$sanitary_values['turn_order_notes_off_from_this_plugin'] = $input['turn_order_notes_off_from_this_plugin'];
411+
}
400412
if ( isset( $input['location_email_notifications'] ) ) {
401413
$sanitary_values['location_email_notifications'] = $input['location_email_notifications'];
402414
}
@@ -677,6 +689,16 @@ public function include_location_data_in_formatted_item_meta_callback()
677689
<p><?php echo __('This special meta can be used by third party plugins to show the location name and quantity subtracted.', 'stock-locations-for-woocommerce'); ?></p>
678690
<?php
679691
}
692+
693+
public function turn_order_notes_off_from_this_plugin_callback()
694+
{
695+
$this->select_yes_no_callback('turn_order_notes_off_from_this_plugin');
696+
?>
697+
<p><?php echo __('This plugin will not add any new order notes to WooCommerce orders if you turn this option ON by selecting Yes.', 'stock-locations-for-woocommerce'); ?></p>
698+
<?php
699+
}
700+
701+
680702

681703
/**
682704
* Location email notifications callback.

src/src/classes/class-slw-stock-locations-tab.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public function tab_content_stock_locations_wc_product( $array )
151151
// Check if the total stock matches the sum of the locations stock, if not show warning message
152152

153153
if( $product->get_stock_quantity() != $total_location_stock ) {
154-
echo '<div id="' . $this->tab_stock_locations . '_alert" style="display:none;">' . __('The total stock does not match the sum of the locations stock. Please update this product to fix it or use', 'stock-locations-for-woocommerce') .' <a href="'.admin_url('admin.php?page=slw-settings&tab=crons').'" target="_blank">'.__('cron jobs.', 'stock-locations-for-woocommerce').'</a>.</div>';
154+
echo '<div id="' . $this->tab_stock_locations . '_alert" style="display:none;">' . sprintf(__('Total stock is calculated from active/enabled locations only. Use %s for interval-based updates in passive mode.', 'stock-locations-for-woocommerce'), '<a href="'.admin_url('admin.php?page=slw-settings&tab=crons').'" target="_blank">'.__('cron jobs.', 'stock-locations-for-woocommerce').'</a>').'</div>';
155155
}
156156

157157
echo '</div>';
@@ -521,6 +521,8 @@ public function location_sidebar_meta_box( $post_type, $priority, $post )
521521
*/
522522
public static function update_product_stock( $id, $product_stock_location_terms, $terms_total, $force_main_product_update=false )
523523
{
524+
//pree($id);exit;
525+
524526
$stock_ret = 0;
525527
// WPML
526528
if(is_numeric($id)){
@@ -560,6 +562,9 @@ public static function update_product_stock( $id, $product_stock_location_terms,
560562

561563
if(is_array($product_stock_location_terms) && !empty($product_stock_location_terms)){
562564
// Loop through terms
565+
566+
//pree($product_stock_location_terms);exit;
567+
563568
foreach ( $product_stock_location_terms as $term ) {
564569

565570

@@ -576,13 +581,14 @@ public static function update_product_stock( $id, $product_stock_location_terms,
576581
if($product->get_parent_id()){
577582
//pree('$stock_input_id: '.$stock_input_id.' - '.$_POST[$stock_input_id]);exit;//pree($_POST);
578583
}
584+
//pree($slw_location_status);
579585

580586
if( !empty($_POST) && isset($_POST[$stock_input_id])) {
581587

582588
// Initiate counter
583589
$counter++;
584590

585-
if(!$slw_location_status){ continue; }
591+
//if(!$slw_location_status){ continue; }
586592
// Save input amounts to array
587593

588594
$input_amount = sanitize_slw_data($_POST[$stock_input_id]);
@@ -592,7 +598,9 @@ public static function update_product_stock( $id, $product_stock_location_terms,
592598
}
593599

594600
if($input_amount>=0){
595-
$input_amounts[] = $input_amount;
601+
if($slw_location_status){
602+
$input_amounts[] = $input_amount;
603+
}
596604
}else{
597605
continue;
598606
}
@@ -658,7 +666,7 @@ public static function update_product_stock( $id, $product_stock_location_terms,
658666
}
659667

660668

661-
$slw_location_status = get_term_meta($term->term_id, 'slw_location_status', true);
669+
//$slw_location_status = get_term_meta($term->term_id, 'slw_location_status', true);
662670

663671
if($slw_location_status){
664672
// Get post meta
@@ -672,7 +680,7 @@ public static function update_product_stock( $id, $product_stock_location_terms,
672680

673681

674682
}
675-
683+
//exit;
676684
if($counter === $terms_total) {
677685

678686
$stock_ret = array_sum($input_amounts);

src/src/helpers/helper-slw-order-item.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ class SlwOrderItemHelper
2323

2424
public static function allocateLocationStock( $orderItemId, $locationStockMap, $allocationType )
2525
{
26+
global $slw_proceed_order_note;
27+
2628
$order_id = wc_get_order_id_by_order_item_id( $orderItemId );
2729
$order_obj = wc_get_order($order_id);
2830
//wc_slw_logger('debug', 'allocateLocationStock: '.'Yes #'.$order_id);
@@ -139,7 +141,7 @@ public static function allocateLocationStock( $orderItemId, $locationStockMap, $
139141

140142

141143
// Add the note
142-
if(is_object($order_obj) && method_exists($order_obj, 'add_order_note')){
144+
if($slw_proceed_order_note && is_object($order_obj) && method_exists($order_obj, 'add_order_note')){
143145
$order_obj->add_order_note(
144146
sprintf(__('The stock in the location %1$s was updated in -%2$d for the product %3$s', 'stock-locations-for-woocommerce'), $term->name, $item_stock_location_subtract_input_qty, $mainProduct->get_name())
145147
);

src/stock-locations-for-woocommerce.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232

3333

34-
global $wc_slw_hpos, $wc_slw_data, $wc_slw_pro, $wc_slw_premium_copy, $slw_plugin_settings, $slw_gkey, $slw_api_valid_keys, $slw_crons_valid_keys, $slw_widgets_arr, $slw_wc_stock_format, $slw_theme_name, $slw_order_id, $slw_logs_status, $slw_woocommerce_product_form_hooks, $slw_wc_hide_out_of_stock;
34+
global $wc_slw_hpos, $wc_slw_data, $wc_slw_pro, $wc_slw_premium_copy, $slw_plugin_settings, $slw_gkey, $slw_api_valid_keys, $slw_crons_valid_keys, $slw_widgets_arr, $slw_wc_stock_format, $slw_theme_name, $slw_order_id, $slw_logs_status, $slw_woocommerce_product_form_hooks, $slw_wc_hide_out_of_stock, $slw_proceed_order_note;
3535

3636
$slw_crons_valid_keys = array(
3737
'action' => array('type'=>'string', 'options'=>'update-stock'),
@@ -47,6 +47,7 @@
4747
$slw_gkey = get_option('slw-google-api-key');
4848
$slw_plugin_settings = get_option( 'slw_settings' );
4949
$slw_plugin_settings = is_array($slw_plugin_settings)?$slw_plugin_settings:array();
50+
$slw_proceed_order_note = ( isset($slw_plugin_settings['turn_order_notes_off_from_this_plugin']) && $slw_plugin_settings['turn_order_notes_off_from_this_plugin'] == 'yes' );
5051
$wc_slw_data = get_plugin_data(__FILE__, true, false);
5152
define( 'SLW_PLUGIN_DIR', dirname( __FILE__ ) );
5253
define( 'SLW_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
@@ -79,7 +80,7 @@
7980

8081
class SlwMain{
8182
// versions
82-
public $version = '3.0.1';
83+
public $version = '3.0.2';
8384
public $import_export_addon_version = '1.1.1';
8485

8586
// others
@@ -261,7 +262,7 @@ public function enqueue_admin()
261262
'wc_slw_stock_reset_msg' => __('This action will restore the stock values to the product. Do you want to proceed?', 'stock-locations-for-woocommerce'),
262263
'wc_slw_product_id' => (is_object($post)?$post->ID:0),
263264
'wc_slw_location_status' => $slw_location_statuses,
264-
'wc_slw_location_disabled_msg' => __('Enable this location from edit location page to save the stock value.', 'stock-locations-for-woocommerce'),
265+
'wc_slw_location_disabled_msg' => __('Enable this location from edit location page to contribute in the total stock value.', 'stock-locations-for-woocommerce'),
265266
'slw_import_export_tutorial' => __('CSV Import/Export Stock Locations?', 'stock-locations-for-woocommerce'),
266267
'slw_error_occurred' => __('An error occurred while processing your request.', 'stock-locations-for-woocommerce'),
267268
);

0 commit comments

Comments
 (0)