12
12
13
13
namespace WCPOS \WooCommercePOS \Admin \Products ;
14
14
15
+ use const DOING_AUTOSAVE ;
15
16
use WCPOS \WooCommercePOS \Registry ;
16
- use WCPOS \WooCommercePOS \Services \Settings ;
17
17
18
- use const DOING_AUTOSAVE ;
18
+ use WCPOS \ WooCommercePOS \ Services \ Settings ;
19
19
20
20
class Single_Product {
21
21
/**
@@ -34,7 +34,7 @@ class Single_Product {
34
34
private $ pro_link = '' ;
35
35
36
36
public function __construct () {
37
- Registry::get_instance ()->set ( get_class ( $ this ) , $ this );
37
+ Registry::get_instance ()->set ( static ::class , $ this );
38
38
39
39
$ this ->barcode_field = woocommerce_pos_get_settings ( 'general ' , 'barcode_field ' );
40
40
$ this ->pro_link = '<a href="https://wcpos.com/pro"> ' . __ ( 'Upgrade to Pro ' , 'woocommerce-pos ' ) . '</a>. ' ;
@@ -46,7 +46,7 @@ public function __construct() {
46
46
'online_only ' => __ ( 'Online Only ' , 'woocommerce-pos ' ),
47
47
);
48
48
49
- if ( $ this ->barcode_field && ' _sku ' !== $ this ->barcode_field ) {
49
+ if ( $ this ->barcode_field && ! \in_array ( $ this ->barcode_field , array ( ' _sku ' , ' _global_unique_id ' ), true ) ) {
50
50
add_action ( 'woocommerce_product_options_sku ' , array ( $ this , 'woocommerce_product_options_sku ' ) );
51
51
add_action ( 'woocommerce_process_product_meta ' , array ( $ this , 'woocommerce_process_product_meta ' ) );
52
52
add_action ( 'woocommerce_product_after_variable_attributes ' , array ( $ this , 'after_variable_attributes_barcode_field ' ), 10 , 3 );
@@ -200,12 +200,12 @@ public function save_post( $post_id, $post ): void {
200
200
// Get the product and save.
201
201
$ valid_options = array ( 'pos_only ' , 'online_only ' , '' );
202
202
203
- if ( isset ( $ _POST ['_pos_visibility ' ] ) && in_array ( $ _POST ['_pos_visibility ' ], $ valid_options , true ) ) {
203
+ if ( isset ( $ _POST ['_pos_visibility ' ] ) && \ in_array ( $ _POST ['_pos_visibility ' ], $ valid_options , true ) ) {
204
204
$ settings_instance = Settings::instance ();
205
- $ args = array (
206
- 'post_type ' => 'products ' ,
205
+ $ args = array (
206
+ 'post_type ' => 'products ' ,
207
207
'visibility ' => $ _POST ['_pos_visibility ' ],
208
- 'ids ' => array ( $ post_id ),
208
+ 'ids ' => array ( $ post_id ),
209
209
);
210
210
$ settings_instance ->update_visibility_settings ( $ args );
211
211
}
@@ -221,12 +221,12 @@ public function post_submitbox_misc_actions(): void {
221
221
return ;
222
222
}
223
223
224
- $ selected = '' ;
224
+ $ selected = '' ;
225
225
$ settings_instance = Settings::instance ();
226
- $ pos_only = $ settings_instance ->is_product_pos_only ( $ post ->ID );
227
- $ online_only = $ settings_instance ->is_product_online_only ( $ post ->ID );
226
+ $ pos_only = $ settings_instance ->is_product_pos_only ( $ post ->ID );
227
+ $ online_only = $ settings_instance ->is_product_online_only ( $ post ->ID );
228
228
229
- // Set $selected based on the visibility status.
229
+ // Set $selected based on the visibility status.
230
230
if ( $ pos_only ) {
231
231
$ selected = 'pos_only ' ;
232
232
} elseif ( $ online_only ) {
@@ -244,18 +244,17 @@ public function post_submitbox_misc_actions(): void {
244
244
}
245
245
246
246
/**
247
- *
248
247
* @param $loop
249
248
* @param $variation_data
250
249
* @param $variation
251
250
*/
252
251
public function after_variable_attributes_pos_only_products ( $ loop , $ variation_data , $ variation ): void {
253
- $ selected = '' ;
252
+ $ selected = '' ;
254
253
$ settings_instance = Settings::instance ();
255
- $ pos_only = $ settings_instance ->is_variation_pos_only ( $ variation ->ID );
256
- $ online_only = $ settings_instance ->is_variation_online_only ( $ variation ->ID );
254
+ $ pos_only = $ settings_instance ->is_variation_pos_only ( $ variation ->ID );
255
+ $ online_only = $ settings_instance ->is_variation_online_only ( $ variation ->ID );
257
256
258
- // Set $selected based on the visibility status.
257
+ // Set $selected based on the visibility status.
259
258
if ( $ pos_only ) {
260
259
$ selected = 'pos_only ' ;
261
260
} elseif ( $ online_only ) {
@@ -271,12 +270,12 @@ public function after_variable_attributes_pos_only_products( $loop, $variation_d
271
270
public function save_product_variation_pos_only_products ( $ variation_id ): void {
272
271
$ valid_options = array ( 'pos_only ' , 'online_only ' , '' );
273
272
274
- if ( isset ( $ _POST ['variable_pos_visibility ' ][ $ variation_id ] ) && in_array ( $ _POST ['variable_pos_visibility ' ][ $ variation_id ], $ valid_options , true ) ) {
273
+ if ( isset ( $ _POST ['variable_pos_visibility ' ][ $ variation_id ] ) && \ in_array ( $ _POST ['variable_pos_visibility ' ][ $ variation_id ], $ valid_options , true ) ) {
275
274
$ settings_instance = Settings::instance ();
276
- $ args = array (
277
- 'post_type ' => 'variations ' ,
275
+ $ args = array (
276
+ 'post_type ' => 'variations ' ,
278
277
'visibility ' => $ _POST ['variable_pos_visibility ' ][ $ variation_id ],
279
- 'ids ' => array ( $ variation_id ),
278
+ 'ids ' => array ( $ variation_id ),
280
279
);
281
280
$ settings_instance ->update_visibility_settings ( $ args );
282
281
}
0 commit comments