Skip to content

Commit

Permalink
fix(checkout): fix mailbox options (#844)
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianSDV authored May 23, 2024
1 parent 2d97e9f commit 495ea80
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
13 changes: 10 additions & 3 deletions Model/Quote/Checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,15 @@ public function getDeliveryOptions(array $forAddress = []): array
$this->country = $forAddress['countryId'];
}

$packageType = $this->getPackageType();

$data = [
/* the 'method' string here is actually the carrier_code of the method */
'methods' => explode(',', $this->helper->getGeneralConfig('shipping_methods/methods') ?? ''),
'config' => array_merge(
$this->getGeneralData(),
$this->getDeliveryData(),
['packageType' => $this->getPackageType()]
$this->getDeliveryData($packageType),
['packageType' => $packageType]
),
'strings' => $this->getDeliveryOptionsStrings(),
'forAddress' => $forAddress,
Expand Down Expand Up @@ -163,9 +165,10 @@ private function getPackageType(): string
/**
* Get delivery data
*
* @param string|null $packageType
* @return array
*/
private function getDeliveryData(): array
private function getDeliveryData(?string $packageType = null): array
{
$myParcelConfig = [];
$activeCarriers = $this->getActiveCarriers();
Expand Down Expand Up @@ -221,6 +224,10 @@ private function getDeliveryData(): array
$allowDeliveryOptions = ! $this->package->deliveryOptionsDisabled
&& ($allowPickup || $allowStandardDelivery || $allowMorningDelivery || $allowEveningDelivery);

if ($allowDeliveryOptions && $packageType === AbstractConsignment::PACKAGE_TYPE_MAILBOX_NAME) {
$allowDeliveryOptions = $this->helper->getBoolConfig($carrierPath, 'mailbox/active');
}

$myParcelConfig['carrierSettings'][$carrier] = [
'allowDeliveryOptions' => $allowDeliveryOptions,
'allowStandardDelivery' => $allowStandardDelivery,
Expand Down
13 changes: 2 additions & 11 deletions view/frontend/web/js/model/checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,8 @@ function(

onReFetchDeliveryOptionsConfig: function(response) {
var configuration = response[0].data;
var carrier = Object.keys(configuration.config.carrierSettings)[0];

doRequest(function() {
return Model.calculatePackageType(carrier);
},
{
onSuccess: function(response) {
Model.bestPackageType = response;
Model.setDeliveryOptionsConfig(configuration);
},
});
Model.bestPackageType = configuration.config.packageType;
Model.setDeliveryOptionsConfig(configuration);
},

/**
Expand Down

0 comments on commit 495ea80

Please sign in to comment.