@@ -46,7 +46,7 @@ public function __construct() {
4646 'online_only ' => __ ( 'Online Only ' , 'woocommerce-pos ' ),
4747 );
4848
49- if ( $ this ->barcode_field && ! \in_array ( $ this ->barcode_field , array ( ' _sku ' , ' _global_unique_id ' ), true ) ) {
49+ if ( $ this ->barcode_field && ! \in_array ( $ this ->barcode_field , $ this -> get_excluded_barcode_fields ( ), 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 );
@@ -280,4 +280,26 @@ public function save_product_variation_pos_only_products( $variation_id ): void
280280 $ settings_instance ->update_visibility_settings ( $ args );
281281 }
282282 }
283+
284+ /**
285+ * Get the list of barcode fields that should be excluded from custom barcode field functionality.
286+ *
287+ * These fields are built-in WooCommerce or plugin fields that don't need custom barcode input.
288+ *
289+ * @return array Array of excluded barcode field keys.
290+ */
291+ private function get_excluded_barcode_fields (): array {
292+ $ excluded_fields = array (
293+ '_sku ' , // default WooCommerce SKU field
294+ '_global_unique_id ' , // default WooCommerce GTIN, UPC, EAN, or ISBN
295+ '_alg_ean ' , // https://wpfactory.com/item/ean-barcodes-woocommerce/
296+ );
297+
298+ /*
299+ * Filter the list of barcode fields that should be excluded from custom barcode field functionality.
300+ *
301+ * @param array $excluded_fields Array of field keys to exclude from custom barcode input.
302+ */
303+ return apply_filters ( 'woocommerce_pos_excluded_custom_barcode_fields ' , $ excluded_fields );
304+ }
283305}
0 commit comments