1212
1313namespace WCPOS \WooCommercePOS \Admin \Products ;
1414
15+ use const DOING_AUTOSAVE ;
1516use WCPOS \WooCommercePOS \Registry ;
16- use WCPOS \WooCommercePOS \Services \Settings ;
1717
18- use const DOING_AUTOSAVE ;
18+ use WCPOS \ WooCommercePOS \ Services \ Settings ;
1919
2020class Single_Product {
2121 /**
@@ -34,7 +34,7 @@ class Single_Product {
3434 private $ pro_link = '' ;
3535
3636 public function __construct () {
37- Registry::get_instance ()->set ( get_class ( $ this ) , $ this );
37+ Registry::get_instance ()->set ( static ::class , $ this );
3838
3939 $ this ->barcode_field = woocommerce_pos_get_settings ( 'general ' , 'barcode_field ' );
4040 $ this ->pro_link = '<a href="https://wcpos.com/pro"> ' . __ ( 'Upgrade to Pro ' , 'woocommerce-pos ' ) . '</a>. ' ;
@@ -46,7 +46,7 @@ public function __construct() {
4646 'online_only ' => __ ( 'Online Only ' , 'woocommerce-pos ' ),
4747 );
4848
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 ) ) {
5050 add_action ( 'woocommerce_product_options_sku ' , array ( $ this , 'woocommerce_product_options_sku ' ) );
5151 add_action ( 'woocommerce_process_product_meta ' , array ( $ this , 'woocommerce_process_product_meta ' ) );
5252 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 {
200200 // Get the product and save.
201201 $ valid_options = array ( 'pos_only ' , 'online_only ' , '' );
202202
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 ) ) {
204204 $ settings_instance = Settings::instance ();
205- $ args = array (
206- 'post_type ' => 'products ' ,
205+ $ args = array (
206+ 'post_type ' => 'products ' ,
207207 'visibility ' => $ _POST ['_pos_visibility ' ],
208- 'ids ' => array ( $ post_id ),
208+ 'ids ' => array ( $ post_id ),
209209 );
210210 $ settings_instance ->update_visibility_settings ( $ args );
211211 }
@@ -221,12 +221,12 @@ public function post_submitbox_misc_actions(): void {
221221 return ;
222222 }
223223
224- $ selected = '' ;
224+ $ selected = '' ;
225225 $ 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 );
228228
229- // Set $selected based on the visibility status.
229+ // Set $selected based on the visibility status.
230230 if ( $ pos_only ) {
231231 $ selected = 'pos_only ' ;
232232 } elseif ( $ online_only ) {
@@ -244,18 +244,17 @@ public function post_submitbox_misc_actions(): void {
244244 }
245245
246246 /**
247- *
248247 * @param $loop
249248 * @param $variation_data
250249 * @param $variation
251250 */
252251 public function after_variable_attributes_pos_only_products ( $ loop , $ variation_data , $ variation ): void {
253- $ selected = '' ;
252+ $ selected = '' ;
254253 $ 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 );
257256
258- // Set $selected based on the visibility status.
257+ // Set $selected based on the visibility status.
259258 if ( $ pos_only ) {
260259 $ selected = 'pos_only ' ;
261260 } elseif ( $ online_only ) {
@@ -271,12 +270,12 @@ public function after_variable_attributes_pos_only_products( $loop, $variation_d
271270 public function save_product_variation_pos_only_products ( $ variation_id ): void {
272271 $ valid_options = array ( 'pos_only ' , 'online_only ' , '' );
273272
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 ) ) {
275274 $ settings_instance = Settings::instance ();
276- $ args = array (
277- 'post_type ' => 'variations ' ,
275+ $ args = array (
276+ 'post_type ' => 'variations ' ,
278277 'visibility ' => $ _POST ['variable_pos_visibility ' ][ $ variation_id ],
279- 'ids ' => array ( $ variation_id ),
278+ 'ids ' => array ( $ variation_id ),
280279 );
281280 $ settings_instance ->update_visibility_settings ( $ args );
282281 }
0 commit comments