Skip to content

Commit

Permalink
fix: make surcharge mode work as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
EdieLemoine committed Oct 4, 2021
1 parent 56722a4 commit 77ed3b7
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/Service/DeliverySettingsProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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),
Expand Down Expand Up @@ -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),
];
Expand Down

0 comments on commit 77ed3b7

Please sign in to comment.