Skip to content

Commit 616db1e

Browse files
committed
2.6.0
1 parent a92d957 commit 616db1e

File tree

8 files changed

+29
-4
lines changed

8 files changed

+29
-4
lines changed

src/inc/filter-hooks.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,14 @@ function slw_location_selection_popup_display_callback($is_front_page=false, $is
6161

6262
}
6363
}
64+
65+
add_filter('allow_stock_allocation_notification', 'allow_stock_allocation_notification_callback', 9, 4);
66+
67+
if(!function_exists('allow_stock_allocation_notification_callback')){
68+
function allow_stock_allocation_notification_callback($term, $item, $quantity, $output = true){
69+
return (boolean)$output;
70+
}
71+
}
72+
73+
6474

src/readme.txt

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

153153

154154
== Changelog ==
155+
= 2.6.0 =
156+
- Fix: Sanitization ensured. [Thanks to patchstack.com / Mika][19/12/2023]
157+
- New: Filter hook added allow_stock_allocation_notification. [Thanks to github.com / Chingologram][19/12/2023]
158+
155159
= 2.5.9 =
156160
- New: Developers API updated with the price option as the item parameter. [Thanks to Tushar Tajane][22/11/2023]
157161

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public function restore_order_items_locations_stock( $order ){
177177
$locations_total_stock = SlwProductHelper::get_product_locations_stock_total( $product_id );
178178

179179
// update product main stock
180-
180+
wc_slw_logger('debug', '$product_id: '.$product_id.', $locations_total_stock: '.$locations_total_stock);
181181
slw_update_product_stock_status( $product_id, $locations_total_stock );
182182

183183

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,9 @@ public function product_update_callback( $values, $post, $attr, $request, $objec
101101

102102
// Get parent post ID
103103
// This is either the current product or its parent_id
104+
104105
$parentPostId = ($object_type === 'product_variation') ? $post->get_parent_id() : $postId;
105-
106+
wc_slw_logger('debug', '$postId: '.$postId.', $parentPostId: '.$parentPostId);
106107
$stockLocationTermIds = array();
107108

108109
$totalQuantity = 0;
@@ -127,6 +128,7 @@ public function product_update_callback( $values, $post, $attr, $request, $objec
127128
if( $totalQuantity != 0 ) {
128129
//$product = wc_get_product($parentPostId);
129130
//wc_update_product_stock( $product, $totalQuantity, 'set', false );
131+
130132
slw_update_product_stock_status( $parentPostId, $totalQuantity );
131133
}
132134

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,8 @@ public function option_setting_sanitize( $input )
326326
$sanitary_values = array();
327327

328328
// sanitize option
329+
$input = sanitize_slw_data($input);
330+
//pree($input);exit;
329331

330332
if ( isset( $input['extra_assets_settings'] ) ) {
331333
$sanitary_values['extra_assets_settings'] = $input['extra_assets_settings'];
@@ -349,7 +351,7 @@ public function option_setting_sanitize( $input )
349351
$sanitary_values['show_in_product_page'] = $input['show_in_product_page'];
350352
}
351353
if ( isset( $input['show_with_postfix'] ) ) {
352-
$sanitary_values['show_with_postfix'] = $input['show_with_postfix'];
354+
$sanitary_values['show_with_postfix'] = (int)$input['show_with_postfix'];
353355
}
354356
if ( isset( $input['default_location_in_frontend_selection'] ) ) {
355357
$sanitary_values['default_location_in_frontend_selection'] = $input['default_location_in_frontend_selection'];

src/src/helpers/helper-slw-mail.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ public static function stock_allocation_notification( $term, $item, $quantity )
2121
{
2222
//wc_slw_logger('debug', 'stock_allocation_notification: '.'Yes');
2323
if( empty($term) || empty($item) || empty($quantity) ) return;
24+
25+
if (!apply_filters('allow_stock_allocation_notification', $term, $item, $quantity, true)) {
26+
return;
27+
}
2428

2529
// get location meta
2630
$item_location_meta = SlwStockAllocationHelper::getLocationMeta( $term->term_id );

src/stock-locations-for-woocommerce.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105

106106
class SlwMain{
107107
// versions
108-
public $version = '2.5.9';
108+
public $version = '2.6.0';
109109
public $import_export_addon_version = '1.1.1';
110110

111111
// others

src/views/settings-api.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
<li>
4646
add_filter('slw_stock_allocation_notification_message', 'yourtheme_stock_allocation_notification_message_callback', 10, 4);
4747
</li>
48+
<li>
49+
add_filter('allow_stock_allocation_notification', 'yourtheme_allow_stock_allocation_notification_callback', 10, 4);
50+
</li>
4851

4952
</ul>
5053
</div>

0 commit comments

Comments
 (0)