From 77ed3b7b675fc0d48a0275b24b97417c1dfcc269 Mon Sep 17 00:00:00 2001 From: Edie Lemoine Date: Wed, 29 Sep 2021 19:32:32 +0200 Subject: [PATCH] fix: make surcharge mode work as expected --- src/Service/DeliverySettingsProvider.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Service/DeliverySettingsProvider.php b/src/Service/DeliverySettingsProvider.php index 85f8cb32..049a59ea 100644 --- a/src/Service/DeliverySettingsProvider.php +++ b/src/Service/DeliverySettingsProvider.php @@ -106,10 +106,10 @@ public function get(): array $updatedDropOffDays = $this->updateDropOffDays($dropOffDays, $dropOffDateObj, $cutoffExceptions); // no dropoffdays left for the coming week, just schedule it for next week - if (! $updatedDropOffDays) { - $dropOffDelay += 7; - } else { + if ($updatedDropOffDays) { $dropOffDays = array_values($updatedDropOffDays); + } else { + $dropOffDelay += 7; } $shippingOptions = $this->module->getShippingOptions($this->idCarrier, $address); @@ -120,12 +120,14 @@ public function get(): array $surchargeOption = Configuration::get(Constant::DELIVERY_OPTIONS_PRICE_FORMAT_CONFIGURATION_NAME); $showPriceSurcharge = Constant::DELIVERY_OPTIONS_PRICE_FORMAT_SURCHARGE === $surchargeOption; + $priceStandardDelivery = $showPriceSurcharge ? null : Tools::ps_round($priceStandardDelivery, 2); + return [ 'config' => [ 'platform' => ($this->module->isBE() ? 'belgie' : 'myparcel'), 'carrierSettings' => $carrierSettings, 'priceMorningDelivery' => Tools::ps_round(CarrierConfigurationProvider::get($this->idCarrier, 'priceMorningDelivery') * $taxRate, 2), - 'priceStandardDelivery' => Tools::ps_round($priceStandardDelivery, 2), + 'priceStandardDelivery' => $priceStandardDelivery, 'priceEveningDelivery' => Tools::ps_round(CarrierConfigurationProvider::get($this->idCarrier, 'priceEveningDelivery') * $taxRate, 2), 'priceSignature' => Tools::ps_round(CarrierConfigurationProvider::get($this->idCarrier, 'priceSignature') * $taxRate, 2), 'priceOnlyRecipient' => Tools::ps_round(CarrierConfigurationProvider::get($this->idCarrier, 'priceOnlyRecipient') * $taxRate, 2), @@ -167,10 +169,10 @@ public function get(): array 'retry' => CarrierConfigurationProvider::get($this->idCarrier, 'retry'), ], 'address' => [ - 'cc' => strtoupper(Country::getIsoById($address->id_country)), - 'city' => $address->city, + 'cc' => strtoupper(Country::getIsoById($address->id_country)), + 'city' => $address->city, 'postalCode' => $address->postcode, - 'number' => $houseNumber, + 'number' => $houseNumber, ], 'delivery_settings' => DeliveryOptions::queryByCart((int) $this->context->cart->id), ];