diff --git a/includes/class-siti-stock-supplier-exports.php b/includes/class-siti-stock-supplier-exports.php index 7b90f25..cd294fa 100644 --- a/includes/class-siti-stock-supplier-exports.php +++ b/includes/class-siti-stock-supplier-exports.php @@ -178,7 +178,6 @@ class Siti_Stock_Supplier_Exports { ? $settings['supplier_exports'] : array(); - $configured = $this->ensure_defaults( $configured ); $configured = $this->ensure_distinct_meta_suppliers( $configured ); uasort( @@ -471,37 +470,6 @@ class Siti_Stock_Supplier_Exports { } } - /** - * Ensure default suppliers exist in config. - * - * @param array $configured Configured values. - * @return array> - */ - private function ensure_defaults( array $configured ) { - foreach ( $this->get_default_suppliers() as $key => $data ) { - if ( isset( $configured[ $key ] ) ) { - if ( empty( $configured[ $key ]['supplier'] ) ) { - $configured[ $key ]['supplier'] = $data['label']; - } - $configured[ $key ]['time'] = $this->normalize_time( - isset( $configured[ $key ]['time'] ) ? $configured[ $key ]['time'] : $data['time'] - ); - if ( ! isset( $configured[ $key ]['enabled'] ) ) { - $configured[ $key ]['enabled'] = $data['enabled']; - } - continue; - } - - $configured[ $key ] = array( - 'supplier' => $data['label'], - 'time' => $data['time'], - 'enabled' => $data['enabled'], - ); - } - - return $configured; - } - /** * Add entries for suppliers found in product meta. * @@ -509,22 +477,21 @@ class Siti_Stock_Supplier_Exports { * @return array */ private function ensure_distinct_meta_suppliers( array $configured ) { + $result = array(); + foreach ( $this->get_distinct_suppliers() as $supplier ) { - $key = $this->normalize_supplier_key( $supplier ); - - if ( isset( $configured[ $key ] ) ) { - $configured[ $key ]['supplier'] = $supplier; - continue; - } - - $configured[ $key ] = array( + $key = $this->normalize_supplier_key( $supplier ); + $existing = isset( $configured[ $key ] ) ? $configured[ $key ] : array(); + $result[ $key ] = array( 'supplier' => $supplier, - 'time' => $this->get_default_time_for_key( $key ), - 'enabled' => $this->is_default_enabled( $key ), + 'time' => $this->normalize_time( + isset( $existing['time'] ) ? $existing['time'] : $this->get_default_time_for_key( $key ) + ), + 'enabled' => isset( $existing['enabled'] ) ? (bool) $existing['enabled'] : $this->is_default_enabled( $key ), ); } - return $configured; + return $result; } /** diff --git a/siti-stock-plugin.php b/siti-stock-plugin.php index 168cc20..c3d2f2e 100644 --- a/siti-stock-plugin.php +++ b/siti-stock-plugin.php @@ -3,7 +3,7 @@ * Plugin Name: Siti Stock Plugin * Plugin URI: https://github.com/SitiWeb/siti-stock-plugin * Description: Synchroniseert WooCommerce voorraad met het externe Siti voorraadplatform. - * Version: 1.2.5 + * Version: 1.2.6 * Author: Siti Web * Author URI: https://www.siti.nl * Requires PHP: 8.1 @@ -16,7 +16,7 @@ if ( ! defined( 'ABSPATH' ) ) { exit; } -define( 'SITI_STOCK_PLUGIN_VERSION', '1.2.5' ); +define( 'SITI_STOCK_PLUGIN_VERSION', '1.2.6' ); define( 'SITI_STOCK_PLUGIN_FILE', __FILE__ ); define( 'SITI_STOCK_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );