diff --git a/package.json b/package.json index 5c7f6764..f2078199 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "woocommerce-germanized-shipments", "title": "Shipments for WooCommerce", - "version": "3.0.0", + "version": "3.0.1", "homepage": "https://vendidero.de", "repository": { "type": "git", diff --git a/src/Install.php b/src/Install.php index 674ec95a..a3987038 100644 --- a/src/Install.php +++ b/src/Install.php @@ -21,8 +21,12 @@ public static function install() { self::create_tables(); self::maybe_create_return_reasons(); - if ( ! is_null( $current_version ) && version_compare( $current_version, '3.0.0', '<' ) ) { - self::migrate_to_configuration_sets(); + if ( ! is_null( $current_version ) ) { + if ( version_compare( $current_version, '3.0.0', '<' ) ) { + self::migrate_to_configuration_sets(); + } elseif ( version_compare( $current_version, '3.0.1', '<' ) ) { + self::migrate_to_configuration_sets( 'dhl' ); + } } self::maybe_create_packaging(); @@ -68,8 +72,9 @@ protected static function get_configuration_set_data( $setting_name, $value ) { 'min_age' => $value, ); } elseif ( 'label_auto_inlay_return_label' === $setting_name ) { - $service_name = 'dhlRetoure'; - $services[ $service_name ] = 'yes'; + if ( 'no' !== $value ) { + $services['dhlRetoure'] = 'yes'; + } } } @@ -126,7 +131,7 @@ protected static function create_configuration_set_from_migration_data( $config_ } public static function migrate_to_configuration_sets( $providers_to_migrate = array() ) { - $providers = empty( $providers_to_migrate ) ? Helper::instance()->get_shipping_providers() : $providers_to_migrate; + $providers = empty( $providers_to_migrate ) ? Helper::instance()->get_shipping_providers() : (array) $providers_to_migrate; $provider_ids = array(); foreach ( $providers as $provider ) { @@ -151,6 +156,9 @@ public static function migrate_to_configuration_sets( $providers_to_migrate = ar } } + var_dump( $config_data ); + exit(); + if ( isset( $config_data['products'] ) ) { self::create_configuration_set_from_migration_data( $config_data, $provider, $provider ); } diff --git a/src/Package.php b/src/Package.php index 2bf2f776..51a658ff 100644 --- a/src/Package.php +++ b/src/Package.php @@ -27,7 +27,7 @@ class Package { * * @var string */ - const VERSION = '3.0.0'; + const VERSION = '3.0.1'; public static $upload_dir_suffix = ''; diff --git a/src/ShippingProvider/Service.php b/src/ShippingProvider/Service.php index cb648680..d9f6d044 100644 --- a/src/ShippingProvider/Service.php +++ b/src/ShippingProvider/Service.php @@ -436,7 +436,7 @@ public function get_value( $shipment, $suffix = '' ) { } } - if ( 'no' === $value && true === $this->book_as_default( $shipment ) ) { + if ( 'no' === $value && is_a( $shipment, '\Vendidero\Germanized\Shipments\Shipment' ) && true === $this->book_as_default( $shipment ) ) { $value = 'yes'; } @@ -444,18 +444,13 @@ public function get_value( $shipment, $suffix = '' ) { } /** - * @param Shipment|ConfigurationSet $shipment + * @param Shipment $shipment * * @return boolean */ public function book_as_default( $shipment ) { $book_as_default = false; - - if ( is_a( $shipment, 'Vendidero\Germanized\Shipments\Labels\ConfigurationSet' ) ) { - $config_set = $shipment; - } else { - $config_set = $shipment->get_label_configuration_set(); - } + $config_set = $shipment->get_label_configuration_set(); if ( $config_set && $config_set->has_service( $this->get_id() ) ) { $book_as_default = true; diff --git a/woocommerce-germanized-shipments.php b/woocommerce-germanized-shipments.php index 21000532..bec459b9 100644 --- a/woocommerce-germanized-shipments.php +++ b/woocommerce-germanized-shipments.php @@ -5,7 +5,7 @@ * Description: The Germanized Shipments integration, installed as a feature plugin for development and testing purposes. * Author: vendidero * Author URI: https://vendidero.de - * Version: 3.0.0 + * Version: 3.0.1 * Requires PHP: 5.6 * License: GPLv3 *