type = $definition['type']; $this->orderId = $definition['order_id']; $this->title = $definition['title']; $this->items = $definition['items']; $this->shippingProfile = $definition['shipping_profile']; if (!empty($definition['package_type_id'])) { $this->packageTypeId = $definition['package_type_id']; } if (!empty($definition['custom_fields'])) { $this->customFields = $definition['custom_fields']; } } /** * Gets the shipment type. * * @return string * The shipment type. */ public function getType() : string { return $this->type; } /** * Gets the parent order ID. * * @return int * The order ID. */ public function getOrderId() : int { return $this->orderId; } /** * Gets the shipment title. * * @return string * The shipment title. */ public function getTitle() : string { return $this->title; } /** * Gets the shipment items. * * @return \Drupal\commerce_shipping\ShipmentItem[] * The shipment items. */ public function getItems() : array { return $this->items; } /** * Gets the shipping profile. * * @return \Drupal\profile\Entity\ProfileInterface * The shipping profile. */ public function getShippingProfile() : ProfileInterface { return $this->shippingProfile; } /** * Gets the package type plugin ID. * * If the proposed shipment returns no package type ID, shipping methods * are expected to use their default package type. * * @return string|null * The package type plugin ID, or NULL if unknown. */ public function getPackageTypeId() { return $this->packageTypeId; } /** * Gets the custom fields. * * @return array * The custom fields, in the $field_name => $value format. */ public function getCustomFields() : array { return $this->customFields; } }