From 0e4b30de978260b7c4db78550f3d05c836c8ed95 Mon Sep 17 00:00:00 2001
From: Dennis Garding
Date: Thu, 13 Jul 2023 13:12:22 +0200
Subject: [PATCH] feat(PT-12385): Country and state are now also displayed in
the address selection
---
Controllers/Backend/SwagBackendOrder.php | 5 +++++
.../backend/swag_backend_order/model/address.js | 3 ++-
.../view/main/customer_information/billing.js | 12 ++++++------
.../view/main/customer_information/shipping.js | 12 ++++++------
Tests/Functional/Controller/SwagBackendOrderTest.php | 7 +++++++
plugin.xml | 2 ++
6 files changed, 28 insertions(+), 13 deletions(-)
diff --git a/Controllers/Backend/SwagBackendOrder.php b/Controllers/Backend/SwagBackendOrder.php
index 6ef4597..0d852eb 100644
--- a/Controllers/Backend/SwagBackendOrder.php
+++ b/Controllers/Backend/SwagBackendOrder.php
@@ -62,6 +62,11 @@ public function getCustomerAction(): void
$customerId = (int) $this->Request()->get('searchParam');
$result = $repository->get($customerId);
+ foreach ($result['address'] as &$address) {
+ $address['countryName'] = $address['country']['name'];
+ $address['stateName'] = $address['state']['name'];
+ }
+
$this->view->assign([
'data' => $result,
'total' => \count($result),
diff --git a/Resources/views/backend/swag_backend_order/model/address.js b/Resources/views/backend/swag_backend_order/model/address.js
index 71cece6..8854475 100644
--- a/Resources/views/backend/swag_backend_order/model/address.js
+++ b/Resources/views/backend/swag_backend_order/model/address.js
@@ -25,6 +25,8 @@ Ext.define('Shopware.apps.SwagBackendOrder.model.Address', {
{ name: 'additionalAddressLine2', type: 'string' },
{ name: 'salutationSnippet', type: 'string' },
{ name: 'countryId', type: 'int', useNull: true },
+ { name: 'countryName', type: 'string' },
+ { name: 'stateName', type: 'string' },
{
name: 'displayField',
type: 'string',
@@ -38,7 +40,6 @@ Ext.define('Shopware.apps.SwagBackendOrder.model.Address', {
}
}
]
-
});
//{/block}
diff --git a/Resources/views/backend/swag_backend_order/view/main/customer_information/billing.js b/Resources/views/backend/swag_backend_order/view/main/customer_information/billing.js
index 0a31865..98e3c7e 100644
--- a/Resources/views/backend/swag_backend_order/view/main/customer_information/billing.js
+++ b/Resources/views/backend/swag_backend_order/view/main/customer_information/billing.js
@@ -133,11 +133,11 @@ Ext.define('Shopware.apps.SwagBackendOrder.view.main.CustomerInformation.Billing
me.snippets.salutation.miss + ' ',
'',
'{firstname} {lastname},
{zipcode} {city},
{street}',
- '',
- ',
{state}',
+ '',
+ ',
{stateName}',
'',
- '',
- ',
{country}',
+ '',
+ ',
{countryName}',
'',
'',
'{/literal}'
@@ -187,10 +187,10 @@ Ext.define('Shopware.apps.SwagBackendOrder.view.main.CustomerInformation.Billing
'{city}',
'
',
'',
- '{state}',
+ '{stateName}',
'
',
'',
- '{country}',
+ '{countryName}',
'
',
'',
'',
diff --git a/Resources/views/backend/swag_backend_order/view/main/customer_information/shipping.js b/Resources/views/backend/swag_backend_order/view/main/customer_information/shipping.js
index 420eb6a..f8b6c6b 100644
--- a/Resources/views/backend/swag_backend_order/view/main/customer_information/shipping.js
+++ b/Resources/views/backend/swag_backend_order/view/main/customer_information/shipping.js
@@ -166,11 +166,11 @@ Ext.define('Shopware.apps.SwagBackendOrder.view.main.CustomerInformation.Shippin
me.snippets.salutation.miss + ' ',
'',
'{firstname} {lastname},
{zipcode} {city},
{street}',
- '',
- ',
{state}',
+ '',
+ ',
{stateName}',
'',
- '',
- ',
{country}',
+ '',
+ ',
{countryName}',
'',
'',
'{/literal}'
@@ -215,10 +215,10 @@ Ext.define('Shopware.apps.SwagBackendOrder.view.main.CustomerInformation.Shippin
'{city}',
'',
'',
- '{state}',
+ '{stateName}',
'
',
'',
- '{country}',
+ '{countryName}',
'
',
'',
'',
diff --git a/Tests/Functional/Controller/SwagBackendOrderTest.php b/Tests/Functional/Controller/SwagBackendOrderTest.php
index b8daf0d..1177a42 100644
--- a/Tests/Functional/Controller/SwagBackendOrderTest.php
+++ b/Tests/Functional/Controller/SwagBackendOrderTest.php
@@ -452,6 +452,13 @@ public function testGetCustomerSingle(): void
static::assertSame($expectedUser['firstname'], $result['firstname']);
static::assertSame($expectedUser['lastname'], $result['lastname']);
static::assertSame($expectedUser['number'], $result['number']);
+
+ static::assertIsArray($result['address']);
+ static::assertCount(2, $result['address']);
+ foreach ($result['address'] as $address) {
+ static::assertArrayHasKey('countryName', $address);
+ static::assertArrayHasKey('stateName', $address);
+ }
}
public function testGetProducts(): void
diff --git a/plugin.xml b/plugin.xml
index 02871fc..533585f 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -14,9 +14,11 @@
+ PT-12385 - Land und Bundeland werden nun auch in der Addressauswahl angezeigt;
PT-12411 - Deaktivierte Zahlungs- und Versandarten werden nicht mehr in den entsprechenden Auswahl-Listen zur Verfügung gestellt;
+ PT-12385 - Country and state are now also displayed in the address selection;
PT-12411 - Deactivated payment and shipping methods aren't available anymore in the corresponding selections;