-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e44e453
commit 08d4726
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MyParcelNL\Pdk\App\Order\Calculator\UPS; | ||
|
||
use MyParcelNL\Pdk\App\Order\Calculator\AbstractPdkOrderOptionCalculator; | ||
use MyParcelNL\Pdk\Types\Service\TriStateService; | ||
|
||
/** | ||
* When age check is enabled, signature and only recipient are required. | ||
*/ | ||
final class UPSAgeCheckCalculator extends AbstractPdkOrderOptionCalculator | ||
{ | ||
public function calculate(): void | ||
{ | ||
$shipmentOptions = $this->order->deliveryOptions->shipmentOptions; | ||
|
||
if (TriStateService::ENABLED !== $shipmentOptions->ageCheck) { | ||
return; | ||
} | ||
|
||
$shipmentOptions->signature = TriStateService::ENABLED; | ||
$shipmentOptions->onlyRecipient = TriStateService::ENABLED; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/App/Order/Calculator/UPS/UPSDeliveryTypeCalculator.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace MyParcelNL\Pdk\App\Order\Calculator\UPS; | ||
|
||
use MyParcelNL\Pdk\App\Order\Calculator\AbstractPdkOrderOptionCalculator; | ||
use MyParcelNL\Pdk\Base\Service\CountryCodes; | ||
use MyParcelNL\Pdk\Shipment\Model\DeliveryOptions; | ||
|
||
class UPSDeliveryTypeCalculator extends AbstractPdkOrderOptionCalculator | ||
{ | ||
/** | ||
* @inheritDoc | ||
*/ | ||
public function calculate(): void | ||
{ | ||
$deliveryOptions = $this->order->deliveryOptions; | ||
$cc = $this->order->shippingAddress->cc; | ||
|
||
switch ($deliveryOptions->deliveryType) { | ||
case DeliveryOptions::DELIVERY_TYPE_EXPRESS_NAME: | ||
if ($cc !== CountryCodes::CC_NL) { | ||
$deliveryOptions->deliveryType = DeliveryOptions::DELIVERY_TYPE_STANDARD_NAME; | ||
} | ||
} | ||
} | ||
} |