Skip to content

Commit e33d36f

Browse files
Add requested changes
1 parent 0d8b87b commit e33d36f

File tree

3 files changed

+31
-21
lines changed

3 files changed

+31
-21
lines changed

src/Resources/app/administration/src/module/postnl/component/config/postnl-config-return-options/postnl-config-return-options.html.twig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
/>
77

88
<template v-if="content.type === 'shipmentAndReturn'">
9-
<sw-alert variant="info">
10-
{{ $tc('postnl.config.returnOptions.description.shipmentAndReturn') }}
11-
</sw-alert>
12-
139
<sw-switch-field
1410
v-model:value="content.allowImmediateShipmentAndReturn"
1511
:label="$tc('postnl.config.returnOptions.allowImmediateShipmentAndReturn')"
1612
size="small"
1713
noMarginTop
1814
/>
15+
16+
<sw-alert variant="info" v-if="!content.allowImmediateShipmentAndReturn">
17+
{{ $tc('postnl.config.returnOptions.description.shipmentAndReturn') }}
18+
</sw-alert>
1919
</template>
2020

2121
<template v-if="content.type === 'labelInTheBox'">

src/Resources/app/administration/src/module/postnl/component/shipment-modal/postnl-create-return-modal/index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ Shopware.Component.extend('postnl-create-return-modal', 'postnl-shipment-modal-b
9999
icon: 'regular-truck',
100100
description: this.$t('postnl.order.modal.createReturn.type.smartReturn.description'),
101101
requiredZones: ['NL', 'BE'],
102+
returnZones: ['NL', 'BE'],
102103
},
103104
{
104105
label: this.$t('postnl.order.modal.createReturn.type.shipmentAndReturn.label'),
@@ -109,6 +110,7 @@ Shopware.Component.extend('postnl-create-return-modal', 'postnl-shipment-modal-b
109110
? this.$t('postnl.order.modal.createReturn.type.shipmentAndReturn.description')
110111
: this.$t('postnl.order.modal.createReturn.type.notAvailable'),
111112
requiredZones: ['NL'],
113+
returnZones: ['NL', 'BE'],
112114
},
113115
{
114116
label: this.$t('postnl.order.modal.createReturn.type.labelInTheBox.label'),
@@ -119,10 +121,16 @@ Shopware.Component.extend('postnl-create-return-modal', 'postnl-shipment-modal-b
119121
? this.$t('postnl.order.modal.createReturn.type.labelInTheBox.description')
120122
: this.$t('postnl.order.modal.createReturn.type.notAvailable'),
121123
requiredZones: ['NL', 'BE'],
124+
returnZones: ['NL'],
122125
}
123126
]
124127
.filter(returnType => returnType.requiredZones.some(zone => this.destinationZones.includes(zone)))
125-
}
128+
.filter(returnType => returnType.returnZones.some(zone => zone === this.returnZone))
129+
},
130+
131+
returnZone() {
132+
return this?.returnAddress?.countrycode
133+
},
126134
},
127135

128136
methods: {

src/Service/PostNL/Builder/ShipmentBuilder.php

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public function buildShipment(OrderEntity $order, Context $context): Shipment
171171
!$context->hasState(OrderReturnAttributeStruct::S_SMART_RETURN) &&
172172
$returnOptions->getType() === ReturnOptionsStruct::T_SHIPMENT_AND_RETURN &&
173173
in_array($product->getDestinationZone(), [Zone::NL]) &&
174-
$returnCountryCode === 'NL'
174+
in_array($returnCountryCode, [Zone::NL, Zone::BE])
175175
) {
176176
$this->orderService->updateOrderCustomFields(
177177
$order->getId(),
@@ -438,24 +438,26 @@ public function buildProductOptions(OrderEntity $order, ProductEntity $product,
438438
}
439439

440440
$returnOptions = $config->getReturnOptions();
441-
if(
442-
$returnOptions->getType() !== ReturnOptionsStruct::T_NONE &&
443-
$product->getDestinationZone() === Zone::NL &&
444-
!$context->hasState(OrderReturnAttributeStruct::S_SMART_RETURN)
445-
) {
441+
442+
if(!$context->hasState(OrderReturnAttributeStruct::S_SMART_RETURN)) {
446443
$productOptions[] = new ProductOption('191', '001');
447444

448-
switch($returnOptions->getType()) {
449-
case ReturnOptionsStruct::T_LABEL_IN_THE_BOX:
450-
$productOptions[] = new ProductOption('152', '028');
451-
break;
452-
case ReturnOptionsStruct::T_SHIPMENT_AND_RETURN:
453-
$productOptions[] = new ProductOption('152', '026');
445+
if(
446+
$returnOptions->getType() === ReturnOptionsStruct::T_LABEL_IN_THE_BOX &&
447+
in_array($product->getDestinationZone(), [Zone::NL])
448+
) {
449+
$productOptions[] = new ProductOption('152', '028');
450+
}
454451

455-
if(!$returnOptions->isAllowImmediateShipmentAndReturn()) {
456-
$productOptions[] = new ProductOption('191', '004');
457-
}
458-
break;
452+
if(
453+
$returnOptions->getType() === ReturnOptionsStruct::T_SHIPMENT_AND_RETURN &&
454+
in_array($product->getDestinationZone(), [Zone::NL, Zone::BE])
455+
) {
456+
$productOptions[] = new ProductOption('152', '026');
457+
458+
if(!$returnOptions->isAllowImmediateShipmentAndReturn()) {
459+
$productOptions[] = new ProductOption('191', '004');
460+
}
459461
}
460462
}
461463

0 commit comments

Comments
 (0)