Skip to content

Commit

Permalink
Version bump to 3.0.1. Migrate DHL label configuration set again as t…
Browse files Browse the repository at this point in the history
…here was a wrong mapping for the dhlRetoure service.
  • Loading branch information
dennisnissle committed Nov 28, 2023
1 parent 004e757 commit 7998130
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
18 changes: 13 additions & 5 deletions src/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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';
}
}
}

Expand Down Expand Up @@ -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 ) {
Expand All @@ -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 );
}
Expand Down
2 changes: 1 addition & 1 deletion src/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Package {
*
* @var string
*/
const VERSION = '3.0.0';
const VERSION = '3.0.1';

public static $upload_dir_suffix = '';

Expand Down
11 changes: 3 additions & 8 deletions src/ShippingProvider/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,26 +436,21 @@ 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';
}

return $value;
}

/**
* @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;
Expand Down
2 changes: 1 addition & 1 deletion woocommerce-germanized-shipments.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down

0 comments on commit 7998130

Please sign in to comment.