Skip to content

Commit

Permalink
fix: honor package type choice from admin (#862)
Browse files Browse the repository at this point in the history
  • Loading branch information
joerivanveen authored Sep 10, 2024
1 parent 25e84fd commit c93eef4
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions Model/Sales/TrackTraceHolder.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,7 @@ public function convertDataFromMagentoToApi(Track $magentoTrack, array $options)
$this->dataHelper->setOrderStatus($magentoTrack->getOrderId(), Order::STATE_NEW);
}

if (isset($deliveryOptions['packageType'])) {
$options['package_type'] = $deliveryOptions['packageType'];
}
$packageType = $this->getPackageType($options, $magentoTrack, $address);
$packageType = $this->getPackageType($magentoTrack, $address, $options, $deliveryOptions);
$dropOffPoint = $this->dataHelper->getDropOffPoint(
CarrierFactory::createFromName($deliveryOptionsAdapter->getCarrier())
);
Expand Down Expand Up @@ -502,24 +499,24 @@ private function getCarrierFromOptions(array $options): ?string
}

/**
* @param array $options
* @param string $packageType
* @param Order\Shipment\Track $magentoTrack
* @param object $address
* @param array $options
* @param array $deliveryOptions
*
* @return int
* @throws \Magento\Framework\Exception\LocalizedException
*/
private function getPackageType(array $options, Track $magentoTrack, $address): int
private function getPackageType(Track $magentoTrack, $address, array $options, array $deliveryOptions): int
{
if ($this->getAgeCheck($magentoTrack, $address, $options)) {
return AbstractConsignment::PACKAGE_TYPE_PACKAGE;
}

// get package type from selected radio buttons and check if package type is set
// get package type from selected radio buttons, try to get from delivery options when default or not set
$packageType = $options['package_type'] ?? 'default';
if ('default' === $packageType) {
$packageType = self::$defaultOptions->getPackageType();
$packageType = $deliveryOptions['packageType'] ?? self::$defaultOptions->getPackageType();
}

if (! is_numeric($packageType)) {
Expand Down

0 comments on commit c93eef4

Please sign in to comment.