PluginProbe
PostNL for WooCommerce / 4.4.0
PostNL for WooCommerce v4.4.0
5.9.12 5.9.11 5.9.10 5.9.9 5.9.8 5.9.7 5.9.6 trunk 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 3.1.4 3.1.5 3.1.6 3.1.7 4.0.0 4.0.1 4.0.2 4.3.2 4.3.3 4.4.0 4.4.1 All 72 releases
woo-postnl / includes / adapter / delivery-options-from-order-adapter.php

delivery-options-from-order-adapter.php in PostNL for WooCommerce 4.4.0, at includes/adapter/delivery-options-from-order-adapter.php

36 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 use MyParcelNL\Sdk\src\Adapter\DeliveryOptions\AbstractDeliveryOptionsAdapter;
6 use MyParcelNL\Sdk\src\Model\Consignment\AbstractConsignment;
7
8 class WCPN_DeliveryOptionsFromOrderAdapter extends AbstractDeliveryOptionsAdapter
9 {
10 /**
11 * Creates delivery options but sets most missing data to null instead of default values.
12 *
13 * @param AbstractDeliveryOptionsAdapter|null $originAdapter
14 * @param array $inputData
15 */
16 public function __construct(?AbstractDeliveryOptionsAdapter $originAdapter, array $inputData = [])
17 {
18 $adapterCarrier = $originAdapter ? $originAdapter->getCarrier() : null;
19 $adapterDate = $originAdapter ? $originAdapter->getDate() : null;
20 $adapterDeliveryType = $originAdapter ? $originAdapter->getDeliveryType() : AbstractConsignment::DEFAULT_DELIVERY_TYPE_NAME;
21 $adapterPackageType = $originAdapter ? $originAdapter->getPackageType() : null;
22 $adapterPickupLocation = $originAdapter ? $originAdapter->getPickupLocation() : null;
23
24 $this->carrier = $inputData['carrier'] ?? $adapterCarrier;
25 $this->date = $inputData['date'] ?? $adapterDate;
26 $this->deliveryType = $inputData['delivery_type'] ?? $adapterDeliveryType;
27 $this->packageType = $inputData['package_type'] ?? $adapterPackageType;
28 $this->shipmentOptions = new WCPN_ShipmentOptionsFromOrderAdapter($originAdapter, $inputData);
29
30 $hasInputPickupLocation = isset($inputData['pickup_location']) && ! empty($inputData['pickup_location']);
31 $this->pickupLocation = $hasInputPickupLocation
32 ? new WCPN_PickupLocationFromOrderAdapter($originAdapter, $inputData)
33 : $adapterPickupLocation;
34 }
35 }
36